[R] Contrast interaction effects in lmer object for reciprocal transplant experiment

Steven Brady steven.brady at yale.edu
Mon Jun 21 20:47:08 CEST 2010


Dear All:

My apologies, but my formatting of the original message was poor.   
Here it is again with more appropriate spacing for copying into the  
terminal.



I am using lmer() {lme4} to analyze results from a reciprocal  
transplant experiment where the response variable is modeled as a  
function of two fixed effects and their interaction.

Example data follow:

#library(lme4)
#library(gmodels)

env=c("r","r","w","w","r","r","w","w","r","r",
"w","w","r","r","w","w")
#type of environment to where populations
#were transplanted (fixed effect)

origin=c("r","r","r","r","r","r","r",
"r","w","w","w","w","w","w","w","w")
#type of environment from where populations
#originated (fixed effect)

survival=c(rnorm(16,0.75, sd = 0.1))
#percent survival (response variable)

population=c("a","a","a","a","b","b","b","b",
"c","c","c","c","d","d","d","d")
#local population (random effect)

exp=data.frame(pond=pond, env=env,
origin=origin,survival=survival)
#make data frame

g<-lmer(survival~origin*env + (1|population),
data = exp)
# mixed model

pvals.fnc(g)
#evaluate fixed effects


My question is this:

How do I perform contrasts on the interaction of the fixed effects  
using, say estimable() in the library {gmodels}?  I have seen how to  
do this for levels within a factor, however, I am unsure how to apply  
these to levels among factors (i.e. the interaction terms).

Biologically speaking, I am interested in evaluating the difference in  
survival between the two origin types in each of two types of  
environments.  In other words:

1. does origin r differ from origin w within env w?  and,
2. does origin r differ from origin w within env r?

Part of my misunderstanding concerns the reporting of the fixed  
effects of the model, which are named as the fixed term concatenated  
with a level (e.g. originw).  Does the way lmer names the fixed  
effects influence the contrast matrix I should specify?

Many thanks in advance,

Steve Brady

__________________________________________
Steven P. Brady, Ph.D. Candidate
School of Forestry & Environmental Studies
Yale University
370 Prospect Street
New Haven, CT 06511

Email: steven.brady at yale.edu
Phone: 203-432-5321 Fax: 203-432-3929
Web: http://www.cbc.yale.edu/people/skelly/steveb.html



More information about the R-help mailing list