我正在尝试进行物流回归,以预测民主党赢得大选的可能性。
响应变量:民主党胜利= 1,民主党人失败= 0。 预测变量:
我的数据是从1960年到2016年。
Name Democrat_win Electoral_rate_D_percent Votes_for_D States_vote_D CA_vote_D
Ronald Reagan 0 9.1 49 7 0
Ronald Reagan 0 2.4 13 2 0
George Bush 0 20.6 111 11 0
William J. Clinton 1 68.8 370 33 1
William J. Clinton 1 70.4 379 32 1
George W. Bush 0 49.4 266 21 1
George W. Bush 0 46.7 251 20 1
Barack Obama 1 67.8 365 32 1
Barack Obama 1 61.7 332 27 1
Donald Trump 0 42.2 227 21 1
所以我在r中执行了一个glm并且它没有工作......每个预测器的p值是1.我该怎么办?
R代码如下:
election = read.csv("project.csv")
election
names(election)
attach(election)
election.glm1 = glm(Democrat_win~Electoral_rate_D_percent+States_vote_D, family = binomial, data = election)
summary(election.glm1)
输出如下:
Call:
glm(formula = Democrat_win ~ Electoral_rate_D_percent + States_vote_D,
family = binomial, data = election)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.322e-05 -2.110e-08 -2.110e-08 2.110e-08 1.392e-05
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.860e+02 3.363e+05 -0.001 1
Electoral_rate_D_percent 1.751e-01 1.918e+04 0.000 1
States_vote_D 7.344e+00 4.656e+04 0.000 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1.3460e+01 on 9 degrees of freedom
Residual deviance: 4.1815e-10 on 7 degrees of freedom
AIC: 6
Number of Fisher Scoring iterations: 25