Discussion_6

Author

Angelo Marinaro

#Packages list
library(AER)
Loading required package: car
Loading required package: carData
Loading required package: lmtest
Loading required package: zoo

Attaching package: 'zoo'
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  
----------------------------------------------------------
state_counts <- table(dt$state)


state_counts_df <- data.frame(State = names(state_counts),
                              Count = as.vector(state_counts))

print(state_counts_df)
                  State Count
1               Alabama    23
2                Alaska    23
3               Arizona    23
4              Arkansas    23
5            California    23
6              Colorado    23
7           Connecticut    23
8              Delaware    23
9  District of Columbia    23
10              Florida    23
11              Georgia    23
12               Hawaii    23
13                Idaho    23
14             Illinois    23
15              Indiana    23
16                 Iowa    23
17               Kansas    23
18             Kentucky    23
19            Louisiana    23
20                Maine    23
21             Maryland    23
22        Massachusetts    23
23             Michigan    23
24            Minnesota    23
25          Mississippi    23
26             Missouri    23
27              Montana    23
28             Nebraska    23
29               Nevada    23
30        New Hampshire    23
31           New Jersey    23
32           New Mexico    23
33             New York    23
34       North Carolina    23
35         North Dakota    23
36                 Ohio    23
37             Oklahoma    23
38               Oregon    23
39         Pennsylvania    23
40         Rhode Island    23
41       South Carolina    23
42         South Dakota    23
43            Tennessee    23
44                Texas    23
45                 Utah    23
46              Vermont    23
47             Virginia    23
48           Washington    23
49        West Virginia    23
50            Wisconsin    23
51              Wyoming    23

It looks like it is a balanced. If we multiply \(23 \ *\ 51 = 1173\)

2. OLS regression

\[ log(violent_i) = \beta_0 + \beta_1 \ law_i + \epsilon_i \]

reg1 <- lm(data = dt,
           formula = log(violent) ~ law)

stargazer(reg1,
          type = "text")

===============================================
                        Dependent variable:    
                    ---------------------------
                           log(violent)        
-----------------------------------------------
lawyes                       -0.443***         
                              (0.042)          
                                               
Constant                     6.135***          
                              (0.021)          
                                               
-----------------------------------------------
Observations                   1,173           
R2                             0.087           
Adjusted R2                    0.086           
Residual Std. Error      0.617 (df = 1171)     
F Statistic          111.079*** (df = 1; 1171) 
===============================================
Note:               *p<0.1; **p<0.05; ***p<0.01
  • 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.

3. Fixed effects model

OLS with dummy variables

\[ \begin{align*} \\ log(violent_{it}) = \beta_0 + \beta_1 \ law_{it} + \gamma_2 \ state\ 2_i + ... + \gamma_{51} state \ 51_i + u_{it} \end{align*} \]

reg2 <- lm(data = dt,
           formula = log(violent) ~ law + state)
stargazer(reg2,
          type = "text")

=====================================================
                              Dependent variable:    
                          ---------------------------
                                 log(violent)        
-----------------------------------------------------
lawyes                             0.114***          
                                    (0.017)          
                                                     
stateAlaska                          0.053           
                                    (0.053)          
                                                     
stateArizona                         0.082           
                                    (0.053)          
                                                     
stateArkansas                      -0.262***         
                                    (0.052)          
                                                     
stateCalifornia                    0.468***          
                                    (0.052)          
                                                     
stateColorado                      -0.127**          
                                    (0.052)          
                                                     
stateConnecticut                   -0.268***         
                                    (0.052)          
                                                     
stateDelaware                        0.015           
                                    (0.052)          
                                                     
stateDistrict of Columbia          1.303***          
                                    (0.052)          
                                                     
stateFlorida                       0.538***          
                                    (0.053)          
                                                     
stateGeorgia                         0.029           
                                    (0.053)          
                                                     
stateHawaii                        -0.743***         
                                    (0.052)          
                                                     
stateIdaho                         -0.777***         
                                    (0.053)          
                                                     
stateIllinois                      0.413***          
                                    (0.052)          
                                                     
stateIndiana                       -0.444***         
                                    (0.055)          
                                                     
stateIowa                          -0.816***         
                                    (0.052)          
                                                     
stateKansas                        -0.337***         
                                    (0.052)          
                                                     
stateKentucky                      -0.523***         
                                    (0.052)          
                                                     
stateLouisiana                     0.302***          
                                    (0.053)          
                                                     
stateMaine                         -1.368***         
                                    (0.054)          
                                                     
stateMaryland                      0.447***          
                                    (0.052)          
                                                     
stateMassachusetts                  0.115**          
                                    (0.052)          
                                                     
stateMichigan                      0.240***          
                                    (0.052)          
                                                     
stateMinnesota                     -0.694***         
                                    (0.052)          
                                                     
stateMississippi                   -0.490***         
                                    (0.053)          
                                                     
stateMissouri                        0.056           
                                    (0.052)          
                                                     
stateMontana                       -1.150***         
                                    (0.053)          
                                                     
stateNebraska                      -0.634***         
                                    (0.052)          
                                                     
stateNevada                        0.298***          
                                    (0.052)          
                                                     
stateNew Hampshire                 -1.548***         
                                    (0.055)          
                                                     
stateNew Jersey                      0.007           
                                    (0.052)          
                                                     
stateNew Mexico                    0.299***          
                                    (0.052)          
                                                     
stateNew York                      0.533***          
                                    (0.052)          
                                                     
stateNorth Carolina                 -0.068           
                                    (0.052)          
                                                     
stateNorth Dakota                  -2.165***         
                                    (0.053)          
                                                     
stateOhio                          -0.207***         
                                    (0.052)          
                                                     
stateOklahoma                      -0.140***         
                                    (0.052)          
                                                     
stateOregon                        -0.139***         
                                    (0.053)          
                                                     
statePennsylvania                  -0.407***         
                                    (0.053)          
                                                     
stateRhode Island                  -0.393***         
                                    (0.052)          
                                                     
stateSouth Carolina                0.354***          
                                    (0.052)          
                                                     
stateSouth Dakota                  -1.335***         
                                    (0.053)          
                                                     
stateTennessee                       0.008           
                                    (0.053)          
                                                     
stateTexas                          0.089*           
                                    (0.052)          
                                                     
stateUtah                          -0.720***         
                                    (0.053)          
                                                     
stateVermont                       -1.532***         
                                    (0.055)          
                                                     
stateVirginia                      -0.544***         
                                    (0.052)          
                                                     
stateWashington                    -0.313***         
                                    (0.055)          
                                                     
stateWest Virginia                 -1.130***         
                                    (0.053)          
                                                     
stateWisconsin                     -0.903***         
                                    (0.052)          
                                                     
stateWyoming                       -0.674***         
                                    (0.053)          
                                                     
Constant                           6.298***          
                                    (0.037)          
                                                     
-----------------------------------------------------
Observations                         1,173           
R2                                   0.928           
Adjusted R2                          0.924           
Residual Std. Error            0.178 (df = 1121)     
F Statistic               281.704*** (df = 51; 1121) 
=====================================================
Note:                     *p<0.1; **p<0.05; ***p<0.01

Within method

\[ \tilde{violent_{it}} = \beta_1 \ \tilde{law_{it}} + \tilde{u_{it}} \]

reg4 <- plm(formula = log(violent) ~ law, 
                    data    = dt,
                    index   = c("state", "year"), 
                    model   = "within")

stargazer(reg4,
          type = "text")

========================================
                 Dependent variable:    
             ---------------------------
                    log(violent)        
----------------------------------------
lawyes                0.114***          
                       (0.017)          
                                        
----------------------------------------
Observations            1,173           
R2                      0.039           
Adjusted R2            -0.005           
F Statistic   45.080*** (df = 1; 1121)  
========================================
Note:        *p<0.1; **p<0.05; ***p<0.01

Comparison

stargazer(reg1,reg2,reg4,
          type = "text")

=======================================================================================================
                                                       Dependent variable:                             
                          -----------------------------------------------------------------------------
                                                          log(violent)                                 
                                                  OLS                                   panel          
                                                                                        linear         
                                     (1)                       (2)                       (3)           
-------------------------------------------------------------------------------------------------------
lawyes                            -0.443***                  0.114***                  0.114***        
                                   (0.042)                   (0.017)                   (0.017)         
                                                                                                       
stateAlaska                                                   0.053                                    
                                                             (0.053)                                   
                                                                                                       
stateArizona                                                  0.082                                    
                                                             (0.053)                                   
                                                                                                       
stateArkansas                                               -0.262***                                  
                                                             (0.052)                                   
                                                                                                       
stateCalifornia                                              0.468***                                  
                                                             (0.052)                                   
                                                                                                       
stateColorado                                                -0.127**                                  
                                                             (0.052)                                   
                                                                                                       
stateConnecticut                                            -0.268***                                  
                                                             (0.052)                                   
                                                                                                       
stateDelaware                                                 0.015                                    
                                                             (0.052)                                   
                                                                                                       
stateDistrict of Columbia                                    1.303***                                  
                                                             (0.052)                                   
                                                                                                       
stateFlorida                                                 0.538***                                  
                                                             (0.053)                                   
                                                                                                       
stateGeorgia                                                  0.029                                    
                                                             (0.053)                                   
                                                                                                       
stateHawaii                                                 -0.743***                                  
                                                             (0.052)                                   
                                                                                                       
stateIdaho                                                  -0.777***                                  
                                                             (0.053)                                   
                                                                                                       
stateIllinois                                                0.413***                                  
                                                             (0.052)                                   
                                                                                                       
stateIndiana                                                -0.444***                                  
                                                             (0.055)                                   
                                                                                                       
stateIowa                                                   -0.816***                                  
                                                             (0.052)                                   
                                                                                                       
stateKansas                                                 -0.337***                                  
                                                             (0.052)                                   
                                                                                                       
stateKentucky                                               -0.523***                                  
                                                             (0.052)                                   
                                                                                                       
stateLouisiana                                               0.302***                                  
                                                             (0.053)                                   
                                                                                                       
stateMaine                                                  -1.368***                                  
                                                             (0.054)                                   
                                                                                                       
stateMaryland                                                0.447***                                  
                                                             (0.052)                                   
                                                                                                       
stateMassachusetts                                           0.115**                                   
                                                             (0.052)                                   
                                                                                                       
stateMichigan                                                0.240***                                  
                                                             (0.052)                                   
                                                                                                       
stateMinnesota                                              -0.694***                                  
                                                             (0.052)                                   
                                                                                                       
stateMississippi                                            -0.490***                                  
                                                             (0.053)                                   
                                                                                                       
stateMissouri                                                 0.056                                    
                                                             (0.052)                                   
                                                                                                       
stateMontana                                                -1.150***                                  
                                                             (0.053)                                   
                                                                                                       
stateNebraska                                               -0.634***                                  
                                                             (0.052)                                   
                                                                                                       
stateNevada                                                  0.298***                                  
                                                             (0.052)                                   
                                                                                                       
stateNew Hampshire                                          -1.548***                                  
                                                             (0.055)                                   
                                                                                                       
stateNew Jersey                                               0.007                                    
                                                             (0.052)                                   
                                                                                                       
stateNew Mexico                                              0.299***                                  
                                                             (0.052)                                   
                                                                                                       
stateNew York                                                0.533***                                  
                                                             (0.052)                                   
                                                                                                       
stateNorth Carolina                                           -0.068                                   
                                                             (0.052)                                   
                                                                                                       
stateNorth Dakota                                           -2.165***                                  
                                                             (0.053)                                   
                                                                                                       
stateOhio                                                   -0.207***                                  
                                                             (0.052)                                   
                                                                                                       
stateOklahoma                                               -0.140***                                  
                                                             (0.052)                                   
                                                                                                       
stateOregon                                                 -0.139***                                  
                                                             (0.053)                                   
                                                                                                       
statePennsylvania                                           -0.407***                                  
                                                             (0.053)                                   
                                                                                                       
stateRhode Island                                           -0.393***                                  
                                                             (0.052)                                   
                                                                                                       
stateSouth Carolina                                          0.354***                                  
                                                             (0.052)                                   
                                                                                                       
stateSouth Dakota                                           -1.335***                                  
                                                             (0.053)                                   
                                                                                                       
stateTennessee                                                0.008                                    
                                                             (0.053)                                   
                                                                                                       
stateTexas                                                    0.089*                                   
                                                             (0.052)                                   
                                                                                                       
stateUtah                                                   -0.720***                                  
                                                             (0.053)                                   
                                                                                                       
stateVermont                                                -1.532***                                  
                                                             (0.055)                                   
                                                                                                       
stateVirginia                                               -0.544***                                  
                                                             (0.052)                                   
                                                                                                       
stateWashington                                             -0.313***                                  
                                                             (0.055)                                   
                                                                                                       
stateWest Virginia                                          -1.130***                                  
                                                             (0.053)                                   
                                                                                                       
stateWisconsin                                              -0.903***                                  
                                                             (0.052)                                   
                                                                                                       
stateWyoming                                                -0.674***                                  
                                                             (0.053)                                   
                                                                                                       
Constant                          6.135***                   6.298***                                  
                                   (0.021)                   (0.037)                                   
                                                                                                       
-------------------------------------------------------------------------------------------------------
Observations                        1,173                     1,173                     1,173          
R2                                  0.087                     0.928                     0.039          
Adjusted R2                         0.086                     0.924                     -0.005         
Residual Std. Error           0.617 (df = 1171)         0.178 (df = 1121)                              
F Statistic               111.079*** (df = 1; 1171) 281.704*** (df = 51; 1121) 45.080*** (df = 1; 1121)
=======================================================================================================
Note:                                                                       *p<0.1; **p<0.05; ***p<0.01

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.

Both time and entity FE

\[ log(violent_{it}) = \beta_1 \ law_{it} + \alpha_i + \lambda_t + u_{it} \]

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")                    

=========================================================================
                                        Dependent variable:              
                          -----------------------------------------------
                                           log(violent)                  
                                 panel                    OLS            
                                 linear                                  
                                  (1)                     (2)            
-------------------------------------------------------------------------
lawyes                           0.002                   0.002           
                                (0.017)                 (0.017)          
                                                                         
stateAlaska                                              0.078*          
                                                        (0.043)          
                                                                         
stateArizona                                            0.106**          
                                                        (0.043)          
                                                                         
stateArkansas                                          -0.243***         
                                                        (0.042)          
                                                                         
stateCalifornia                                         0.468***         
                                                        (0.042)          
                                                                         
stateColorado                                          -0.127***         
                                                        (0.042)          
                                                                         
stateConnecticut                                       -0.268***         
                                                        (0.042)          
                                                                         
stateDelaware                                            0.015           
                                                        (0.042)          
                                                                         
stateDistrict of Columbia                               1.303***         
                                                        (0.042)          
                                                                         
stateFlorida                                            0.597***         
                                                        (0.043)          
                                                                         
stateGeorgia                                             0.077*          
                                                        (0.043)          
                                                                         
stateHawaii                                            -0.743***         
                                                        (0.042)          
                                                                         
stateIdaho                                             -0.734***         
                                                        (0.043)          
                                                                         
stateIllinois                                           0.413***         
                                                        (0.042)          
                                                                         
stateIndiana                                           -0.332***         
                                                        (0.046)          
                                                                         
stateIowa                                              -0.816***         
                                                        (0.042)          
                                                                         
stateKansas                                            -0.337***         
                                                        (0.042)          
                                                                         
stateKentucky                                          -0.508***         
                                                        (0.042)          
                                                                         
stateLouisiana                                          0.341***         
                                                        (0.043)          
                                                                         
stateMaine                                             -1.281***         
                                                        (0.044)          
                                                                         
stateMaryland                                           0.447***         
                                                        (0.042)          
                                                                         
stateMassachusetts                                      0.115***         
                                                        (0.042)          
                                                                         
stateMichigan                                           0.240***         
                                                        (0.042)          
                                                                         
stateMinnesota                                         -0.694***         
                                                        (0.042)          
                                                                         
stateMississippi                                       -0.447***         
                                                        (0.043)          
                                                                         
stateMissouri                                            0.056           
                                                        (0.042)          
                                                                         
stateMontana                                           -1.111***         
                                                        (0.043)          
                                                                         
stateNebraska                                          -0.634***         
                                                        (0.042)          
                                                                         
stateNevada                                             0.317***         
                                                        (0.042)          
                                                                         
stateNew Hampshire                                     -1.436***         
                                                        (0.046)          
                                                                         
stateNew Jersey                                          0.007           
                                                        (0.042)          
                                                                         
stateNew Mexico                                         0.299***         
                                                        (0.042)          
                                                                         
stateNew York                                           0.533***         
                                                        (0.042)          
                                                                         
stateNorth Carolina                                      -0.049          
                                                        (0.042)          
                                                                         
stateNorth Dakota                                      -2.097***         
                                                        (0.044)          
                                                                         
stateOhio                                              -0.207***         
                                                        (0.042)          
                                                                         
stateOklahoma                                          -0.120***         
                                                        (0.042)          
                                                                         
stateOregon                                             -0.095**         
                                                        (0.043)          
                                                                         
statePennsylvania                                      -0.358***         
                                                        (0.043)          
                                                                         
stateRhode Island                                      -0.393***         
                                                        (0.042)          
                                                                         
stateSouth Carolina                                     0.368***         
                                                        (0.042)          
                                                                         
stateSouth Dakota                                      -1.267***         
                                                        (0.044)          
                                                                         
stateTennessee                                           0.032           
                                                        (0.043)          
                                                                         
stateTexas                                              0.103**          
                                                        (0.042)          
                                                                         
stateUtah                                              -0.657***         
                                                        (0.043)          
                                                                         
stateVermont                                           -1.421***         
                                                        (0.046)          
                                                                         
stateVirginia                                          -0.525***         
                                                        (0.042)          
                                                                         
stateWashington                                        -0.201***         
                                                        (0.046)          
                                                                         
stateWest Virginia                                     -1.081***         
                                                        (0.043)          
                                                                         
stateWisconsin                                         -0.903***         
                                                        (0.042)          
                                                                         
stateWyoming                                           -0.650***         
                                                        (0.043)          
                                                                         
as.factor(year)1978                                      0.048*          
                                                        (0.028)          
                                                                         
as.factor(year)1979                                     0.144***         
                                                        (0.028)          
                                                                         
as.factor(year)1980                                     0.188***         
                                                        (0.028)          
                                                                         
as.factor(year)1981                                     0.177***         
                                                        (0.028)          
                                                                         
as.factor(year)1982                                     0.136***         
                                                        (0.028)          
                                                                         
as.factor(year)1983                                     0.078***         
                                                        (0.028)          
                                                                         
as.factor(year)1984                                     0.089***         
                                                        (0.028)          
                                                                         
as.factor(year)1985                                     0.116***         
                                                        (0.028)          
                                                                         
as.factor(year)1986                                     0.170***         
                                                        (0.028)          
                                                                         
as.factor(year)1987                                     0.147***         
                                                        (0.028)          
                                                                         
as.factor(year)1988                                     0.187***         
                                                        (0.029)          
                                                                         
as.factor(year)1989                                     0.223***         
                                                        (0.029)          
                                                                         
as.factor(year)1990                                     0.323***         
                                                        (0.029)          
                                                                         
as.factor(year)1991                                     0.357***         
                                                        (0.029)          
                                                                         
as.factor(year)1992                                     0.375***         
                                                        (0.029)          
                                                                         
as.factor(year)1993                                     0.386***         
                                                        (0.029)          
                                                                         
as.factor(year)1994                                     0.362***         
                                                        (0.029)          
                                                                         
as.factor(year)1995                                     0.347***         
                                                        (0.029)          
                                                                         
as.factor(year)1996                                     0.285***         
                                                        (0.029)          
                                                                         
as.factor(year)1997                                     0.261***         
                                                        (0.030)          
                                                                         
as.factor(year)1998                                     0.206***         
                                                        (0.030)          
                                                                         
as.factor(year)1999                                     0.146***         
                                                        (0.030)          
                                                                         
Constant                                                6.091***         
                                                        (0.036)          
                                                                         
-------------------------------------------------------------------------
Observations                     1,173                   1,173           
R2                              0.00001                  0.954           
Adjusted R2                      -0.066                  0.950           
Residual Std. Error                                0.144 (df = 1099)     
F Statistic               0.013 (df = 1; 1099) 309.158*** (df = 73; 1099)
=========================================================================
Note:                                         *p<0.1; **p<0.05; ***p<0.01

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.