Hi, Mr. Dolman.
Thank you VERY MUCH for your response.  The variable, Time is discrete in
the example.   Your codes below, esp. interaction term, are they still valid
if Time is a discrete variable?  Again many thanks.
Saang-Yoon
On Sun, Mar 27, 2011 at 7:20 AM, Andrew Dolman <andydolman@gmail.com> wrote:

> If time is being modelled as a continuous variable, i.e. you are
> looking at a continuous change in x over time, then
>
> mod2=lmer(x~time+(1|site),  data=mydata)
> mod3=lmer(x~time+(time|site),  data=mydata)
>
> is probably what you want.
>
> And you can test whether time interacts with site (the slope for time
> differs between sites) by a likelihood ratio test
>
> anova(mod2, mod3)
>
>
>
> andydolman@gmail.com
>
>
>
> On 27 March 2011 07:10, Saang-Yoon Hyun <shyunuw@gmail.com> wrote:
> > Hi.
> > I have one fixed and one random effect.  However, I cannot find how to
> code
> > their interaction term.  For example, the data have the following two
> > columns: site as random effect, and time as fixed effect.
> >
> > mod1=lmer(x~(1|site),  data=mydata);       #site: random effect;
> > mod2=lmer(x~time+(1|site),  data=mydata);    #time: fixed effect;
> >
> > These above codes work.  But I wonder how you do code for their
> interaction
> > term.  I tried to do several things (e.g., +time*(1|site),
> +(1|time*site),
> > ... etc.), but all failed.
> >
> > Please give me some tips.  Thank you,
> > Saang-Yoon
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
>

	[[alternative HTML version deleted]]


