model<-glm(response~risk,
family=binomial,
data = dat)
summary(model)
##得到OR值
exp(coef(model))
##得到95%CI
exp(confint(model,level = 0.95))
#指定输出某一项
exp(coef(m)['变量名'])
exp(confint(m, parm = "变量名",level = 0.95))
As with the linear regression routine and the ANOVA routine in R, the 'factor( )' command can be used to declare a categorical predictor (with more than two categories) in a logistic regression; R will create dummy variables to represent the categorical predictor using the lowest coded category as the reference group.
当变量分类大于2时,需要设置为factor,代表数值小的分类为reference
参考网页:
https://sphweb.bumc.bu.edu/otlt/MPH-Modules/PH717-QuantCore/PH717_MultipleVariableRegression/PH717_MultipleVariableRegression6.html
https://sphweb.bumc.bu.edu/otlt/MPH-Modules/BS/R/R-Manual/R-Manual20.html#:~:text=As%20with%20the%20linear%20regression%20routine%20and%20the,the%20lowest%20coded%20category%20as%20the%20reference%20group.
网友评论