[英]glm function in R uses incorrect coefficient?
我有两组的考试成绩,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.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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.