bootstrap_parameters and model_parameters provide problematic pd values when specifying type="response" in emmeans function
InkaMarei opened this issue · 1 comments
InkaMarei commented
Hello,
I just wanted to highlight that when speciying type="response" in emmeans when using a generalized linear (mixed) model, the pd values reported by model_parameters() are all 100. When not specifying type="response" the results seem to be correct though.
Here is the example code:
library(glmmTMB)
library(emmeans)
library(parameters)
m2 <- glmmTMB(count ~ spp + mined + (1|site), family=nbinom2, data=Salamanders)
blub <- bootstrap_parameters(m2, test = "pd")
EMM <- emmeans(blub, ~spp, type="response")
model_parameters(contrast(EMM))
EMM <- emmeans(blub, ~spp)
model_parameters(contrast(EMM))
mattansb commented
This is because by default pd
is testing for a direction with regard to 0. You can pass a null=1
argument when the estimate is a ratio (or a ratio factor):
library(glmmTMB)
library(emmeans)
library(parameters)
m2 <- glmmTMB(count ~ spp + mined + (1|site), family=nbinom2, data=Salamanders)
blub <- bootstrap_parameters(m2, test = "pd", iterations = 20)
EMM <- emmeans(blub, ~spp, type="response")
model_parameters(contrast(EMM), null = 1)
#> Parameter | Median | 95% CI | pd
#> -----------------------------------------------
#> GP effect | 1.03 | [0.79, 1.33] | 55.00%
#> PR effect | 0.27 | [0.22, 0.40] | 100%
#> DM effect | 1.42 | [1.01, 1.80] | 95.00%
#> (EC-A) effect | 0.46 | [0.37, 0.65] | 100%
#> (EC-L) effect | 1.78 | [1.52, 2.11] | 100%
#> (DES-L) effect | 2.24 | [1.81, 2.84] | 100%
#> DF effect | 1.41 | [1.12, 1.56] | 100%
EMM <- emmeans(blub, ~spp)
model_parameters(contrast(EMM), null = 0)
#> Parameter | Median | 95% CI | pd
#> -------------------------------------------------
#> GP effect | 0.03 | [-0.23, 0.29] | 55.00%
#> PR effect | -1.32 | [-1.53, -0.91] | 100%
#> DM effect | 0.35 | [ 0.01, 0.59] | 95.00%
#> (EC-A) effect | -0.77 | [-1.00, -0.44] | 100%
#> (EC-L) effect | 0.57 | [ 0.42, 0.75] | 100%
#> (DES-L) effect | 0.81 | [ 0.59, 1.04] | 100%
#> DF effect | 0.35 | [ 0.11, 0.44] | 100%