## 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
##
##
## 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
##
##
## Attaching package: 'DescTools'
##
## The following object is masked from 'package:Zelig':
##
## Mode
## Warning: package 'dplyr' was built under R version 3.1.3
##
## 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
## Warning: package 'readstata13' was built under R version 3.1.3
For this assignment, I will be using the GSS data that I used on the previous assignment. I am going to start looking at factors that might contribute to gun ownership.
## [1] "CASEID" "WORKBLKS" "RACDIF1" "RACMAR" "RACDIF2" "RACDIF3"
## [7] "HELPBLK" "HELPPOOR" "YEAR" "SEX" "AGE" "RACE"
## [13] "REALINC" "REALRINC" "EDUC" "DEGREE" "PRESTG80" "PAPRES80"
## [19] "MARITAL" "DIVORCE" "CHILDS" "RELIG" "WRKSLF" "UNEMP"
## [25] "REGION" "SIZE" "RACLIVE" "FEAR" "GUN" "POLVIEWS"
## [31] "FECHLD" "FEFAM"
d_sub1<-select(d, EDUC, REGION, POLVIEWS, GUN)
names (d_sub1)
## [1] "EDUC" "REGION" "POLVIEWS" "GUN"
After bringing up the previous data set I created, I needed to code the gun ownership variable as numeric, so that it could be used here.
d_sub1$GUN=as.numeric(d_sub1$GUN)
d_sub1$REGION=as.numeric(d_sub1$REGION)
d_sub1$POLVIEWS=as.numeric(d_sub1$POLVIEWS)
mytable<-table(d_sub1$GUN)
lbls<-paste(names(mytable), "\n", mytable, GUN="")
pie(mytable, labels=lbls, main= "Own a Gun")
The number 2, the smaller section, represents participants who own a gun. The number 3, the larger section, represents participants who do not own a gun.
mytable<-table(d_sub1$REGION)
lbls<-paste(names(mytable), "\n", mytable, REGION="")
pie(mytable, labels=lbls, main= "Region of Residence")
In this pie chart the regions are represented by numbers, as follow, 2=Mid Atlantic, 3=East North Central, 4=West North Central, 5=South Atlantic, 6=East South central, 7=West South Central, 8=Mountain, 9=Pacific, and 10=New England. Based on this pie chart we can see that most respondants come from the East North Central, West North Central, East South Central, and New England regions of the United States.
mytable<-table(d_sub1$POLVIEWS)
lbls<-paste(names(mytable), "\n", mytable, POLVIEWS="")
pie(mytable, labels=lbls, main= "Polical Views")
hist(d_sub1$EDUC)
hist(d_sub1$POLVIEWS)
The first histogram shows us the distribution of education across participants. The distribution skews slightly to the right indicating a large number of participants going on to college studies. However, most of the participants completed their high school education.
The second histogram shows us the political leanings of the participants. Lower numbers indicate more liberal leanings, and higher numbers indicate more conservative leanings. The number 8 here is represented by the response “I don’t know”. The historgram shows us that participants responded most with a rating of 5 which corresponds to considering themselves “slightly conservative”.
m1<- zelig(GUN~EDUC, data=d_sub1, 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
##
m2<- zelig(GUN~REGION, data=d_sub1, 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
##
m3<- zelig(GUN~POLVIEWS, data=d_sub1, 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
##
m4<- zelig(GUN~EDUC+REGION, data=d_sub1, 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
##
m5<- zelig(GUN~EDUC+POLVIEWS, data=d_sub1, 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
##
m6<- zelig(GUN~REGION+POLVIEWS, data=d_sub1, 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
##
m7<- zelig(GUN~EDUC+POLVIEWS+REGION, data=d_sub1, 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(m1, m2, m3, m4, m5, m6, m7, type="text")
##
## ==============================================================================================
## Dependent variable:
## ----------------------------------------------------------------------------
## GUN
## (1) (2) (3) (4) (5) (6) (7)
## ----------------------------------------------------------------------------------------------
## EDUC 0.0005 0.001 0.001 0.002*
## (0.001) (0.001) (0.001) (0.001)
##
## REGION -0.011*** -0.011*** -0.011*** -0.011***
## (0.001) (0.001) (0.001) (0.001)
##
## POLVIEWS 0.009*** 0.009*** 0.009*** 0.009***
## (0.002) (0.002) (0.002) (0.002)
##
## Constant 2.798*** 2.869*** 2.753*** 2.860*** 2.734*** 2.814*** 2.791***
## (0.011) (0.007) (0.013) (0.013) (0.018) (0.015) (0.020)
##
## ----------------------------------------------------------------------------------------------
## Observations 19,276 19,328 16,174 19,276 16,146 16,174 16,146
## Log Likelihood -9,521.792 -9,497.641 -8,198.922 -9,476.484 -8,183.011 -8,163.665 -8,147.754
## Akaike Inf. Crit. 19,047.580 18,999.280 16,401.840 18,958.970 16,372.020 16,333.330 16,303.510
## ==============================================================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
This table shows us what variables contribute to owning a gun. Based on the models, education alone does not contribute to gun ownership, nor does it contribute to gun ownership with combined with region or political views. Political views do contribute to owning a gun. The more conservative leaning the participant, the more likely they are to own a gun, across all models. In addition, region significantly contributes to gun ownership. However, based on the categorical nature of this variable the relationship is unclear. Perhaps this variable needs to be coded differently. Lastly, in the inclusive model which looks at education, region, and political view significant findings tell us that those who have more education, conservative political leanings, and come from a certain region are more likely to own guns. Again, the region variable needs to be looked at more completely to parse out the results.