Using the `defData`

and `genData`

functions, it is relatively easy to specify multinomial distributions that characterize categorical data. Order becomes relevant when the categories take on meanings related to strength of opinion or agreement (as in a Likert-type response) or frequency. A motivating example could be when a response variable takes on five possible values: (1) strongly disagree, (2) disagree, (3) neutral, (4) agree, (5) strongly agree. There is a natural order to the response possibilities.

It is common to summarize the data by looking at *cumulative* probabilities, odds, or log-odds. Comparisons of different exposures or individual characteristics typically look at how these cumulative measures vary across the different exposures or characteristics. So, if we were interested in cumulative odds, we would compare \[\small{\frac{P(response = 1|exposed)}{P(response > 1|exposed)} \ \ vs. \ \frac{P(response = 1|unexposed)}{P(response > 1|unexposed)}},\]

\[\small{\frac{P(response \le 2|exposed)}{P(response > 2|exposed)} \ \ vs. \ \frac{P(response \le 2|unexposed)}{P(response > 2|unexposed)}},\]

and continue until the last (in this case, fourth) comparison

\[\small{\frac{P(response \le 4|exposed)}{P(response > 4|exposed)} \ \ vs. \ \frac{P(response \le 4|unexposed)}{P(response > 4|unexposed)}},\]

We can use an underlying (continuous) latent process as the basis for data generation. If we assume that probabilities are determined by segments of a logistic distribution (see below), we can define the ordinal mechanism using thresholds along the support of the distribution. If there are \(k\) possible responses (in the meat example, we have 5), then there will be \(k-1\) thresholds. The area under the logistic density curve of each of the regions defined by those thresholds (there will be \(k\) distinct regions) represents the probability of each possible response tied to that region.

In the cumulative logit model, the underlying assumption is that the odds ratio of one population relative to another is constant across all the possible responses. This means that all of the cumulative odds ratios are equal:

\[\small{\frac{codds(P(Resp = 1 | exposed))}{codds(P(Resp = 1 | unexposed))} = \frac{codds(P(Resp \leq 2 | exposed))}{codds(P(Resp \leq 2 | unexposed))} = \ ... \ = \frac{codds(P(Resp \leq 4 | exposed))}{codds(P(Resp \leq 4 | unexposed))}}\]

In terms of the underlying process, this means that each of the thresholds shifts the same amount (as shown below) where we add 1.1 units to each threshold that was set for the exposed group. What this effectively does is create a greater probability of a lower outcome for the unexposed group.

In the `R`

package `ordinal`

, the model is fit using function `clm`

. The model that is being estimated has the form

\[log \left( \frac{P(Resp \leq i)}{P(Resp > i)} | Group \right) = \alpha_i - \beta*I(Group=exposed) \ \ , \ i \in \{1, 2, 3, 4\}\]

The model specifies that the cumulative log-odds for a particular category is a function of two parameters, \(\alpha_i\) and \(\beta\). (Note that in this parameterization and the model fit, \(-\beta\) is used.) \(\alpha_i\) represents the cumulative log odds of being in category \(i\) or lower for those in the reference exposure group, which in our example is Group A. *\(\alpha_i\) also represents the threshold of the latent continuous (logistic) data generating process.* \(\beta\) is the cumulative log-odds ratio for the category \(i\) comparing the unexposed to reference group, which is the exposed. *\(\beta\) also represents the shift of the threshold on the latent continuous process for the exposed relative to the unexposed*. The proportionality assumption implies that the shift of the threshold for each of the categories is identical.

To generate ordered categorical data using `simstudy`

, there is a function `genOrdCat`

.

baseprobs <- c(0.11, 0.33, 0.36, 0.17, 0.03) defA <- defDataAdd(varname = "z", formula = "-1.1*exposed", dist = "nonrandom") set.seed(130) dT <- genData(25000) dT <- trtAssign(dT, grpName = "exposed") dT <- addColumns(defA, dT) dT <- genOrdCat(dT, adjVar = "z", baseprobs, catVar = "r")

Estimating the parameters of the model using function `clm`

, we can recover the original parameters quite well.

```
## formula: r ~ exposed
## data: dT
##
## link threshold nobs logLik AIC niter max.grad cond.H
## logit flexible 25000 -33223.00 66456.01 6(0) 8.24e-11 2.2e+01
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## exposed -1.1434 0.0241 -47.5 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Threshold coefficients:
## Estimate Std. Error z value
## 1|2 -2.0938 0.0222 -94.5
## 2|3 -0.2614 0.0174 -15.1
## 3|4 1.3766 0.0205 67.2
## 4|5 3.4552 0.0456 75.8
```

In the model output, the `exposed`

coefficient of -1.15 is the estimate of \(-\beta\) (i.e. \(\hat{\beta} = 1.15\)), which was set to -1.1 in the simulation. The threshold coefficients are the estimates of the \(\alpha_i\)’s in the model - and match the thresholds for the unexposed group.

The log of the cumulative odds for groups 1 to 4 from the data without exposure are

(logOdds.unexp <- log(odds(cumsum(dT[exposed == 0, prop.table(table(r))])))[1:4])

```
## 1 2 3 4
## -2.08 -0.26 1.36 3.43
```

And under exposure:

(logOdds.expos <- log(odds(cumsum(dT[exposed == 1, prop.table(table(r))])))[1:4])

```
## 1 2 3 4
## -0.96 0.88 2.57 4.69
```

The log of the cumulative odds ratios for each of the four groups is

logOdds.expos - logOdds.unexp

```
## 1 2 3 4
## 1.1 1.1 1.2 1.3
```