Dear Paul,

I have checked your publications and code with regard to IRT models. Checking uniform DIF is clear to me and pretty straight forward. I now want to also check for non-uniform DIF. We compare the same questions (binary outcome) for two different countries. As you describe in your paper “Bayesian Item Response Modeling in R with brms and Stan” I now want to use a “maximal multilevel approach” to check for potential non-uniform DIF. Country is thus a person covariate varying over items. I came up with two approaches that yielded so far similar results and wonder which is the better choice (or which one is wrong):

First approach:

```
formula_4pl_dif <- bf(
response ~ gamma + (1 - gamma - psi) *
inv_logit(beta + exp(logalpha) * theta),
nl = TRUE,
theta ~ 0 + (1 | person),
beta ~ 1 + country + (1 + country |i| item),
logalpha ~ 1 + country + (1 + country |i| item),
logitgamma ~ 1 + country + (1 + country |i| item),
nlf(gamma ~ inv_logit(logitgamma)),
logitpsi ~ 1 + country + (1 + country |i| item),
nlf(psi ~ inv_logit(logitpsi)),
family = brmsfamily("bernoulli", link = "identity")
)
```

I then test whether the estimates are different from 0

```
hypothesis(fit_4pl, "beta_countrya < 0", scope = "coef", group = "item", alpha = 0.05)
hypothesis(fit_4pl, "beta_countrya > 0", scope = "coef", group = "item", alpha = 0.05)
```

For the second approach I followed what you describe in the paper with gender - basically using (0 + country |i| item) which gives each country its own varying effect.

Second approach:

```
formula_4pl_dif <- bf(
response ~ gamma + (1 - gamma - psi) *
inv_logit(beta + exp(logalpha) * theta),
nl = TRUE,
theta ~ 0 + (1 | person),
beta ~ 1 + country + (0 + country |i| item),
logalpha ~ 1 + country + (0 + country |i| item),
logitgamma ~ 1 + country + (0 + country |i| item),
nlf(gamma ~ inv_logit(logitgamma)),
logitpsi ~ 1 + country + (0 + country |i| item),
nlf(psi ~ inv_logit(logitpsi)),
family = brmsfamily("bernoulli", link = "identity")
)
```

Then I would check for differences:

```
hypothesis(fit_4pl, "beta_countrya = beta_countryb", scope = "coef", group = "item", alpha = 0.05)
```

What would you recommend?

Thanks for your help!

- Operating System: Windows
- brms Version: 2.12.0