#
#
########## Binary or Binomial Logistic Regression Analysis example ##########
#
#
# This script assumes you have worked through all the previous notes from
# the web page and you have downloaded, installed, and updated all available
# R packages.
# Load the following libraries if you have not already.
library(Rcmdr)
library(foreign)
# Data available here: http://researchsupport.unt.edu/class/Jon/R_SC/Module9/logreg1.txt
logreg <- read.table("http://researchsupport.unt.edu/class/Jon/R_SC/Module9/logreg1.txt",
header=TRUE, sep="", na.strings="NA", dec=".", strip.white=TRUE)
summary(logreg)
# Data also available as SPSS.sav file here: http://researchsupport.unt.edu/class/Jon/SPSS_SC/Module9/M9_LogReg/logreg1.sav
logreg1 <- read.spss("http://researchsupport.unt.edu/class/Jon/SPSS_SC/Module9/M9_LogReg/logreg1.sav", use.value.labels=TRUE,
max.value.labels=Inf, to.data.frame=TRUE)
summary(logreg1)
# Disregard the warnings; they merely reflect that a binomial model was fit (rather than a
# Gaussian or normal model).
GLM.1 <- glm(y ~ x1 + x2 + x3 + x4, logreg, family=binomial(logit))
GLM.2 <- glm(y ~ x1 + x2 + x3 + x4, logreg1, family=binomial(logit))
summary(GLM.1)
summary(GLM.2)
# Named elements of the output (most not shown by default.
names(GLM.1)
# Miscellaneous (often useful) elements of the output (not printed by default).
coefficients(GLM.1)
residuals(GLM.1)
summary(residuals(GLM.1))
fitted.values(GLM.1)
summary(fitted.values(GLM.1))