puzzling results from logistic regression
Michael <comtech.usa <at> gmail.com> writes:
Hi all, As you can see from below, the result is strange... I would imagined that the bb result should be much higher and close to 1, any way to improve the fit? Any other classification methods? Thank you! data=data.frame(y=rep(c(0, 1), times=100), x=1:200) aa=glm(y~x, data=data, family=binomial(link="logit")) newdata=data.frame(x=6, y=100) bb=predict(aa, newdata=newdata, type="response") bb
bb
1 0.4929125
I have a feeling you meant to say data <- data.frame(y=rep(c(0,1), each=100), x=1:200) instead. Try with(data,plot(y~x)) for each data set to see what you actually got as opposed to what you thought you were getting it. You may still have a little bit of a problem fitting such an extreme data set -- this is what is called "complete separation", and leads to an infinite estimate of the slope -- if you want to pursue this, take a look at the brglm package.