Tuesday, October 26, 2010

R: Logistic Regression

# practically reposted from Quick R

# i haven't had the chance to test this, but I really don't see why it shouldn't work... if you try using it and it refuses to cooperate, send me an email.

# Data input: generic

fit <- glm(binary.outcome.var~indep.var1+indep.var2+indep.var3+...+indep.var,data=infile,family=binomial()) # where all indep.var(s) are continous variables. And assuming your the file your data resides in is called infile.
summary(fit) # display results
confint(fit) # 95% CI for the coefficients
exp(coef(fit)) # exponentiated coefficients
exp(confint(fit)) # 95% CI for exponentiated coefficients
predict(fit, type="response") # predicted values
residuals(fit, type="deviance") # residuals

# /* END OF LOGISTIC REGRESSION*/

No comments:

Post a Comment