I am trying to run a Mixed Effect Multinomial Logistic Regression Model in R using mixcat package and npmlt() command. Two random effects (participant id ("id" and day ("tag") nested within id) are present. I have almost no experience in R so I am trying to explain as good as i can.
This is the code i tried to use:
attach(final_merged_data_MLM)
model <- npmlt(formula = NSSI_risky_alone ~ lag_NA_within + centered_NA_global +
lag_URGE_within + centered_URGE_global + geschlecht + stunde_cluster +
bpd_anz + binary_tag,
random = ~ 1 | id + tag)
This is the warning message I keep getting:
Error in model.matrix.default(random, data = a) :
model frame and formula mismatch in model.matrix()
Things i tried to solve but did not work:
- I read in another part that someone had the same problem and solve it just the banal solution of renaming the variables with shorter names. Tried it but did not work.
- Also tried the same code but with a data frame containing only the relevant variables (as the data frame has a total of 90 variables/columns). Did not work.
- Tried to see if the code works with just one of the several predictors. Did not work.
- Tried the code without random effects, with another outcome variable,....also did not work.
- Checked the format of the variables and all are correctly specified (factor or numeric; outcome variable is factor and contains fields with "not available" values; however tried the code with the same outcome variable without "not available" fields and still did not work).
- Tried other packages (e.g. mclogit) but got other, different warning messages. Now focusing on Mixcat as seems the best package for my purposes
I really have no idea on what to do and would be extremely grateful for any help...
Best wishes,
Cristina