我正在运行一个零膨胀glmmTMB模型。我有兴趣在条件成分和零通胀成分的不同因子水平之间进行成对比较。有条件的部分,我可以用通常的emmeans方法轻松完成。我一直在尝试使用(相对)新创建的glmmTMB:::emm_basis.glmmTMB,但无法弄清楚该函数采用的一些参数,也找不到示例......
这是我目前所处位置的一个玩具示例。我专门poly()向模型添加了一个组件 - 我的完整模型同时具有poly()和ns(),因此需要弄清楚它们在这里是如何工作的。
所以问题如下:1)我trms提供的论点是否正确?2)函数需要什么参数xlev和grid参数emm_basis.glmmTMB?
library(glmmTMB)
data(Salamanders)
mod <- glmmTMB(count ~ spp + mined + poly(cover, 2) + (1|site), zi=~spp + mined, Salamanders,
family=nbinom2)
tt <- y ~ spp + mined + poly(cover, 2)
tt <- delete.response(terms(tt))
glmmTMB:::emm_basis.glmmTMB(mod, trms = tt)
Run Code Online (Sandbox Code Playgroud)
非常感谢您的任何想法!
函数emm_basis()和是emmeansrecover_data()包的支持函数,具有许多不同模型类的方法,包括. 这些函数并不意味着由用户调用——这就是为什么它们被注册为方法而不是被导出的原因。glmmTMB
相反,只需调用emmeansemmeans()包中的或其他函数,这些方法将根据需要使用。
对于对象,调用中可能包含glmmTMB一个可选参数。在你的例子中:componentemmeans()
> emmeans(mod, ~spp, component = "cond")
spp emmean SE df lower.CL upper.CL
GP 0.440 0.225 624 -0.00146 0.881
PR -0.382 0.483 624 -1.32983 0.566
DM 0.596 0.203 624 0.19723 0.994
EC-A 0.145 0.327 624 -0.49699 0.787
EC-L 0.991 0.231 624 0.53814 1.445
DES-L 1.009 0.188 624 0.64015 1.379
DF 0.332 0.217 624 -0.09448 0.758
Results are averaged over the levels of: mined
Results are given on the log (not the response) scale.
Confidence level used: 0.95
Run Code Online (Sandbox Code Playgroud)
(我们实际上不需要包含component,因为默认值为cond。)这些结果采用对数刻度,这是由于nbinom2用于拟合模型条件部分的系列的结果。您可以通过指定以下内容在响应量表上查看这些结果type:
> emmeans(mod, ~spp, type = "response")
spp response SE df lower.CL upper.CL
GP 1.553 0.349 624 0.999 2.41
PR 0.682 0.329 624 0.265 1.76
DM 1.814 0.368 624 1.218 2.70
EC-A 1.156 0.378 624 0.608 2.20
EC-L 2.695 0.622 624 1.713 4.24
DES-L 2.744 0.516 624 1.897 3.97
DF 1.394 0.303 624 0.910 2.13
Results are averaged over the levels of: mined
Confidence level used: 0.95
Intervals are back-transformed from the log scale
Run Code Online (Sandbox Code Playgroud)
您可以通过以下方式查看模型的零膨胀部分compoenent = "zi":
> emmeans(mod, ~spp, component = "zi", type = "response")
spp response SE df lower.CL upper.CL
GP 0.455 0.1064 624 0.2646 0.660
PR 0.763 0.1406 624 0.4115 0.937
DM 0.273 0.1128 624 0.1097 0.534
EC-A 0.719 0.1020 624 0.4870 0.873
EC-L 0.365 0.1085 624 0.1864 0.590
DES-L 0.278 0.0989 624 0.1275 0.503
DF 0.132 0.1150 624 0.0207 0.522
Results are averaged over the levels of: mined
Confidence level used: 0.95
Intervals are back-transformed from the logit scale
Run Code Online (Sandbox Code Playgroud)
目前,似乎无法估计实际的平均响应 (1 - zi)*(condmean);这很有用,但相当混乱,因为它需要组合两个组件。
| 归档时间: |
|
| 查看次数: |
1539 次 |
| 最近记录: |