【发布时间】:2014-08-18 05:52:34
【问题描述】:
我有两组的考试成绩,a 和 b。
test.a=c(1.12, 1, 2, 1.4, 2)
test.b=c(2, 1, 1.5, 1.7, 1)
如果此人得分超过 1.1,我想将他/她标记为积极。
test.a=ifelse(test.a>1.1,'positive','negative')
test.b=ifelse(test.b>1.1,'positive', 'negative')
test.ab=c(test.a, test.b)
状态是一个二元响应变量,表示该人是否患有疾病(0 = 没有疾病,1 = 疾病)
status=c(rep(0,2), rep(1,3))
status=as.factor(status)
test.ab=as.factor(test.ab)
test.data=data.frame(status, test.ab)
test.fit=glm(status~test.ab, data=test.data, family="binomial")
summary(test.fit)
汇总函数返回
Call:
glm(formula = status ~ test.ab, family = "binomial", data = test.data)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.58 -0.90 0.82 0.82 1.48
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.693 1.225 -0.57 0.57
test.abpositive 1.609 1.483 1.09 0.28
我不明白为什么在 test.ab 上附加了正数?系数不应该只是我在 data.frame 和 glm() 命令中指定的 test.ab 吗?
【问题讨论】:
-
test.ab是一个有两个类别的分类变量。test.abpositive为您提供被归类为“正”的对数赔率的差异,与在本例中选择为test.abnegative的基线相比。 -
如果您不想要这种行为,可以将其显式编码为 0 和 1
标签: r logistic-regression