I'm studying GLM models from the Lane (2002) paper and I am a bit confused with the analysis of deviance for the Gamma-GLM model.
In the paper, the p-value is lower than P < 0.001 but if we used the deviance reported as well as the degrees of freedom to calculate the p-value with the pchisq()
function in R we get the following results:
> 1-pchisq(11.1057, 7)
[1] 0.1340744`
and not the P <0.001 reported in the paper.
I've copied the data to replicate the GLM model here's the link ! and this is the code I used to generate the results:
test <- read_csv("data/test_glm_gamma.csv", col_types = cols())
model.test <- glm(soil ~ trt, family = Gamma(link = "log"), data = test)
anova(model.test, test = "Chisq")
which returns:
Analysis of Deviance Table
Model: Gamma, link: log
Response: cont
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev Pr(>Chi)
NULL 23 11.5897
trt 7 11.106 16 0.4839 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
with similar deviances as in the paper and I suspect similar P-value but this is not the 0.13 obtained before.
Is there any transformation done before the P-value is calculated? Or I am calculating the p-value in the wrong way? How do they get the <2.2e-16 in the deviance table?
Lane, PW (2002). Generalized linear models in soil science. European Journal of Soil Science, 53, 241–251. https://doi.org/10.1046/j.1365-2389.2002.00440.x
You need to pass the deviance scaled by the dispersion to pchisq
:
p <- pchisq(anova(model.test)$Deviance[2]/
summary(model.test)$dispersion,
anova(model.test)$Df[2],
lower.tail = FALSE)
p == anova(model.test, test = "Chisq")$`Pr(>Chi)`[2]
#[1] TRUE
You can study the code of stats:::stat.anova
to see how the p-values are calculated for the different tests.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.