> CarData = read.table('car.data',sep=',',col.names=c('buying','maintenance','doors','persons','lug_boot','safety','rating'))
> summary(CarData)
buying maintenance doors persons lug_boot safety rating
high :432 high :432 2 :432 2 :576 big :576 high:576 acc : 384
low :432 low :432 3 :432 4 :576 med :576 low :576 good : 69
med :432 med :432 4 :432 more:576 small:576 med :576 unacc:1210
vhigh:432 vhigh:432 5more:432 vgood: 65
> logisticModel <- glm(rating!='unacc' ~ buying + maintenance + doors + persons + lug_boot +safety,
+ family=binomial(link = "logit"),data=CarData)
> summary(logisticModel)
Call:
glm(formula = rating != "unacc" ~ buying + maintenance + doors +
persons + lug_boot + safety, family = binomial(link = "logit"),
data = CarData)
Deviance Residuals:
Min 1Q Median 3Q Max
-3.2160 0.0000 0.0000 0.0257 2.4336
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -28.4255 1257.5255 -0.023 0.982
buyinglow 5.0481 0.5670 8.904 < 2e-16 ***
buyingmed 3.9218 0.4842 8.100 5.49e-16 ***
buyingvhigh -2.0662 0.3747 -5.515 3.49e-08 ***
maintenancelow 3.4064 0.4692 7.261 3.86e-13 ***
maintenancemed 3.4064 0.4692 7.261 3.86e-13 ***
maintenancevhigh -2.8254 0.4145 -6.816 9.36e-12 ***
doors3 1.8556 0.4042 4.591 4.41e-06 ***
doors4 2.4816 0.4278 5.800 6.62e-09 ***
doors5more 2.4816 0.4278 5.800 6.62e-09 ***
persons4 29.9652 1257.5256 0.024 0.981
personsmore 29.5843 1257.5255 0.024 0.981
lug_bootmed -1.5172 0.3758 -4.037 5.40e-05 ***
lug_bootsmall -4.4476 0.4750 -9.363 < 2e-16 ***
safetylow -30.5045 1300.3428 -0.023 0.981
safetymed -3.0044 0.3577 -8.400 < 2e-16 ***
---
Signif. codes: 0 ��***�� 0.001 ��**�� 0.01 ��*�� 0.05 ��.�� 0.1 �� �� 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 2110.47 on 1727 degrees of freedom
Residual deviance: 339.36 on 1712 degrees of freedom
AIC: 371.36
Number of Fisher Scoring iterations: 21
logit regression
最新推荐文章于 2022-04-14 22:20:10 发布