我的测试成绩分为两组,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?系数不应该只是test.ab,就像我在data.frame和glm()命令中指定的一样吗?
答案 0 :(得分:0)
尝试
test.a=c(1.12, 1, 2, 1.4, 2)
test.b=c(2, 1, 1.5, 1.7, 1)
test.a=ifelse(test.a>1.1,1,0)
test.b=ifelse(test.b>1.1,1,0)
test.ab=c(test.a, test.b)
status=c(rep(0,2), rep(1,3))
status=as.factor(status)
test.data=data.frame(status, test.ab)
test.fit=glm(status~test.ab, data=test.data, family="binomial")
summary(test.fit)