Submitted by Professor Shortell on Wed, 11/01/2017 - 18:10
Submitted by Professor Shortell on Wed, 10/04/2017 - 19:45
#Recode
V162034r<-'NA'; V162034r[V162034a==1]<-1; V162034r[V162034a==2]<-2
#Contingency table
CrossTable(V162034r,V161310a,prop.r=FALSE,prop.c=TRUE,prop.t=FALSE,prop.chisq=FALSE,chisq=TRUE,fisher=TRUE)
Submitted by Professor Shortell on Wed, 09/27/2017 - 13:46
Logistic Regression
Let's test a model to predict voting for Trump in 2016.
First, some recodes:
Vote4Trump<-ifelse(V162034a==2,1,0) #This will be our DV
Gender<-'NA'; Gender[V161342==1]<-1; Gender[V161342==2]<-0
V161310r<-'NA'; V161310r[V161310a>=0]<-0; V161310r[V161310a==1]<-1
Now, the model:
summary(glm(Vote4Trump~Gender+V161310r+V161126))
exp(coef(glm(Vote4Trump~Gender+V161310r+V161126)))
Submitted by Professor Shortell on Wed, 09/06/2017 - 19:35
Submitted by Professor Shortell on Wed, 09/06/2017 - 18:20
Let's review the linear model with an example.
DATAFRAME: ANES 2012
DV: Favorability to Democratic Party (ft_dem)
IVs: Political view (libcpre_self)
Attitude toward DACA (immig_citizen) * recoded
Attitude toward affirmative action (aa_uni) * recoded
Religiosity (relig_import)
Gender (gender_respondent)
RECODES
immig_citizenr<-ifelse(immig_citizen==1,1,0)
aa_unir<-ifelse(aa_uni==1,1,0)
MODEL
summary(lm(ft_dem~libcpre_self+immig_citizenr+aa_unir+relig_import+gender_respondent))
Pages