(updates are at bottom)
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.
Addtion: Since there isn’t any obvious data that I could combine in the GSS, i decided to expand on my current regression from last week. All data that I tried to combine would give me an error.
Aside from age and sex there is one thing that seems to effect political views more. Having kids seems to large factor in how people feel politically more so than age or sex. The P value is .001 which is much stronger than .051 with age.
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(DescTools)
##
## Attaching package: 'DescTools'
##
## The following object is masked from 'package:Zelig':
##
## Mode
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(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:Zelig':
##
## combine, summarize
##
## The following object is masked from 'package:MASS':
##
## select
##
## The following object is masked from 'package:stats':
##
## filter
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
library(memisc)
## Loading required package: lattice
##
## Attaching package: 'lattice'
##
## The following object is masked from 'package:boot':
##
## melanoma
##
##
## Attaching package: 'memisc'
##
## The following objects are masked from 'package:dplyr':
##
## collect, query, rename
##
## The following object is masked from 'package:DescTools':
##
## %nin%
##
## The following object is masked from 'package:Zelig':
##
## description
##
## The following objects are masked from 'package:stats':
##
## contr.sum, contr.treatment, contrasts
##
## The following object is masked from 'package:base':
##
## as.array
library(pander)
library(foreign)
library(gmodels)
library(car)
##
## Attaching package: 'car'
##
## The following object is masked from 'package:memisc':
##
## recode
##
## The following object is masked from 'package:DescTools':
##
## Recode
##
## The following object is masked from 'package:boot':
##
## logit
library(visreg)
library(aod)
##
## Attaching package: 'aod'
##
## The following object is masked from 'package:Zelig':
##
## link
GSS = read.spss("C:\\Users\\Robert Johnson\\RSquared\\GSS2014.sav", to.data.frame=TRUE)
## Warning in read.spss("C:\\Users\\Robert Johnson\\RSquared\\GSS2014.sav", :
## C:\Users\Robert Johnson\RSquared\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
polviewschild <- zelig(childs ~ 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
##
stargazer(polviewsage, type = "text")
##
## =============================================
## Dependent variable:
## ---------------------------
## age
## ---------------------------------------------
## polviews -0.051**
## (0.023)
##
## Constant 49.375***
## (0.380)
##
## ---------------------------------------------
## Observations 2,505
## Log Likelihood -10,714.630
## Akaike Inf. Crit. 21,433.260
## =============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
stargazer(polviewschild, type = "text")
##
## =============================================
## Dependent variable:
## ---------------------------
## childs
## ---------------------------------------------
## polviews 0.001
## (0.002)
##
## Constant 1.821***
## (0.035)
##
## ---------------------------------------------
## Observations 2,506
## Log Likelihood -4,772.969
## Akaike Inf. Crit. 9,549.938
## =============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
The below two logistical regressions look at the relationship between race sex and political views, whether or not race or sex is a factor in political views. 1 looks at the relationship between sex and political views. 2 does the same thing but uses age instead of race. 1 has as a lower Akaike so is better to interpret over model 2. According to the chart sex is least likely to be a factor in voting and this is not statistically significant. When race is considered the likelihood of it having an effect on someone’s political views it is 49.9% and is statistically significant. According to the logistical regression race plays a bigger factor in political views than sex.
lmod1<- zelig(sex~ polviews + race, model="logit", data= GSS)
##
##
## How to cite this model in Zelig:
## Kosuke Imai, Gary King, and Olivia Lau. 2015.
## "logit: Logistic Regression for Dichotomous Dependent Variables"
## in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software,"
## http://gking.harvard.edu/zelig
##
lmod2<- zelig(sex~ polviews + age, model="logit", data= GSS)
##
##
## How to cite this model in Zelig:
## Kosuke Imai, Gary King, and Olivia Lau. 2015.
## "logit: Logistic Regression for Dichotomous Dependent Variables"
## in Kosuke Imai, Gary King, and Olivia Lau, "Zelig: Everyone's Statistical Software,"
## http://gking.harvard.edu/zelig
##
stargazer(lmod1, lmod2, type="text")
##
## ==============================================
## Dependent variable:
## ----------------------------
## sex
## (1) (2)
## ----------------------------------------------
## polviews 0.001 0.001
## (0.003) (0.003)
##
## raceBLACK 0.499***
## (0.117)
##
## raceOTHER -0.041
## (0.134)
##
## age 0.001
## (0.002)
##
## Constant 0.124** 0.121
## (0.049) (0.122)
##
## ----------------------------------------------
## Observations 2,514 2,505
## Log Likelihood -1,719.986 -1,723.633
## Akaike Inf. Crit. 3,447.973 3,453.265
## ==============================================
## Note: *p<0.1; **p<0.05; ***p<0.01