More on Logistic Regression

# We'll look at another example of logistic regression and
# model specification. This time, we'll use the ANES 2012.

ANES2012<-read.csv("http://www.courseserve.info/files/ANES2012r.csv")
attach(ANES2012)

# First, we'll create a binary vector for party affiliation
# that compares just Democrats and Republicans. With the
# new variable, "repub", we'll be building a model that
# tries to predict the characteristics associated with the
# odds of identifying as a Republican rather than a Democrat.

repub=0; repub[pid_self==1]<-0; repub[pid_self==2]<-1

# Now, we'll specify our base model.

# We'll use the index that measures attitude toward federal
# spending that we created earlier. The source code is here:
source("http://www.courseserve.info/files/SOCY7112spending.r")

# Let's create a binary vector for marital status (married, not married):
married=0; married<-ifelse(dem_marital==1,1,0)

# We'll use a pair of binary vectors to measure race. The
# code is here:
source("http://www.courseserve.info/files/SOCY7112race.r")

# We'll use binary vectors for education and region:
source("http://www.courseserve.info/files/SOCY7112degree.r")
source("http://www.courseserve.info/files/SOCY7112anesregion.r")

# Now we can run the base model.

summary(glm(repub~spending+married+dem_unionhh+black+hispanic+collegegrad+northeast+northcentral+south,family="binomial"))