[R] a question about linear mixed model in R
Chung Chang
cc2240 at columbia.edu
Wed Jan 19 16:31:27 CET 2005
Thanks for your post.
Yes, your example is indeed similar to my question.
If i means group, j means individual(subject)
h:indicator(0:control;1:experiment) k:repeat(if no repeat then k=1)
the the model is also X_hijk = alpha_h + h * b_i + r_(ij) + e_hijk.
After I posted this question, I found out how to do it in R.
So I would like to share with you guys and hear the comments from
you.
X:response,b_i subject effect, r(ij) nested effect within subject
lme(X~alpha_h,data=dataset,random=list(subject=~h-1,r=~1),method="ML
",na.action="na.omit")
the fixed effect part is alpha_h
the random effect is subject effect, the corresponding coefficient
is h and -1 means no random intercept of subject.
and random effect of r(nested effect within subject)
Thanks for your help
ÒýÓÃ Peter Muhlberger <peterm at andrew.cmu.edu>:
> Hi Chung Cheng: This seems related to a problem I'm having in
> some data of
> mine as well. I'm new to R (played w/ it some a year ago) & to
> lme
> modeling, so take this w/ a grain of salt, but here are some
> thoughts:
>
> In my problem, D would be an indicator of whether a subject was
> in the
> control condition or not. In the control condition, all people
> participated
> individually, in the experimental condition there was small-group
> based
> discussion. r(ij) would be some variable that affects the
> outcome, but
> whose effect may be moderated by the group the discussion was in.
>
> The model assumes that the non-control condition values will have
> a
> distribution of coefficients for r(ij). The coefficient for
> r(ij) in the
> controls need not have the same central value as for the
> non-controls
> (though it would be nice to be able constrain it so it would be).
> So, it
> might make some sense to split the variable into two variables,
> one with
> zeros for the controls & one w/ zeros for the experimental groups
> and
> estimate the former w/ random effects & the other not.
>
> I'm not 100% sure that's what you're asking, but it seems
> related.
>
> Peter
>
> >Dear all,
> >
> >I have a somewhat unusual linear mixed model that I can't seem
> >to code in lme. It's only unusual in that one random effect is
> >applied only to some of the observations (I have an indicator
> >variable
> >that specifies which observations have this random effect).
> >
> >The model is:
> >
> >X_hijk = alpha_h + h * b_i + r_(ij) + e_hijk , where
> >
> > h = 0 or 1 (indicator)
> > i = 1, ..., N
> > j = 1, ..., n_i
> > k = 1, ..., K
> >alpha is fixed, and the rest are random.
> >I'm willing to assume b, r, and e are mutually independent
> >and normal with var(b) = sigma^2_b, var(r) = sigma^2_r, and
> >var(e) = sigma^2.
> >
> >Any help in writing this model in lme() would be greatly
> >appreciated.
> >
> >Thanks,
> >
> >Chung Cheng
>
More information about the R-help
mailing list