# Item Response Model definition in brms for cumulative logit link

**URL:** <https://discourse.mc-stan.org/t/item-response-model-definition-in-brms-for-cumulative-logit-link/32493>\
**Category:** Modeling\
**Tags:** brms, specification\
**Created:** [August 19, 2023, 3:08pm UTC](https://discourse.mc-stan.org/t/item-response-model-definition-in-brms-for-cumulative-logit-link/32493 "2023-08-19T15:08:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stef](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stef/32/16622_2.png) [@stef](https://discourse.mc-stan.org/u/stef)\
**Post date:** [August 19, 2023, 3:08pm UTC](https://discourse.mc-stan.org/t/item-response-model-definition-in-brms-for-cumulative-logit-link/32493/1 "2023-08-19T15:08:28Z")

</div>

In his article on item response theory in `brms` ([https://arxiv.org/pdf/1905.09501.pdf?](https://arxiv.org/pdf/1905.09501.pdf?)), Paul shows how to use his package for a so-called _two-parameter graded response model_. These are cumulative logit models with two item-specific parameters. An _easiness_ parameter, say b\_i, and a _discrimination_ parameter, say a\_i, for each item i.

A simple version of my current code to fit such a model would be

```plaintext
family <- brmsfamily("cumulative", "logit")
formula <- bf(score ~ 1 + (1 | item) + (1 | rater), disc ~ 1 + (1 | item))
model <- brm(formula = formula, data = df, family = family)

```

However, mathematically, I can see two possible models that could be defined by this syntax. Let’s assume score has three ordinal categories Y\_{i,j} \in \{1,2,3\} and that raters are enumerated by j = 1, ..., J and their ability is \theta\_j. The probability to score a 1 (lowest category) could be defined in two ways now.

**Version 1**

Pr(Y\_{i,j} = 1) = \text{expit}(\beta\_1 - ((a\_i) \* (b\_i + \theta\_j)))

**Version 2**

Pr(Y\_{i,j} = 1) = \text{expit}(a\_i (\beta\_1 - (b\_i + \theta\_j)))

In the first, the threshold parameter \beta\_1 is not multiplied by the discrimination parameter, in the second one, it is. Of course, it’s the same for the definition of the probability of the second category, but this is enough to make the point.

To me, it is not clear which of the two models `brms` is fitting here, even after carefully studying the associated paper. It seems they would refer to different underlying model definitions?

---

<div class="post-metadata">

**Author:** ![stef](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stef/32/16622_2.png) [@stef](https://discourse.mc-stan.org/u/stef)\
**Post date:** [August 20, 2023, 8:08am UTC](https://discourse.mc-stan.org/t/item-response-model-definition-in-brms-for-cumulative-logit-link/32493/2 "2023-08-20T08:08:26Z")

</div>

I have found the solution in another paper by Paul (Ordinal Regression Models in Psychology: A Tutorial, equation 36), it is **Version 2**. It can also be seen in the Stan code

```plaintext
  real cumulative_logit_lpmf(int y, real mu, real disc, vector thres) {
    int nthres = num_elements(thres);
    if (y == 1) {
      return log_inv_logit(disc * (thres[1] - mu));
    } else if (y == nthres + 1) {
      return log1m_inv_logit(disc * (thres[nthres] - mu));
    } else {
      return log_diff_exp(log_inv_logit(disc * (thres[y] - mu)),
                          log_inv_logit(disc * (thres[y - 1] - mu)));
    }
  }

```
