[英]How to calculate % change with GLM Poisson output
背景:我有計數數據(甲蟲計數),我正在研究處理梯度對計數數據的影響。 梯度是一個連續的預測變量,由“7個級別”組成(即-100%減少、-80%減少、-60%減少、-40%減少、-20%減少、0%減少和50%增加) . '0% 減少'意味着沒有變化,或者這就是控制。 我想使用 GLM output 將處理“-60% 減少”(例如)與“0% 減少”進行比較。
如何使用具有泊松分布的 GLMM output 和 R 中的日志鏈接來計算“減少 -60%”和“減少 0%”之間計數數據的百分比變化?
這是 model 的示例:
glmmTMB(count_data ~ continuous_predictor + (1|random_effect),
family=poisson(link=log), data=data)
plot編號 | 治療 | 甲蟲數 |
---|---|---|
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 如下所示:
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
這意味着如果我們希望估計給定treatment
值的beetle_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
這幾乎是 60%
如果您想探索治療水平之間的百分比差異(我們稱它們為treatment_A
和treatment_B
),公式簡化為
100 * (1 - exp(0.015117)^(treatment_A - treatment_B))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.