def setup_ordinal(self, endog, exog, groups, time, offset):
        """
        Restructure ordinal data as binary indicators so that they can
        be analysed using Generalized Estimating Equations.
        """

        self.endog_orig = endog.copy()
        self.exog_orig = exog.copy()
        self.groups_orig = groups.copy()
        if offset is not None:
            self.offset_orig = offset.copy()
        else:
            self.offset_orig = None
            offset = np.zeros(len(endog))
        if time is not None:
            self.time_orig = time.copy()
        else:
            self.time_orig = None
            time = np.zeros((len(endog),1))

        exog = np.asarray(exog)
        endog = np.asarray(endog)
        groups = np.asarray(groups)
        time = np.asarray(time)
        offset = np.asarray(offset)

        # The unique outcomes, except the greatest one.
        self.endog_values = np.unique(endog)
        endog_cuts = self.endog_values[0:-1]
        ncut = len(endog_cuts)

        nrows = ncut * len(endog)
        exog_out = np.zeros((nrows, exog.shape[1]),
                            dtype=np.float64)
        endog_out = np.zeros(nrows, dtype=np.float64)
        intercepts = np.zeros((nrows, ncut), dtype=np.float64)
        groups_out = np.zeros(nrows, dtype=groups.dtype)
        time_out = np.zeros((nrows, time.shape[1]),
                            dtype=np.float64)
        offset_out = np.zeros(nrows, dtype=np.float64)

        jrow = 0
        zipper = zip(exog, endog, groups, time, offset)
        for (exog_row, endog_value, group_value, time_value,
             offset_value) in zipper:

            # Loop over thresholds for the indicators
            for thresh_ix, thresh in enumerate(endog_cuts):

                exog_out[jrow, :] = exog_row
                endog_out[jrow] = (int(endog_value > thresh))
                intercepts[jrow, thresh_ix] = 1
                groups_out[jrow] = group_value
                time_out[jrow] = time_value
                offset_out[jrow] = offset_value
                jrow += 1

        exog_out = np.concatenate((intercepts, exog_out), axis=1)

        # exog column names, including intercepts
        xnames = ["I(y>%.1f)" % v for v in endog_cuts]
        if type(self.exog_orig) == pd.DataFrame:
            xnames.extend(self.exog_orig.columns)
        else:
            xnames.extend(["x%d" % k for k in range(1, exog.shape[1]+1)])
        exog_out = pd.DataFrame(exog_out, columns=xnames)

        # Preserve the endog name if there is one
        if type(self.endog_orig) == pd.Series:
            endog_out = pd.Series(endog_out, name=self.endog_orig.name)

        return endog_out, exog_out, groups_out, time_out, offset_out
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/genmod/generalized_estimating_equations.py/OrdinalGEE.setup_ordinal/original