Skip to content

lmer random and fixed effect?

4 messages · Charles Determan Jr, Farrar, David, Ben Bolker

#
Greetings,

I have been looking more into mixed models recently and have run into a
situation that confuses me.  I was initially under the impression that
fixed and random effect variables are separate, however can they be both in
an lmer model and if so why would you do so?

Such as example is with the following dataset:
lmm.data <- read.table("
http://www.unt.edu/rss/class/Jon/R_SC/Module9/lmm.data.txt",
                       header=TRUE, sep=",", na.strings="NA", dec=".",
strip.white=TRUE)

Reading online, I have found the following model:
require(lme4)
fit <- lmer(formula = extro~open+agree+social+class+(1|school/class), data
= lmm.data)

Everything runs fine but I am confused as to what this actually means or if
it is even appropriate.

Thank you for any insight,
Regards,
#
A split-plot design is an example where both are used.  You may find helpful the discussion of that design "the R book."

-----Original Message-----
From: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-models-bounces at r-project.org] On Behalf Of Charles Determan Jr
Sent: Thursday, August 14, 2014 2:09 PM
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] lmer random and fixed effect?

Greetings,

I have been looking more into mixed models recently and have run into a situation that confuses me.  I was initially under the impression that fixed and random effect variables are separate, however can they be both in an lmer model and if so why would you do so?

Such as example is with the following dataset:
lmm.data <- read.table("
http://www.unt.edu/rss/class/Jon/R_SC/Module9/lmm.data.txt",
                       header=TRUE, sep=",", na.strings="NA", dec=".",
strip.white=TRUE)

Reading online, I have found the following model:
require(lme4)
fit <- lmer(formula = extro~open+agree+social+class+(1|school/class), data = lmm.data)

Everything runs fine but I am confused as to what this actually means or if it is even appropriate.

Thank you for any insight,
Regards,

--
Dr. Charles Determan, PhD
Integrated Biosciences


_______________________________________________
R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
#
In this example:

lmer(formula = extro~open+agree+social+class+(1|school/class),
     data = lmm.data)

  'class' is included as a fixed effect, and the random effects grouping
variable is specified as school/class, which means "class nested within
school", i.e. the same as school+school:class (where : denotes
interaction).  Note that class itself is *not* included as a
random-effects grouping variable.   This model specification would make
sense if (1) levels of the class variable are defined across schools
(i.e. class #1 in school #1 has something in common with class #1 in
school #2); (2) it makes sense to treat class as a fixed effect, i.e. we
have a fairly small number of classes and/or we want to make inferences
about the values of particular classes contrasts among specific classes
(and not just the variation among classes)
On 14-08-14 02:25 PM, Farrar, David wrote:
#
In agreement, I think, I hazard a guess that the research questions relate to levels of open, agree, and social which have been measured at the class or school level.   Could a correct specification be ~ open + agree + social + (1 | school/class) ? 
The school part could get a little tricky as follows.   It could be asked "did you see any difference between east schools and west schools?" etc.  The possibilities seem to be to evaluate the school blups or add in and test an east-west fixed factor.  Seems either way you could easily get into a multiple-testing problem by commenting extensively.  If you submit speculations based on blups for publication, you might be asked why they are not formally tested.  How do editors respond to interpretations based on blups?  


-----Original Message-----
From: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-models-bounces at r-project.org] On Behalf Of Ben Bolker
Sent: Thursday, August 14, 2014 4:59 PM
To: r-sig-mixed-models at r-project.org
Subject: Re: [R-sig-ME] lmer random and fixed effect?

  In this example:

lmer(formula = extro~open+agree+social+class+(1|school/class),
     data = lmm.data)

  'class' is included as a fixed effect, and the random effects grouping variable is specified as school/class, which means "class nested within school", i.e. the same as school+school:class (where : denotes interaction).  Note that class itself is *not* included as a
random-effects grouping variable.   This model specification would make
sense if (1) levels of the class variable are defined across schools (i.e. class #1 in school #1 has something in common with class #1 in school #2); (2) it makes sense to treat class as a fixed effect, i.e. we have a fairly small number of classes and/or we want to make inferences about the values of particular classes contrasts among specific classes (and not just the variation among classes)
On 14-08-14 02:25 PM, Farrar, David wrote:
_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models