0

I'm trying to run a multinomial regression for the first time. I am attempting to build the code based on a built-in dataset, but I'm having trouble getting it to do what I need. I want to run a model with random effects only. Here is the code with one random effect which I think is fine:

library(MASS)
library(mlogit)

house.mblogit1 <- mblogit(Sat ~ 1, random=~1|Infl, maxit=1000, estimator = "REML",data = housing)

However, I can't find an example of how to add another random effect (e.g., Type). I tried it and I can't figure out the syntax. Both these are wrong apparently:

house.mblogit2 <- mblogit(Sat ~ 1, random=~1|Infl+ ~1|Type, data = housing)
house.mblogit3 <- mblogit(Sat ~ 1, random=~1|Infl+Type, data = housing)

Error: Invalid random formula

Is it even possible to do it?

Agata
  • 343
  • 3
  • 13
  • 1
    From the help, it follows that random parameter accepts a list. Try `random=list(~1|Infl, ~1|Type)` or similar – Ric Nov 08 '22 at 17:12
  • That did not work, but it gave me the idea to try random=c(~1|Infl, ~1|Type) which did so thank you! Now just need to make the actual model converge with three random effects... – Agata Nov 08 '22 at 19:42

0 Answers0