[R-sig-ME] variance estimates differ glmer vs lme
Thierry Onkelinx
thierry.onkelinx at inbo.be
Thu Feb 16 10:18:28 CET 2017
Dear Vincenzo,
You can't compare those models at all. Write down the equations and you'll
see that they are very different.
In this case you should use the glmer version.
Best regards,
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
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
2017-02-15 17:47 GMT+01:00 Vincenzo Ellis <vincenzoaellis op gmail.com>:
> Dear mixed effects modelers,
>
> I'm interested in doing variance partitioning of parasite prevalence (a
> proportion calculated as the number of infected host individuals divided by
> the total number of host individuals sampled) among different host
> taxonomic levels.
>
> I've run the analysis in lme4 using the glmer function and I've also
> arcsine square-root transformed the response variable (prevalence) and run
> that in the nlme package using the lme function (with weights set to the
> square root of sample size).
>
> These two approaches give different answers. I assumed they would differ a
> bit, but I expected them to be more similar than they are. The glmer
> approach puts 66% of the variance in prevalence at the species within
> genera level, while the lme approach puts 92% of the variance at the
> species within genera level.
>
> *Question:* Am I wrong to think that these two approaches should have given
> more similar results? And is one of these approaches clearly correct or
> incorrect?
>
> Thanks for any insights!
>
> Vincenzo
>
> Reproducible example:
>
> #### Compare hierarchical variance partitioning results between glmer() and
> lme()
>
> ## install packages if necessary
> install.packages(c("gsheet", "lme4", "nlme"))
>
> ## load data
> library(gsheet)
> dat <- gsheet2tbl('
> https://docs.google.com/spreadsheets/d/1EhkrHG19pESBCTQ1mMa8od4lbyF-
> N484RchskCrPUqo/edit?usp=sharing
> ')
>
>
> ## glmer variance partitioning (takes about 30s to run on my computer)
> library(lme4)
> mod.glmm <- glmer(cbind(Infected, Sample_Size-Infected) ~ 1 +
> (1|Family/Genus/Species),
> data = dat, family = binomial)
>
> ## variance estimates
> print(VarCorr(mod.glmm), comp=c("Variance"))
>
> ## proportional variance
> mod.glmm.var <- c(VarCorr(mod.glmm)[[1]][1,1], VarCorr(mod.glmm)[[2]][1,1],
> VarCorr(mod.glmm)[[3]][1,1])
> round(mod.glmm.var/sum(mod.glmm.var), 3)
>
>
> ## lme variance partitioning
> library(nlme)
> prev <- with(dat, Infected/Sample_Size)
> mod.lmm <- lme(asin(sqrt(prev)) ~ 1, random = ~ 1|Family/Genus,
> data = dat, weights = ~ 1/sqrt(Sample_Size))
>
> ## variance estimates
> VarCorr(mod.lmm)
>
> ## proportional variance
> mod.lmm.var <- as.numeric(VarCorr(mod.lmm)[c(5,4,2),1])
> round(mod.lmm.var/sum(mod.lmm.var), 3)
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models op r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list