1

我正在尝试计算glmmTMB(家庭:nbinom1)中模型估计的 95% 置信区间。

我可以使用glmer.nb模型来做到这一点emmeans,并且使用type = "response"来对估计值和置信区间进行反向转换。

model = glmer.nb (response ~ p1 + p2 + (1|block))
emmeans(model, ~ p1 + p2, type = "response")

我认为 is 中的类似函数glmmTMBconfint(model)但它不会对估计值进行反向转换。

任何人都可以帮助我使用glmmTMB模型来完成这项工作glmer吗?

4

2 回答 2

1

emmeans() 也应该适用于glmmTMB模型。对我来说,它有效,并且 CI 也被反向转换(对数尺度):

library(glmmTMB)
data(Salamanders)

m <- glmmTMB(
  count ~ spp + mined + (1 | site),
  ziformula = ~ spp + mined,
  family = truncated_poisson,
  data = Salamanders
)

emmeans::emmeans(m, "spp", type = "response")
#>  spp    rate    SE  df lower.CL upper.CL
#>  GP    1.553 0.223 627    1.171     2.06
#>  PR    0.922 0.251 627    0.540     1.57
#>  DM    1.944 0.250 627    1.511     2.50
#>  EC-A  1.277 0.246 627    0.875     1.86
#>  EC-L  2.965 0.337 627    2.372     3.71
#>  DES-L 2.844 0.321 627    2.280     3.55
#>  DF    1.626 0.222 627    1.244     2.13
#> 
#> Results are averaged over the levels of: mined 
#> Confidence level used: 0.95 
#> Intervals are back-transformed from the log scale

reprex 包(v0.3.0)于 2019 年 8 月 9 日创建

如果您需要零通货膨胀的混合模型的预测值(置信区间) ,则计算会稍微复杂一些,但在ggeffects-package中实现。您可以在此小插图中找到更多详细信息。

默认情况下,两者predict()emmeans()不会返回最合适的置信区间,正如 Brooks 等人提出的那样。(见https://journal.r-project.org/archive/2017/RJ-2017-066/RJ-2017-066.pdf,附录)。

请参阅此处的示例:

library(glmmTMB)
data(Salamanders)

m <- glmmTMB(
  count ~ spp + mined + (1 | site),
  ziformula = ~ spp + mined,
  family = truncated_poisson,
  data = Salamanders
)

# emmeans, not taking zero-inflation component into account
emmeans::emmeans(m, "spp", type = "response")
#>  spp    rate    SE  df lower.CL upper.CL
#>  GP    1.553 0.223 627    1.171     2.06
#>  PR    0.922 0.251 627    0.540     1.57
#>  DM    1.944 0.250 627    1.511     2.50
#>  EC-A  1.277 0.246 627    0.875     1.86
#>  EC-L  2.965 0.337 627    2.372     3.71
#>  DES-L 2.844 0.321 627    2.280     3.55
#>  DF    1.626 0.222 627    1.244     2.13
#> 
#> Results are averaged over the levels of: mined 
#> Confidence level used: 0.95 
#> Intervals are back-transformed from the log scale

# ggeffects with emmeans, not taking zero-inflation 
# component into account
ggeffects::ggemmeans(m, "spp", type = "fe")
#> 
#> # Predicted counts of count
#> # x = spp
#> 
#>      x predicted conf.low conf.high
#>     GP     1.553    1.171     2.059
#>     PR     0.922    0.540     1.574
#>     DM     1.944    1.511     2.502
#>   EC-A     1.277    0.875     1.863
#>   EC-L     2.965    2.372     3.707
#>  DES-L     2.844    2.280     3.549
#>     DF     1.626    1.244     2.126

# ggeffects with emmeans, taking zero-inflation 
# component into account
ggeffects::ggemmeans(m, "spp", type = "fe.zi")
#> 
#> # Predicted counts of count
#> # x = spp
#> 
#>      x predicted conf.low conf.high
#>     GP     0.567    0.483     0.651
#>     PR     0.089    0.072     0.107
#>     DM     0.911    0.773     1.048
#>   EC-A     0.204    0.167     0.242
#>   EC-L     1.389    1.172     1.606
#>  DES-L     1.506    1.268     1.744
#>     DF     0.762    0.637     0.886

reprex 包(v0.3.0)于 2019 年 8 月 9 日创建

于 2019-08-09T18:54:36.083 回答
1

这是一个苹果对橘子的局面。

emmeans调用计算模型在 和 的每个组合处的p1预测p2。那些可以被反向转换。

但是,confint(model)要求对回归系数进行推断。这些系数本质上是斜率。它们不像 EMM 那样在对数尺度上,并且它们不能进行反向转换。

于 2019-08-02T12:28:28.873 回答