The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: survival
library(stargazer)
Please cite as:
Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library(dplyr)
Attaching package: 'dplyr'
The following object is masked from 'package:car':
recode
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(plm)
Attaching package: 'plm'
The following objects are masked from 'package:dplyr':
between, lag, lead
1. Data
dt <-read.csv("Guns.csv")
I have selected the Guns data set. It contains data of crime statistics and other variables such as income, population and population density by state for the years 1977-1999.
Time component: years from 1977 to 1999
Entity component: 50 US. States and D.C.
Variable
Description
Expected Sign
year
factor indicating year
none
state
factor indicating state
none
violent
violent crime rate (incidents per 100,000 of the population)
none
murder
murder rate (incidents per 100,000)
none
robbery
robbery rate (incidents per 100,000)
none
prisoners
incarceration rate in the state in the previous year (sentenced prisoners per 100,000 residients; value for the previous year)
negative
afam
percentage of state population that is African-american, ages 10 to 64
unknown
cauc
percentage of state population that is Caucasian, ages 10 to 64
unknown
male
percentage of state population that is male, ages 10 to 29
positive
population
state population in millions
positive
income
real per capita personal income in the state (US dollars)
negative
density
population per square mile of land area, divided by 1,000
positive
law
factor. Does the state have a shall carry law in effect in that year?
unknown
stargazer(dt,type ="text",title ="Summary Stats")
Summary Stats
==========================================================
Statistic N Mean St. Dev. Min Max
----------------------------------------------------------
year 1,173 1,988.000 6.636 1,977 1,999
violent 1,173 503.075 334.277 47.000 2,921.800
murder 1,173 7.665 7.523 0.200 80.600
robbery 1,173 161.820 170.510 6.400 1,635.100
prisoners 1,173 226.580 178.888 19 1,913
afam 1,173 5.336 4.886 0.248 26.980
cauc 1,173 62.945 9.762 21.780 76.526
male 1,173 16.081 1.732 12.214 22.353
population 1,173 4.816 5.252 0.403 33.145
income 1,173 13,724.800 2,554.542 8,554.884 23,646.710
density 1,173 0.352 1.355 0.001 11.102
----------------------------------------------------------
If the state have a shall carry law in effect, the violent crime rate decreases by 44.3%. This is a very debated topic, although the expected sign is going to vary by people, I think that the magnitude is strangely big. If this was the case, all states should have a shall carry law in effect to prevent violent crimes.
I think there might be committed variable bias. One variable that I can think would affect both crime rate and law is beliefs, is it more of a conservative or liberal state? majority are republican or democrats? elected officials party affiliation, people living in poverty.
Now my coefficients change across the Fixed effects and the regular OLS. The effect is now positive, indicating that the law increases crime rate by 11.4% contrary to the negative sign that the regular OLS was producing.
The fixed effects model is accounting for time invariant characteristics of each entity.
reg5 <-plm(formula =log(violent) ~ law +as.factor(year), data = dt,index =c("state", "year"), model ="within",effect ="twoways") reg6 <-lm(data = dt,formula =log(violent) ~ law + state +as.factor(year))stargazer(reg5,reg6,type ="text")
Now, the FE model is accounting for both time invariant characteristics of each entity and time-variant characteristics affecting all entities. Now, the law is not statistically significant.