Skip to content
Prev 7332 / 20628 Next

Comparing results from glmer and glht

Hi Colin,

This is what I would do. The example is on a simple lm() but is similar to a mixed model.
I find it easier to define contrasts on models without the intercept.

set.seed(12345)
dataset <- expand.grid(wsh = c("C", "D", "F", "G"), rip = c("Forest", "Non-forest"), id = seq_len(10))
dataset$wshrip <- with(dataset, wsh:rip)
dataset$Y <- runif(4, min = -10, max = 10)[dataset$wsh] + runif(2, min = -2, max = 2)[dataset$rip] + runif(8, min = -1, max = 1)[dataset$wshrip] + rnorm(nrow(dataset))
model <- lm(Y ~ 0 + wshrip, data = dataset)
library(multcomp)
K <- rbind(
  c(1, 1, -1, -1, 0, 0, 0, 0),
  c(0, 0, 1, 1, 0, 0, -1, -1), 
  c(1, -1, 1, -1, 1, -1, 1, -1))
rownames(K) <- c("C - D = 0", "D - G = 0", "Forest - non-forest = 0")
summary(glht(model, K))

Best regards,

Thierry

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
Thierry.Onkelinx at inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: Colin Wahl [mailto:biowahl at gmail.com] 
Verzonden: maandag 16 januari 2012 21:55
Aan: ONKELINX, Thierry; r-sig-mixed-models at r-project.org
Onderwerp: Re: [R-sig-ME] Comparing results from glmer and glht

Thierry,
Thank you for the suggestion. I think I understand, though creating user defined contrasts will be difficult.

I create a combined variable:
wshrip <-c bind(wsh, rip)

Resulting in a new model
modelEPT<-glmer(EPT ~ wshrip + (1|stream) + (1|stream:rip) + (1|obs), data=ept, family=binomial(link="logit"))

The user defined contrasts I tried previously were:
wsh <- rbind("C vs. D" = c(1,0,0,0,0,0,0,0),
            "C vs. F" = c(0,1,0,0,0,0,0,0),
            "C vs. G" = c(0,0,1,0,0,0,0,0),
            "D vs. F" = c(-1,1,0,0,0,0,0,0),
            "D vs. G" = c(-1,0,1,0,0,0,0,1),
            "F vs. G" = c(0,-1,1,0,0,0,0,0))

This did not give me reasonable results, prompting me to use built-in
contrasts:

summary(glht(modelEPT, linfct=mcp(wsh="Tukey")))

For riparian contrasts I used:
rip <- rbind("C: Forested vs. Non-Forested" = c(0,0,0,0,1,0,0,0),
            "D: Forested vs. Non-Forested" = c(0,0,0,0,1,1,0,0),
            "F: Forested vs. Non-Forested" = c(0,0,0,0,1,0,1,0),
            "G: Forested vs. Non-Forested" = c(0,0,0,0,1,0,0,1))

I dont understand how these contrasts are defined, but based them on contrasts on an almost identical design found here:
http://thebiobucket.blogspot.com/2011/06/glmm-with-custom-multiple-comparisons.html#more

Could you please explain how to use user-defined for the model with a wshrip combined variable? I cant find a clear example of how to do this. The parameter length is different from the original model now that there is a combined variable, correct?

Thank you very much, I'd be lost in the dark without this mailing list.

Colin
On Mon, Jan 16, 2012 at 12:58 AM, ONKELINX, Thierry <Thierry.ONKELINX at inbo.be> wrote: