1

I am using the following model in R:

glmer(y ~ x + z + (1|id), weights = specification, family = binomial, data = data)

which:

y ~ binomial(y, specification)
Logit(y) = intercept + a*x + b*z

a and b are coefficients for x and z variables.

a|a0+a1 = a0 + a1*I

One of the variables (here x) depends on other variable (here I), so I need a hierarchical model to see the heterogeneity in mean of the x.

I would appreciate it if anyone could help me with this problem? Sorry if the question does not look professional! This is one of my first experiences.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Amir
  • 11
  • 2
  • As your question seems to be more about the methodological principles underlying GLMMs rather than conding per se, you should ask your question on [Cross Validated](https://stats.stackexchange.com/) instead. Also, consult [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Dion Groothof Jan 24 '22 at 22:01
  • is `I` an indicator variable? – Ben Bolker Jan 24 '22 at 22:58
  • @BenBolker Thank you very much for your reply! Actually, in my origin model the I variable is daily number of COVID cases and x variable is also a continuous variable. – Amir Jan 25 '22 at 00:04

1 Answers1

1

I'm not perfectly sure I understand the question, but: if Logit(y) = intercept + a*x + b*z and a = a0 + a1*I, then it would seem that

Logit(y) = intercept + (a0+a1*I)*x + b*z

This looks like a straightforward interaction model:

glmer(y ~ 1 + x + x:I + z + (1|id), ...)

to make it more explicit, this could also be written as

glmer(y ~ 1 + x + I(x*I) + z + (1|id), ...)

(although the use of I as a predictor variable and in the I() function is a little bit confusing at first glance ...)

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453