[R] Mixed model Nested ANOVA

Rune Haubo rune.haubo at gmail.com
Sat Feb 23 00:44:30 CET 2008


Hi Stephen

On 22/02/2008, Stephen Cole <swbcole at gmail.com> wrote:
> hello R help
>
>  I am trying to analyze a data set that has been collected from a
>  hierarchical sampling design.  The model should be a mixed model nested
>  ANOVA.  The purpose of my study is to analyze the variability at each
>  spatial scale in my design (random factors, variance components), and say
>  something about the variability between regions (fixed factor, contrast of
>  means).  The data is as follows;
>
>  region (fixed)
>  Location (random)
>  Site(random)
>
>  site nested in location nested in region.
>
>  I would like to run this as an ANOVA and then compute variance components.
>
>  My question is when i use the aov command;   mod1 <- aov(density ~
>  region/location/site)
>  is there any way to tell R which factor is random and fixed.

This depends on whether your design is balanced or not. If, your data
are balanced, you may use Error() in aov() to specify error-strata,
but then you may as well work out the variance parameters from the
sums of squares manually. A more general procedure would be to use
either lme or lmer, from which you can get anova tables of fixed
effects with anova().
>
>  I know i can specify fixed and random factors using lme or lmer but these
>  methods do not allow me to extract an anova table (or do they?)
>  I know that the data can be analyzed using a nested ANOVA because i have
>  based my design on several papers in the marine biological literature
>  (MEPS).  Thank-you for any advice in advance.

If you data are nested lme usually works rather smooth. Here you might
want use something like

anova(mymodel)

to get anova for the fixed effects. The variance components are provided with

summary(mymodel)

Best
Rune
>
>  Stephen Cole
>
>         [[alternative HTML version deleted]]
>
>  ______________________________________________
>  R-help at r-project.org mailing list
>  https://stat.ethz.ch/mailman/listinfo/r-help
>  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>  and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list