[R-sig-ME] nested random effects with lmer
Malcolm Fairbrother
m.fairbrother at bristol.ac.uk
Sat Dec 3 12:44:53 CET 2011
Hi Charles,
> lmeobj1<-lmer(outcome~med+time+medtime+(time|subjid)+(subjid|clinid))
With this call, you've got a random intercept for subjid (which sounds like it makes sense for your data), and you're also treating it as a fixed effect that can vary randomly (which doesn't make sense), but without estimating an overall average effect (even less sense).
I think you should try:
lmeobj1 <- lmer(outcome ~ med + time + medtime + (time | subjid) + (1 | clinid))
And you may end up finding that the random slope for time is not necessary, in which case:
lmeobj1 <- lmer(outcome ~ med + time + medtime + (1 | subjid) + (1 | clinid))
Cheers,
Malcolm
> Message: 1
> Date: Fri, 02 Dec 2011 11:34:54 -0500
> From: "Charles Li" <chl2016 at med.cornell.edu>
> To: r-sig-mixed-models at r-project.org
> Subject: [R-sig-ME] nested random effects with lmer
> Message-ID: <005801ccb110$5257a350$f706e9f0$@med.cornell.edu>
> Content-Type: text/plain
>
> Hi,
>
>
>
> I have a multilevel situation where subjects are nested within clinics, and
> each subject has multiple measurements.
>
> For simplicity, suppose there 4 clinics, 3 subjects per clinic, and each
> subject has 3 repeated measures.
>
> Outcome is continuous. I am trying to implement this model with lmer
> function in lme4 library.
>
>
>
> lmeobj1<-lmer(outcome~med+time+medtime+(time|subjid)+(subjid|clinid))
>
>
>
> My data set is as follows: med has two levels, time has three levels,
> medtime is the interaction between med and time, subjid is the id numbers
> for subjects, clinid is the id numbers for clinics. I pasted the data below.
>
>
>
> The above code is giving the same results with fixed effects regression. In
> addition, whatever I put as random effects is not making a difference at
> all. What am I doing wrong?
More information about the R-sig-mixed-models
mailing list