您不能从预测均值中“删除”预测变量(当您使用 时predict()
),因为这只会返回NA
值。因此,我会推荐与 Allen 相同的方法,并使用一个合理/有意义的值,让您保持Logger.ID
不变。这是ggeffects包中的一个示例:
library(ggeffects)
library(glmmTMB)
data("Salamanders")
m <- glmmTMB(count ~ spp * mined + sample + (1 | site), family = nbinom1, data = Salamanders)
# hold "sample" constant at its mean value
ggpredict(m, c("spp", "mined"))
#>
#> # Predicted counts of count
#> # x = spp
#>
#> # mined = yes
#>
#> x | Predicted | SE | 95% CI
#> --------------------------------------
#> GP | 0.04 | 1.01 | [0.01, 0.27]
#> PR | 0.11 | 0.60 | [0.03, 0.36]
#> DM | 0.38 | 0.36 | [0.19, 0.78]
#> EC-A | 0.11 | 0.60 | [0.03, 0.36]
#> EC-L | 0.32 | 0.38 | [0.15, 0.68]
#> DF | 0.56 | 0.32 | [0.30, 1.04]
#>
#> # mined = no
#>
#> x | Predicted | SE | 95% CI
#> --------------------------------------
#> GP | 2.27 | 0.20 | [1.53, 3.37]
#> PR | 0.46 | 0.33 | [0.24, 0.88]
#> DM | 2.42 | 0.20 | [1.64, 3.58]
#> EC-A | 0.89 | 0.27 | [0.53, 1.50]
#> EC-L | 3.20 | 0.19 | [2.21, 4.65]
#> DF | 1.85 | 0.21 | [1.22, 2.81]
#>
#> Adjusted for:
#> * sample = 2.50
#> * site = NA (population-level)
#> Standard errors are on the link-scale (untransformed).
# predicted means when sample is set to "0"
ggpredict(m, c("spp", "mined"), condition = list(sample = 0))
#>
#> # Predicted counts of count
#> # x = spp
#>
#> # mined = yes
#>
#> x | Predicted | SE | 95% CI
#> --------------------------------------
#> GP | 0.04 | 1.02 | [0.00, 0.27]
#> PR | 0.11 | 0.62 | [0.03, 0.36]
#> DM | 0.38 | 0.38 | [0.18, 0.80]
#> EC-A | 0.11 | 0.61 | [0.03, 0.36]
#> EC-L | 0.32 | 0.40 | [0.15, 0.69]
#> DF | 0.54 | 0.34 | [0.28, 1.06]
#>
#> # mined = no
#>
#> x | Predicted | SE | 95% CI
#> --------------------------------------
#> GP | 2.22 | 0.24 | [1.40, 3.52]
#> PR | 0.45 | 0.36 | [0.22, 0.90]
#> DM | 2.37 | 0.24 | [1.49, 3.78]
#> EC-A | 0.87 | 0.30 | [0.49, 1.58]
#> EC-L | 3.14 | 0.22 | [2.04, 4.81]
#> DF | 1.81 | 0.25 | [1.11, 2.95]
#>
#> Adjusted for:
#> * site = NA (population-level)
#> Standard errors are on the link-scale (untransformed).
由reprex 包(v0.3.0)于 2020 年 9 月 14 日创建