似然比检验和Wald检验为R中的glm提供了不同的结论


11

我正在从通用模型,线性模型和混合模型复制示例。我的MWE如下:

Dilution <- c(1/128, 1/64, 1/32, 1/16, 1/8, 1/4, 1/2, 1, 2, 4)
NoofPlates <- rep(x=5, times=10)
NoPositive <- c(0, 0, 2, 2, 3, 4, 5, 5, 5, 5)
Data <- data.frame(Dilution,  NoofPlates, NoPositive)

fm1 <- glm(formula=NoPositive/NoofPlates~log(Dilution), family=binomial("logit"), data=Data)
summary(object=fm1)

输出量


Call:
glm(formula = NoPositive/NoofPlates ~ log(Dilution), family = binomial("logit"), 
    data = Data)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-0.38326  -0.20019   0.00871   0.15607   0.48505  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)
(Intercept)      4.174      2.800   1.491    0.136
log(Dilution)    1.623      1.022   1.587    0.112

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 8.24241  on 9  degrees of freedom
Residual deviance: 0.64658  on 8  degrees of freedom
AIC: 6.8563

Number of Fisher Scoring iterations: 6


anova(object=fm1, test="Chisq")

输出量


Analysis of Deviance Table

Model: binomial, link: logit

Response: NoPositive/NoofPlates

Terms added sequentially (first to last)


              Df Deviance Resid. Df Resid. Dev Pr(>Chi)   
NULL                              9     8.2424            
log(Dilution)  1   7.5958         8     0.6466  0.00585 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1   1


library(aod)
wald.test(b=coef(object=fm1), Sigma=vcov(object=fm1), Terms=2)

输出量


Wald test:
----------

Chi-squared test:
X2 = 2.5, df = 1, P(> X2) = 0.11

估计的系数与书中给出的结果完全匹配,但SE的相距很远。基于LRT测试,斜率显着,但基于Wald和Z测试,斜率系数不明显。我想知道我是否想念一些基本的东西。在此先感谢您的帮助。


Answers:


12

主要的问题是,如果要使用比率作为响应变量,则应使用weights参数。您必须忽略有关“二项式glm中非整数#成功”的警告...

Dilution <- c(1/128, 1/64, 1/32, 1/16, 1/8, 1/4, 1/2, 1, 2, 4)
NoofPlates <- rep(x=5, times=10)
NoPositive <- c(0, 0, 2, 2, 3, 4, 5, 5, 5, 5)
Data <- data.frame(Dilution,  NoofPlates, NoPositive)


fm1 <- glm(formula=NoPositive/NoofPlates~log(Dilution),
     family=binomial("logit"), data=Data, weights=NoofPlates)

coef(summary(fm1))
##               Estimate Std. Error  z value     Pr(>|z|)
## (Intercept)   4.173698  1.2522190 3.333042 0.0008590205
## log(Dilution) 1.622552  0.4571016 3.549653 0.0003857398

anova(fm1,test="Chisq")
##               Df Deviance Resid. Df Resid. Dev  Pr(>Chi)    
## NULL                              9     41.212              
## log(Dilution)  1   37.979         8      3.233 7.151e-10 ***

LRT和Wald测试结果仍然相差甚远(值为与),但出于实际目的,我们可以继续说一下,它们都是非常重要...(在这种情况下(使用单个参数),给出与完全相同的p值)。p4×10-47×10-10aod::wald.test()summary()

Wald与配置文件的置信区间也相差不大,但(0.7,2.5)(Wald)和(0.9,2.75)(LRT)的置信区间[如下所示] 实际上是否不同取决于具体情况。

沃尔德:

confint.default(fm1)
##                   2.5 %   97.5 %
## (Intercept)   1.7193940 6.628002
## log(Dilution) 0.7266493 2.518455

轮廓:

confint(fm1)
##                   2.5 %   97.5 %
## (Intercept)   2.2009398 7.267565
## log(Dilution) 0.9014053 2.757092
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.