Skip to content

Instantly share code, notes, and snippets.

@smc77
Created October 26, 2011 01:45
Show Gist options
  • Save smc77/1315162 to your computer and use it in GitHub Desktop.
Save smc77/1315162 to your computer and use it in GitHub Desktop.
Logistic Regression
# Plot the sigmoid function
qplot(-10:10, 1/(1 + exp(-(-10:10))), geom="line", xlab="z", ylab="sigmoid function")
# Apply logistic regression to South African heart data from ESL
sa.heart <- glm(chd ~ sbp + tobacco + ldl + famhist + obesity + alcohol + age , family = binomial , data=hr)
summary(sa.heart)
# Use stepwise logistic regression to reduce the dimensions
library(MASS)
sa.heart.step <- stepAIC(sa.heart)
summary(sa.heart.step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment