[Question] Random intercept model
Closed this issue · 6 comments
This is more of a question about the mmrm()
. And my apologies for not including a reproducible example. If the package can do what I am looking for, I will add an example later.
I need to fit a random intercept model to a repeated measure data. I have a hard time trying to figure out the within-subject variance-covariance matrix from the lme4 package (A side note, I don't think they used the unstructured matrix). So I shifted to the mmrm package now. But when I fit the model, I received an error message on the names(data)
. My random effect in the model is specified like us(1 | id)
. I noticed that the examples in the documentation all included a random slope of one variable from the data. I wonder if the mmrm()
can only allows a random intercept per subject.
Hi,
So the random intercept induced covariance structure is a special case of the compound symmetric covariance structure (i.e. if you have positive correlation between the observations of a subject). So you can use cs()
in the model formula.
Does this answer your question?
Thanks for your response. I tried the compound symmetric covariance structure, but I got the same error message.
Error in h_mmrm_tmb_data(formula_parts, data, weights, reml, singular = if (control$accept_singular) "drop" else "error", :
Assertion on 'names(data)' failed: Names must include the elements {'1','id'}, but is missing elements {'1'}.
Yeah please check out the documentation, you need the visit and subject variables inside the covariance specification
I see this pattern throughout the examples, but I am a little confused. Being familiar with the syntax in lme4, I think adding a variable before the vertical bar in the random effect means adding a random slope of that variable. Does mmrm use a different syntax? For example, cs(visit|id)
does not imply a random slope of visit.
Yes, it is a different syntax than lme4
. Our syntax is close to glmmTMB
e.g.
Got it. Thanks!