【发布时间】:2019-01-30 17:08:01
【问题描述】:
我正在尝试在没有截距的情况下运行逻辑回归。首先,我尝试了函数glm,但出现以下错误:
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
鉴于我的工作性质根本无法更改数据集,因此我决定使用另一个 R 程序包,其代码为 bayesglm。
当我使用这个包含拦截的函数时,我没有收到上述错误消息。但是,当我通过在函数末尾添加 -1 来排除拦截时,我仍然得到相同的结果上面的错误,输出如下:
> regress=bayesglm(y~x1*x2+x3+x4-1, data = DATA, family=binomial(link="logit"))
> summary(regress)
Call:
bayesglm(formula = y ~ x1 * x2 + x3 + x4 - 1, family = binomial(link = "logit"),
data = DATA, maxit = 10000)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.01451 -0.43143 -0.22778 -0.05431 2.89066
Coefficients:
Estimate Std. Error z value Pr(>|z|)
x1 -20.45537 9.70594 -2.108 0.03507 *
x2 -7.04844 2.87415 -2.452 0.01419 *
x1:x2 0.13409 17.57010 0.008 0.99391
x3 -0.17779 0.06377 -2.788 0.00531 **
x4 -0.02593 0.05313 -0.488 0.62548
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 494.91 on 357 degrees of freedom
Residual deviance: 124.93 on 352 degrees of freedom
(165 observations deleted due to missingness)
AIC: 134.93
Number of Fisher Scoring iterations: 123
并得到与以下相同的错误:
Warning message:
glm.fit: fitted probabilities numerically 0 or 1 occurred
如果我不添加 -1 来删除拦截,我不会得到。
因此,我有两个问题要问:
1.我可以忽略这个警告信息吗?
2。否则,我可以知道如何根据此警告消息解决问题吗?
【问题讨论】:
标签: r warnings logistic-regression intercept bayesglm