1

I want to run a multinomial mixed effects model with the mclogit package of R.

Below can be show the head of my data frame.

> head(mydata)
  ID VAR1 X1 Time  Y other_X3 other_X4 other_X5 other_X6 other_X7
1  1    1  1    1 10        0        0        0        0        0
2  1    1  1    2  5        1        1        1        0        2
3  2    2  3    1 10        0        0        0        0        0
4  2    2  3    2  7        1        0        0        0        2
5  3    1  3    1 10        0        0        0        0        0
6  3    1  3    2  7        1        0        0        0        2

The Y variable is a categorical variable with 10 levels (1-10, is a score variable). What I want is a model for y~x1+x2 by adding random intercept effect (for ID variable) and random slope effect (for Time variable).

I try the following command by I got an error.

> mixed_model <- mclogit( cbind(Y, ID) ~ X1 + Time + X1*Time, 
+                         random = list(~1|ID, ~Time|ID), data = mydata)

Error in FUN(X[[i]], ...) : 
  No predictor variable remains in random part of the model.
Please reconsider your model specification.
In addition: Warning messages:
1: In mclogit(cbind(Y, ID) ~ X1 + Time + X1 * Time, random = list(~1 |  :
  removing X1 from model due to insufficient within-choice set variance
2: In FUN(X[[i]], ...) : removing intercept from random part of the model
 because of insufficient within-choice set variance

Any idea about how to correct it ? Thank you in advance.

Didie
  • 31
  • 3
  • `ID` is at the same time a response and a random effect? – Rui Barradas Sep 03 '22 at 06:43
  • Hi @RuiBarradas and thank you for your quick responce. We only need this variable for the random intercept part which is the ID of each participant. I am not sure if my code syntax above is correct. I tried to run something. – Didie Sep 03 '22 at 07:12
  • You cannot have the same variable on both sides of `~`. Try with `Y` as the only response and see if the model is what you are looking for. – Rui Barradas Sep 03 '22 at 07:56

0 Answers0