The data set I chose do use is the 2014 GSS data. I orginally wanted t ouse the entire 1972-2014 data set by my laptop only has 4 GB of memory and my larger computer with 16GB of memory would take to much time to reinstall everything on it. The data set I am using is colleted every year and is aviliabe on norc.org.
The variables I am interested in are age, sex and polviews. Polviews is a 1 to 7 scale variable that puts 1 as extreme liberal and 7 extreme conservative. I would like to see if there is a connection between age and sex when it comes to political views. I hypostasis that there is a correlation.
According to the data there is a slight correlation between political views and age when controlling for sex. The P value is .051 which isn’t statistically significant but is somewhat strong.
library(foreign)
library(Zelig)
## Loading required package: boot
## Loading required package: MASS
## Loading required package: sandwich
## ZELIG (Versions 4.2-1, built: 2013-09-12)
##
## +----------------------------------------------------------------+
## | Please refer to http://gking.harvard.edu/zelig for full |
## | documentation or help.zelig() for help with commands and |
## | models support by Zelig. |
## | |
## | Zelig project citations: |
## | Kosuke Imai, Gary King, and Olivia Lau. (2009). |
## | ``Zelig: Everyone's Statistical Software,'' |
## | http://gking.harvard.edu/zelig |
## | and |
## | Kosuke Imai, Gary King, and Olivia Lau. (2008). |
## | ``Toward A Common Framework for Statistical Analysis |
## | and Development,'' Journal of Computational and |
## | Graphical Statistics, Vol. 17, No. 4 (December) |
## | pp. 892-913. |
## | |
## | To cite individual Zelig models, please use the citation |
## | format printed with each model run and in the documentation. |
## +----------------------------------------------------------------+
##
##
##
## Attaching package: 'Zelig'
##
## The following object is masked from 'package:utils':
##
## cite
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
library(DescTools)
##
## Attaching package: 'DescTools'
##
## The following object is masked from 'package:Zelig':
##
## Mode
GSS = read.spss("C:\\Users\\User\\Documents\\SOC\\Data\\Spss\\GSS2014.sav", to.data.frame=TRUE)
## Warning in
## read.spss("C:\\Users\\User\\Documents\\SOC\\Data\\Spss\\GSS2014.sav", :
## C:\Users\User\Documents\SOC\Data\Spss\GSS2014.sav: Unrecognized record
## type 7, subtype 18 encountered in system file
## Warning in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels)
## else paste0(labels, : duplicated levels in factors are deprecated
## Warning in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels)
## else paste0(labels, : duplicated levels in factors are deprecated
## Warning in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels)
## else paste0(labels, : duplicated levels in factors are deprecated
## Warning in `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels)
## else paste0(labels, : duplicated levels in factors are deprecated
polviewsage <- zelig(age ~ polviews, data = GSS, model = "normal")
##
##
## How to cite this model in Zelig:
## Kosuke Imai, Gary King, and Olivia Lau. 2015.
## "normal: Normal Regression for Continuous Dependent Variables"
## in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software,"
## http://gking.harvard.edu/zelig
##
polviewsagesex <- zelig(age ~ polviews + sex, data = GSS, model = "normal")
##
##
## How to cite this model in Zelig:
## Kosuke Imai, Gary King, and Olivia Lau. 2015.
## "normal: Normal Regression for Continuous Dependent Variables"
## in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software,"
## http://gking.harvard.edu/zelig
##
stargazer(polviewsage, polviewsagesex, type = "text")
##
## ==============================================
## Dependent variable:
## ----------------------------
## age
## (1) (2)
## ----------------------------------------------
## polviews -0.051** -0.051**
## (0.023) (0.023)
##
## sexFEMALE 0.429
## (0.700)
##
## Constant 49.375*** 49.140***
## (0.380) (0.540)
##
## ----------------------------------------------
## Observations 2,505 2,505
## Log Likelihood -10,714.630 -10,714.440
## Akaike Inf. Crit. 21,433.260 21,434.890
## ==============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
plot(polviewsage)
plot(polviewsagesex)