如何使用 GLM 泊松输出计算百分比变化

How to calculate % change with GLM Poisson output

背景:我有计数数据(甲虫计数),我正在研究处理梯度对计数数据的影响。梯度是一个连续的预测变量,由“7 个水平”组成(即 -100% 减少、-80% 减少、-60% 减少、-40% 减少、-20% 减少、0% 减少和 50% 增加) . “减少 0%”表示没有变化,或者说是对照。我想使用 GLM 输出将处理“-60% 减少”(例如)与“0% 减少”进行比较。

我如何在 R 中使用具有泊松分布和对数 link 的 GLMM 输出来计算计数数据在“-60% 减少”和“0% 减少”之间的百分比变化?

这是模型样本:

glmmTMB(count_data ~ continuous_predictor + (1|random_effect),
        family=poisson(link=log), data=data)
plot number treatment beetle count
1 -60 4
2 -20 13
3 0 23
4 -100 2
5 50 10
6 -80 3
7 -40 5
8 0 14
9 -20 9
10 -60 7
11 -100 1
12 -40 2

让我们先让您的示例可重现:

library(glmmTMB)

data <- structure(list(
  plot_number  = 1:12, 
  treatment    = c(-60L, -20L, 0L, -100L, 50L, -80L, 
                   -40L, 0L, -20L, -60L, -100L, -40L), 
  beetle_count = c(4L, 13L, 23L, 2L, 10L, 3L, 5L, 14L, 
                   9L, 7L, 1L, 2L)), 
  class = "data.frame", row.names = c(NA, -12L))

您使用提供的数据描述的模型如下所示:

model <- glmmTMB(beetle_count ~ treatment + (1|plot_number),
                 family = poisson(link = log), 
                 data = data)

summary(model)
#>  Family: poisson  ( log )
#> Formula:          beetle_count ~ treatment + (1 | plot_number)
#> Data: data
#> 
#>      AIC      BIC   logLik deviance df.resid 
#>     68.4     69.8    -31.2     62.4        9 
#> 
#> Random effects:
#> 
#> Conditional model:
#>  Groups      Name        Variance Std.Dev.
#>  plot_number (Intercept) 0.1703   0.4127  
#> Number of obs: 12, groups:  plot_number, 12
#> 
#> Conditional model:
#>             Estimate Std. Error z value Pr(>|z|)    
#> (Intercept) 2.366465   0.201081  11.769  < 2e-16 ***
#> treatment   0.015117   0.004148   3.645 0.000268 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

这意味着如果我们想估计给定值 treatmentbeetle_count,我们需要计算 exp(2.366465 + 0.015117 * treatment)。请注意,当处理为 0 时,这将简化为 exp(2.366465) 或 10.65964。对于 -60 的处理值,该值为 exp(2.366465 + 0.015117 * -60) 或 4.30357.

因此预期计数已从 10.65964 下降到 4.30357,这意味着下降百分比为

100 * ((10.65964 - 4.30357) / 10.65964)
#> [1] 59.62744

这几乎是 bang-on 60%

如果您想探索治疗水平(我们称它们为 treatment_Atreatment_B)之间的百分比差异,则公式可简化为

100 * (1 - exp(0.015117)^(treatment_A - treatment_B))