[R-sig-ME] How to define the fixed and random effects in lmer
Luca Borger
lborger at uoguelph.ca
Tue Sep 15 19:42:17 CEST 2009
Hello,
that should be fairly easy to do, instead of "random =..." you use brackets to specify the random effects. For example:
1. fixed effects for the intercept and slope and only random effect for the intercept is included
lmer(Pre~t +(1|group), data= prec)
or
2. fixed effects for the intercept and slope, and random effects for the intercept and slope are included
lmer(Pre~t + (t|group), data= prec)
HTH
Cheers,
Luca
----- Messaggio originale -----
Da: "FMH" <kagba2006 at yahoo.com>
A: "Benjamin Michael Bolker" <bolker at ufl.edu>, r-sig-mixed-models at r-project.org
Inviato: Martedì, 15 settembre 2009 13:30:25 GMT -05:00 U.S.A./Canada, stati orientali
Oggetto: Re: [R-sig-ME] How to define the fixed and random effects in lmer
Thank you for your advice, but actually i'm looking for the scripts via lmer function in lme4 package.
Cheers
Fir
----- Original Message ----
From: "Bolker,Benjamin Michael" <bolker at ufl.edu>
To: FMH <kagba2006 at yahoo.com>; "r-sig-mixed-models at r-project.org" <r-sig-mixed-models at r-project.org>
Sent: Tuesday, September 15, 2009 1:48:54 PM
Subject: RE: [R-sig-ME] How to define the fixed and random effects in lmer
I was running lme function on my data as shown below, in which the variables involved are:
########################################
#Pre : Precipitation
#t : time
#group : Group of precipitation
#prec: data set
lme(Pre ~ t| group, data = prec, random = ~ t| group)
#########################################
I'm surprised this works (does it?) -- I didn't think |group was meaningful in a fixed-effects formula
specification
How could i write the scripts with lmer function with :
1. fixed effects for the intercept and slope and only random effect for the intercept is included
lme(Pre~t, random=~1|group, data= prec)
2. fixed effects for the intercept and slope, and random effects for the intercept and slope are included
lme(Pre~t, random=~t|group, data= prec)
3. only fixed effect for the intercept and only random effect for the intercept is included
lme(Pre~1, random=~1|group, data= prec)
4. only fixed effects for the slope, and random effects for the intercept and slope are included
lme(Pre~t-1, random=~1|group, data= prec)
(I think. See if those work as expected)
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list