使用R语言包AER中的Affairs作为例子
data(Affairs, package = "AER")
View(Affairs)
summary(Affairs)
table((Affairs$affairs))
#分类变量,变成因子
Affairs$ynaffair[Affairs$affairs > 0] <- 1
Affairs$ynaffair[Affairs$affairs == 0] <- 0
Affairs$ynaffair <- factor(Affairs$ynaffair,
levels= c(0,1),
labels = c("no","yes"))
table((Affairs$ynaffair))
#建模,因子全纳入
fit.full <- glm(ynaffair ~ gender + age + yearsmarried + children +
religiousness + education + occupation + rating ,
data = Affairs, family = binomial())
summary(fit.full)
coef(fit.full)
#OR值
exp(coef(fit.full))
confint(fit.full)
#95%的置信区间
exp(confint(fit.full))
这个就是OR值
这个就是置信区间
原创文章(本站视频密码:66668888),作者:xujunzju,如若转载,请注明出处:https://zyicu.cn/?p=16500