[R-sig-eco] Can I weight LS means estimates by elevation in lme4/lmerTest packages?

Matthew Van Scoyoc scoyoc at gmail.com
Sat Nov 29 02:35:57 CET 2014


Good afternoon r-sig-ecology,

I'm running linear mixed models using the lme4 and lmerTest packages to
examine ecosystem structure in grasslands and shrublands. The grasslands
are located at lower elevations than the shrublands, and I would like to
weight the estimates from LS means to reflect the differences in
elevations. My colleague says there is an easy way to do it in SAS, but I
haven't found a way to do it in R.

There is an example dataset and workflow. Here I would be examining grass
cover differences between the two ecosystems, the quality of the
ecosystems, and examining the interaction between ecosystem and quality. I
am also interested in systematic changes throughout the study area (not
represented in this example) so I don't want to run separate analyses on
for each ecosystem. I just want to adjust the LS means estimates to reflect
the differences in elevation and not a mean elevation of the sampled plots.

>library("lme4")
>library("lmerTest")
>
> df = data.frame(PlotID = rep(c(paste0("G", 1:30), paste0("S", 1:30)), 2),
+                 SamplePeriod = as.factor(c(rep(2012, 30), rep(2014,
30))),
+                 Ecosystem = rep(c(rep("Grassland", 30), rep("Shrubland",
30)), 2),
+                 Quality = rep(rep(c(rep("Good", 10), rep("Moderate", 10),
rep("Poor", 10)), 2), 2),
+                 GrassCover = c(runif(10, min = 0.50, max = 0.85), # 2012
Grassland Good
+                                runif(10, min = 0.50, max = 0.60), # 2012
Grassland Moderate
+                                runif(10, min = 0.30, max = 0.40), # 2012
Grassland Poor
+                                runif(10, min = 0.25, max = 0.60), # 2012
Shrubland Good
+                                runif(10, min = 0.20, max = 0.45), # 2012
Shrubland Moderate
+                                runif(10, min = 0.05, max = 0.25), # 2012
Shrubland Poor
+                                runif(10, min = 0.50, max = 0.90), # 2014
Grassland Good
+                                runif(10, min = 0.50, max = 0.55), # 2014
Grassland Moderate
+                                runif(10, min = 0.30, max = 0.30), # 2014
Grassland Poor
+                                runif(10, min = 0.25, max = 0.60), # 2014
Shrubland Good
+                                runif(10, min = 0.20, max = 0.30), # 2014
Shrubland Moderate
+                                runif(10, min = 0.05, max = 0.15))) # 2014
Shrubland Poor
> Elevation = c(sample(1200:1700, size = 30, replace = T),
sample(1800:3000, size = 30,
>                    replace = T))
> df$Elevation = c(Elevation, Elevation); rm(Elevation)
>
> lmm = lmer(GrassCover ~ Ecosystem*Quality + Elevation + (1|PlotID), data
= df, REML = T)
> anova(lmm,  ddf = "Satterthwaite", type = 3, method.grad = "Richardson")
Analysis of Variance Table of type 3  with  Satterthwaite
approximation for degrees of freedom
                         Sum Sq      Mean Sq      NumDF      DenDF
 F.value    Pr(>F)
Ecosystem           1.68172     1.68172     1              113
 51.239    8.79e-11 ***
Quality               1.97119     0.98560     2               113
152.611   < 2.2e-16 ***
Elevation             0.00311     0.00311     1              113
 0.016      0.89978
Ecosystem:Quality 0.04201    0.02101     2              113          3.604
     0.03039 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> lsms = lsmeans(lmm, method.grad = "Richardson")
>estimates = lsms[[1]]$Estimate

At this point I would be plotting the estimates of the significant response
variables and interactions to look at the differences. As I understand, the
ecosystem effect and the interaction between ecosystem and quality are with
an average elevation for all plots, and this could exaggerate LS means
estimate.  Correcting for elevation would provide more accurate
estimations. Right?

Okay, thanks for you help.
Cheers,
MVS
=====
Matthew Van Scoyoc

<https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=mvanscoyoc@aggiemail.usu.edu>
https://sites.google.com/site/scoyoc/
=====
Think SNOW!

	[[alternative HTML version deleted]]



More information about the R-sig-ecology mailing list