The General Social Survey(GSS) is used to monitor changes in American society. The GSS is used to monitor and explain trends and constants in attitudes and behaviors. GSS questions range from a wide variety of topics including respondents age to more sensitive topics (ex. past drug use). For this assignment I have decided to use the data gathered in the General Social Survey of 2014. For this GSS, data was collected from 2538 respondents and has 866 variables.
library(foreign)
setwd("C:/Users/Xiomara/Desktop/Fall semester '14/Socio Hsin MONDAY/STATA")
mydata <- read.dta(file="gss2014.dta")
library(Zelig)
library(DescTools)
library(dplyr)
I am using the GSS of 2014 for this assignment, there are over 800 variables therefore I will not include them into the final project but I will be varying between these variables during the semesters. For this assignment I am only using the following three variables which are {abany, age, and sex}, I have selected these three variables as shown below. These variables respresent the age of the respondent, sex of the respondent and whether they believe a woman has the right to get an abortion for any reason.
names(mydata)
mydata2<- select(mydata, abany, age, sex)
names(mydata2)
## [1] "abany" "age" "sex"
There are a number of variables that could have been chosen, I chose these three variables because I want to see if there is a relationship between age and whether they believe a woman should be able to get an abortion regardless of the reason. I want to see if these differences, if any, change when we control for sex of the respondent.
plot(age ~ abany, data=mydata)
reg1 <- zelig(age ~ abany, model="normal", data=mydata)
reg2 <- zelig(age ~ abany + sex, model = "normal", data=mydata)
summary(reg1)
##
## Call:
## glm(formula = formula, weights = weights, family = gaussian,
## model = F, data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -32.002 -15.002 -0.383 12.998 41.237
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 47.7631 0.6405 74.575 <2e-16 ***
## abanyno 2.2391 0.8647 2.589 0.0097 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 304.7788)
##
## Null deviance: 503100 on 1645 degrees of freedom
## Residual deviance: 501056 on 1644 degrees of freedom
## (892 observations deleted due to missingness)
## AIC: 14090
##
## Number of Fisher Scoring iterations: 2
summary(reg2)
##
## Call:
## glm(formula = formula, weights = weights, family = gaussian,
## model = F, data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -32.067 -14.920 -0.376 13.080 41.315
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 47.6846 0.7900 60.362 < 2e-16 ***
## abanyno 2.2356 0.8652 2.584 0.00986 **
## sexfemale 0.1470 0.8650 0.170 0.86505
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 304.9589)
##
## Null deviance: 503100 on 1645 degrees of freedom
## Residual deviance: 501047 on 1643 degrees of freedom
## (892 observations deleted due to missingness)
## AIC: 14092
##
## Number of Fisher Scoring iterations: 2
library(stargazer)
##
## Please cite as:
##
## Hlavac, Marek (2014). stargazer: LaTeX code and ASCII text for well-formatted regression and summary statistics tables.
## R package version 5.1. http://CRAN.R-project.org/package=stargazer
stargazer(reg1, reg2, type="text")
##
## ==============================================
## Dependent variable:
## ----------------------------
## age
## (1) (2)
## ----------------------------------------------
## abanyno 2.239*** 2.236***
## (0.865) (0.865)
##
## sexfemale 0.147
## (0.865)
##
## Constant 47.763*** 47.685***
## (0.640) (0.790)
##
## ----------------------------------------------
## Observations 1,646 1,646
## Log Likelihood -7,042.792 -7,042.777
## Akaike Inf. Crit. 14,089.580 14,091.550
## ==============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
What we find is that with a 99% confidence level there is a strong correlation between age and whether or not the respondent believes that women should be allowed to get an abortion for any reason. The table above shows that as the respodents age goes up there is an increase (0.865) that they will say no to woman being able to get an abortion for any reason.