logistic regression - glm function in R uses incorrect coefficient? -
i have test scores of 2 groups, , b.
test.a=c(1.12, 1, 2, 1.4, 2) test.b=c(2, 1, 1.5, 1.7, 1)
if person scores on 1.1, want label him/her positive.
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)
the status binary response variable indicates whether person has disease or not (0 = no diseae, 1=disease)
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)
the summary function returns
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
i don't understand why positive appended test.ab? shouldn't coefficient test.ab have specified in data.frame , in glm() command?
try
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)
Comments
Post a Comment