0
$\begingroup$

Why would I be getting drastically different results from glmer and glmmadmbM for the same model when using emmeans? The results from summary() are the same.

EMmeans glmer:

##  Condition Dimension       rate         SE  df  asymp.LCL asymp.UCL
##  Cond1     Dim1      0.62962963 0.15270775 Inf 0.39141573 1.0128195
##  Cond2     Dim1      1.00000000 0.20851452 Inf 0.66452621 1.5048315
##  Cond1     Dim2      0.44444444 0.12830046 Inf 0.25240386 0.7825984
##  Cond2     Dim2      0.52173913 0.15061335 Inf 0.29630044 0.9187017
##  Cond1     Dim3      0.11111111 0.06415030 Inf 0.03583554 0.3445094
##  Cond2     Dim3      0.08695652 0.06148800 Inf 0.02174740 0.3476938
##  Cond1     Dim4      0.62962963 0.15270793 Inf 0.39141552 1.0128200
##  Cond2     Dim4      0.34782609 0.12297546 Inf 0.17394664 0.6955178
##  Cond1     Dim5      0.22222222 0.09072157 Inf 0.09983595 0.4946386
##  Cond2     Dim5      0.52173913 0.15061320 Inf 0.29630061 0.9187012
##  Cond1     Dim6      0.55555556 0.14344385 Inf 0.33492546 0.9215244
##  Cond2     Dim6      0.60869565 0.16268074 Inf 0.36050146 1.0277639
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale

glmmadmb:

##  Condition Dimension      rate         SE  df   asymp.LCL asymp.UCL
##  Cond1     Dim1      0.3663249 0.05349442 Inf 0.275147407 0.4877164
##  Cond2     Dim1      0.4136632 0.10788837 Inf 0.248109407 0.6896847
##  Cond1     Dim2      0.6296298 0.17603138 Inf 0.364004784 1.0890893
##  Cond2     Dim2      0.9999996 0.45302846 Inf 0.411510701 2.4300684
##  Cond1     Dim3      0.4444386 0.14348993 Inf 0.236045490 0.8368118
##  Cond2     Dim3      0.5217467 0.28670585 Inf 0.177711150 1.5318097
##  Cond1     Dim4      0.1111087 0.06538836 Inf 0.035059774 0.3521170
##  Cond2     Dim4      0.0869379 0.09964245 Inf 0.009196412 0.8218638
##  Cond1     Dim5      0.6296300 0.16326922 Inf 0.378756834 1.0466712
##  Cond2     Dim5      0.3478197 0.19225164 Inf 0.117724364 1.0276421
##  Cond1     Dim6      0.2222084 0.08653129 Inf 0.103583342 0.4766846
##  Cond2     Dim6      0.5217479 0.25848473 Inf 0.197586717 1.3777284
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log scale

Summary coefs--

glmer:

## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: poisson  ( log )
## Formula: Value ~ Condition * Dimension + (1 | ID)
##    Data: dat
## 
##      AIC      BIC   logLik deviance df.resid 
##    532.2    580.3   -253.1    506.2      287 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.0000 -0.7223 -0.3333  0.5016  6.4874 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  ID     (Intercept) 0        0       
## Number of obs: 300, groups:  ID, 50
## 
## Fixed effects:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                -1.0042     0.1460  -6.877 6.12e-12 ***
## ConditionCond2              0.1215     0.2157   0.564   0.5730    
## Dimension1                  0.5416     0.2460   2.201   0.0277 *  
## Dimension2                  0.1933     0.2773   0.697   0.4858    
## Dimension3                 -1.1930     0.4935  -2.417   0.0156 *  
## Dimension4                  0.5416     0.2460   2.201   0.0277 *  
## Dimension5                 -0.4999     0.3639  -1.374   0.1696    
## ConditionCond2:Dimension1   0.3411     0.3387   1.007   0.3139    
## ConditionCond2:Dimension2   0.0388     0.3970   0.098   0.9221    
## ConditionCond2:Dimension3  -0.3667     0.7759  -0.473   0.6365    
## ConditionCond2:Dimension4  -0.7150     0.4112  -1.739   0.0821 .  
## ConditionCond2:Dimension5   0.7319     0.4617   1.585   0.1129    

glmmadmb:

## glmmadmb(formula = Value ~ Condition * Dimension + (1 | ID), 
##     data = dat, family = "poisson")
## 
## AIC: 532.2 
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                -1.0042     0.1460   -6.88  6.1e-12 ***
## ConditionCond2              0.1215     0.2157    0.56    0.573    
## Dimension1                  0.5416     0.2460    2.20    0.028 *  
## Dimension2                  0.1933     0.2773    0.70    0.486    
## Dimension3                 -1.1930     0.4935   -2.42    0.016 *  
## Dimension4                  0.5416     0.2460    2.20    0.028 *  
## Dimension5                 -0.4999     0.3639   -1.37    0.170    
## ConditionCond2:Dimension1   0.3411     0.3387    1.01    0.314    
## ConditionCond2:Dimension2   0.0388     0.3970    0.10    0.922    
## ConditionCond2:Dimension3  -0.3668     0.7760   -0.47    0.636    
## ConditionCond2:Dimension4  -0.7150     0.4112   -1.74    0.082 .  
## ConditionCond2:Dimension5   0.7320     0.4617    1.59    0.113    

Reproducible example:

dat = structure(list(ID = structure(c(6L, 46L, 37L, 16L, 10L, 7L, 47L, 
12L, 40L, 2L, 28L, 39L, 32L, 43L, 8L, 31L, 25L, 22L, 34L, 5L, 
36L, 17L, 48L, 30L, 33L, 1L, 24L, 26L, 35L, 29L, 38L, 44L, 13L, 
20L, 45L, 15L, 42L, 19L, 11L, 14L, 9L, 49L, 4L, 41L, 18L, 21L, 
23L, 3L, 50L, 27L, 6L, 46L, 37L, 16L, 10L, 7L, 47L, 12L, 40L, 
2L, 28L, 39L, 32L, 43L, 8L, 31L, 25L, 22L, 34L, 5L, 36L, 17L, 
48L, 30L, 33L, 1L, 24L, 26L, 35L, 29L, 38L, 44L, 13L, 20L, 45L, 
15L, 42L, 19L, 11L, 14L, 9L, 49L, 4L, 41L, 18L, 21L, 23L, 3L, 
50L, 27L, 6L, 46L, 37L, 16L, 10L, 7L, 47L, 12L, 40L, 2L, 28L, 
39L, 32L, 43L, 8L, 31L, 25L, 22L, 34L, 5L, 36L, 17L, 48L, 30L, 
33L, 1L, 24L, 26L, 35L, 29L, 38L, 44L, 13L, 20L, 45L, 15L, 42L, 
19L, 11L, 14L, 9L, 49L, 4L, 41L, 18L, 21L, 23L, 3L, 50L, 27L, 
6L, 46L, 37L, 16L, 10L, 7L, 47L, 12L, 40L, 2L, 28L, 39L, 32L, 
43L, 8L, 31L, 25L, 22L, 34L, 5L, 36L, 17L, 48L, 30L, 33L, 1L, 
24L, 26L, 35L, 29L, 38L, 44L, 13L, 20L, 45L, 15L, 42L, 19L, 11L, 
14L, 9L, 49L, 4L, 41L, 18L, 21L, 23L, 3L, 50L, 27L, 6L, 46L, 
37L, 16L, 10L, 7L, 47L, 12L, 40L, 2L, 28L, 39L, 32L, 43L, 8L, 
31L, 25L, 22L, 34L, 5L, 36L, 17L, 48L, 30L, 33L, 1L, 24L, 26L, 
35L, 29L, 38L, 44L, 13L, 20L, 45L, 15L, 42L, 19L, 11L, 14L, 9L, 
49L, 4L, 41L, 18L, 21L, 23L, 3L, 50L, 27L, 6L, 46L, 37L, 16L, 
10L, 7L, 47L, 12L, 40L, 2L, 28L, 39L, 32L, 43L, 8L, 31L, 25L, 
22L, 34L, 5L, 36L, 17L, 48L, 30L, 33L, 1L, 24L, 26L, 35L, 29L, 
38L, 44L, 13L, 20L, 45L, 15L, 42L, 19L, 11L, 14L, 9L, 49L, 4L, 
41L, 18L, 21L, 23L, 3L, 50L, 27L), .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", 
"27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", 
"38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", 
"49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", 
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", 
"71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", 
"82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", 
"93", "94", "95", "96", "97", "98", "99", "100", "101", "102", 
"103", "104", "105", "106", "107", "108", "109", "110", "111", 
"112", "113", "114", "115", "116", "117", "118", "119", "120", 
"121", "122", "123", "124", "125", "126", "127", "128", "129", 
"130", "131", "132", "133", "134", "135", "136", "137", "138", 
"139", "140", "141", "142", "143", "144", "145", "146", "147", 
"148", "149", "150", "151", "152", "153", "154", "155", "156", 
"157", "158", "159", "160", "161", "162", "163", "164", "165", 
"166", "167", "168", "169", "170", "171", "172", "173", "174", 
"175", "176", "177", "178", "179", "180", "181", "182", "183", 
"184", "185", "186", "187", "188", "189", "190", "191", "192", 
"193", "194", "195", "196", "197", "198", "199", "200", "201", 
"202", "203", "204", "205", "206", "207", "208", "209", "210", 
"211", "212", "213", "214", "215", "216", "217", "218", "219", 
"220", "221", "222", "223", "224", "225", "226", "227", "228", 
"229", "230", "231", "232", "233", "234", "235", "236", "237", 
"238", "239", "240", "241", "242", "243", "244", "245", "246", 
"247", "248", "249", "250"), class = "factor"), Condition = structure(c(1L, 
1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 
2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 
2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 
2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 
2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 
1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 
1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 
2L, 1L, 1L, 1L, 2L, 1L, 2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 0, 0, 1, 1, 0, 
    0, 1, 3, 0, 0, 0, 1, 0, 1, 2, 0, 0, 2, 0, 0, 1, 1, 1, 0, 
    1, 4, 2, 3, 0, 0, 1, 1, 1, 2, 1, 1, 0, 1, 3, 1, 1, 0, 0, 
    1, 0, 2, 0, 0, 1, 0, 2, 0, 1, 0, 1, 1, 0, 0, 2, 1, 1, 0, 
    0, 1, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 
    0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 
    0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 
    0, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 0, 1, 1, 0, 1, 0, 2, 0, 
    1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 
    1, 0, 1, 1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 
    0, 0, 1, 1, 0, 0, 0, 1, 2, 0, 1, 1, 2, 4, 2, 0, 0, 1, 1, 
    1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
    1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 1, 1, 0, 2, 0, 0)), class = "data.frame", row.names = c(NA, 
-300L))

contrasts(dat$Dimension) <- contr.sum 
dat$ID = as.factor(dat$ID)
tail(contrasts(dat$ID))

glmerM = glmer(Value ~ Condition*Dimension + (1|ID), family=poisson, dat)
summary(glmerM)
emmeans(glmerM, ~Condition*Dimension, type="response")

glmmadmbM = glmmadmb(Value ~ Condition*Dimension + (1|ID),family="poisson", dat)
summary(glmmadmbM)
emmeans(glmmadmbM, ~Condition*Dimension, type="response")
$\endgroup$
7
  • $\begingroup$ How do the results differ? Do the annotations on the results confirm that in both cases, the results are back-transformed? $\endgroup$
    – Russ Lenth
    Jul 10, 2018 at 13:53
  • $\begingroup$ @rvl the estimated marginal means (in the first two outputs I pasted) are different. For example, dimension 1 condition 1 is .63 for the glmer model and .37 for glmmadmb. Looking at the output a little longer I realized some (but not all) of the values moved around to different rows between the two models for some reason (e.g., cond1-dim1 rate in glmer becomes cond1-dim2 in glmmadmb). And they are both back-transformed (indicated in output), but I get the same issue with the log scale emmeans. $\endgroup$
    – user137451
    Jul 10, 2018 at 18:33
  • $\begingroup$ @rvl I seem to have identified the issue, which I think may be a bug in emmeans when using glmmadmb with contrast coding (in my code: contrasts(dat$Dimension) <- contr.sum ). If I run the code with the automatic dummy coding then both results agree. I checked and the emmeans for the glmer model are the correct ones when using contrast coding. Not sure why emmeans is interpreting glmmadmb's coding incorrectly. $\endgroup$
    – user137451
    Jul 10, 2018 at 23:53
  • $\begingroup$ Ok, well that helps. It’s sometimes hard to figure out where the contrasts actually used are saved (if indeed they were) in the model object. I’ll look at it. $\endgroup$
    – Russ Lenth
    Jul 11, 2018 at 0:04
  • $\begingroup$ OK, Now that I'm home from vacation, I looked at the code, and see that the support code looks for object$contrasts, which doesn't exist (so is set to NULL and the current getOption("contrasts") is used). I have a vague memory that I put that in as a placeholder and hoped I could find a way to find the contrasts somewhere. In a glmerMod object they are in attr(object@pp$X, "contrasts"), but there is no such animal in glmmadmb objects. I'll poke around and see if I can find it somewhere. $\endgroup$
    – Russ Lenth
    Jul 13, 2018 at 16:43

1 Answer 1

2
$\begingroup$

The contrasts attribute is not correctly retrieved in emmeans's current support for glmmamdb objects. To make it work in this example, do:

glmmamdbM$contrasts <- list(
    Condition = "contr.treatment", Dimension = "contr.sum")

... before calling emmeans() or ref_grid().

I have figured out how to retrieve this contrast info, at least when it is assigned to individual variables using contrasts<-, as in this example. That support will be included with the next update of emmeans (version > 1.2.2).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.