[R-sig-ME] post hoc tests for glmmTMB
Lenth, Russell V
ru@@ell-lenth @ending from uiow@@edu
Fri Nov 9 21:46:02 CET 2018
With emmeans/lsmeans, it turns out the mistake was in sourcing that obsolete lsmeans-methods.R code. Please erase all functions in your workspace that begin with "recover.data" or "lsm.basis" -- then you can obtain EMMs without problems, because emmeans support is built-in to the cirrent glmmTMB package. For example:
require(glmmTMB)
require(emmeans)
example("glmmTMB")
# ... quite a few lines excluded here
emmeans(m2, "spp")
# spp emmean SE df lower.CL upper.CL
# GP 0.10429796 0.2629172 626 -0.4120086 0.6206045
# PR -0.85940395 0.6723753 626 -2.1797882 0.4609803
# DM 0.27498137 0.2456147 626 -0.2073472 0.7573099
# EC-A -0.28275838 0.3610020 626 -0.9916800 0.4261633
# EC-L 0.59224612 0.2581265 626 0.0853474 1.0991448
# DES-L 0.69378481 0.2410053 626 0.2205080 1.1670616
# DF -0.00896838 0.2496003 626 -0.4991237 0.4811869
Russ
-----Original Message-----
From: Lenth, Russell V
Sent: Friday, November 9, 2018 10:22 AM
To: r-sig-mixed-models using r-project.org; 'Aoibheann Gaughran' <gaughra using tcd.ie>
Subject: RE: R-sig-mixed-models Digest, Vol 143, Issue 12
I screwed up -- in a kind of brown-paper-bag way...
I think it may work with emmeans if you do this:
recover.data <- function(object, ...) UseMethod("recover.data")
lsm.basis <- function(object, ...) UseMethod("lsm.basis")
recover.data.default <- function(object, ...) emmeans::recover_data(object, ...)
lsm.basis.default <- function(object, ...) emmeans::emm_basis(object, ...)
Hope this helps.
Russ Lenth
Russell V. Lenth - Professor Emeritus
Department of Statistics and Actuarial Science The University of Iowa - Iowa City, IA 52242 USA Voice (319)335-0712 (Dept. office) - FAX (319)335-3017
-----Original Message-----
Message: 1
Date: Fri, 9 Nov 2018 12:24:47 +0000
From: Aoibheann Gaughran <gaughra using tcd.ie>
To: r-sig-mixed-models using r-project.org
Subject: [R-sig-ME] post hoc tests for glmmTMB
Message-ID:
<CAN=0SEmQE6f=OAofUeSg_e2f-O2tnfUepqUSRO28onLw_dgh1w using mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Dear list,
I am trying to perform post hoc tests on a glmmTMB model. I would normally use car::Anova and mulgcomp::glht on my glmms (lmers). However, these functions do not appear to be working for glmmTMB (when I run the model as an lmer they work fine). I have also tried lsmeans and emmeans but they do not appear to support glmmTMB either (although it appears they used to). I have found various treads online suggesting that these functions should work with TMB but they date back a few months.
I am using the most up to date versions of R (3.5.1) and have updated all of my packages e.g. glmmTMB 0.2.2.0, lsmeans 2.30-0
The following are the error messages that I receive:
> Anova(topmodTRFETE, type = 2)Error in I.p[c(subs.relatives, subs.term), , drop = FALSE] :
subscript out of bound
> summary(glht(topmodTRFETE, linfct = mcp(roadworks = "Tukey")), test = adjusted("holm"))Error in modelparm.default(model, ...) :
dimensions of coefficients and covariance matrix don't match
> source(system.file("other_methods","lsmeans_methods.R",package="glmmTMB"))> lsmeans(topmodTRFETE, pairwise ~ roadworks, adjustSigma = TRUE, adjust = "holm")Error in ref_grid(object, ...) :
Can't handle an object of class “glmmTMB”
Use help("models", package = "emmeans") for information on supported models.> rw.emm.s <- emmeans(topmodTRFETE, "roadworks")Error in ref_grid(object, ...) :
Can't handle an object of class “glmmTMB”
Use help("models", package = "emmeans") for information on supported models.
Can any point me in the direction of a workaround for performing posthocs on my glmmTMB model?
Many thanks,
--
Aoibheann Gaughran
Behavioural and Evolutionary Ecology Research Group Zoology Building School of Natural Sciences Trinity College Dublin Dublin 2 Ireland
Phone: +353 (86) 3812615
More information about the R-sig-mixed-models
mailing list