R Markdown file

Q1

1.In April 2008 the unemployment rate in the United States stood at 5.0%. By April 2009 it had increased to 9.0%, and it had increased further, to 10.0%, by October 2009.

You will find the data file Employment_08_09 attached with this email, which contains a random sample of 5440 workers who were surveyed in April 2008 and reported that they were employed full time. A detailed description is given in Employment_08_09_Description file. These workers were surveyed one year later, in April 2009, and asked about their employment status (employed, unemployed, or out of the labor force). The data set also includes various demographic measures for each individual.

a) Use the dataset to model the determinants of Employed.

Ans

emp_table= read.csv("employment_08_09.csv")
names(emp_table)
##  [1] "age"          "race"         "earnwke"      "employed"     "unemployed"  
##  [6] "married"      "union"        "ne_states"    "so_states"    "ce_states"   
## [11] "we_states"    "government"   "private"      "self"         "educ_lths"   
## [16] "educ_hs"      "educ_somecol" "educ_aa"      "educ_bac"     "educ_adv"    
## [21] "female"

First we will remove unemployed column and then design a model with employed as a dependant variable and all other as independent variable

emp<- subset(emp_table,select= -c(unemployed))
model1= glm(employed~.,data=emp,family="binomial")
summary(model1)
## 
## Call:
## glm(formula = employed ~ ., family = "binomial", data = emp)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.7391   0.3817   0.4799   0.5557   0.9794  
## 
## Coefficients: (4 not defined because of singularities)
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   1.2040072  0.2841790   4.237 2.27e-05 ***
## age           0.0059357  0.0039919   1.487  0.13703    
## race         -0.0464200  0.0753398  -0.616  0.53780    
## earnwke       0.0005843  0.0001096   5.330 9.81e-08 ***
## married       0.1175285  0.0945774   1.243  0.21399    
## union        -0.6221243  0.1281222  -4.856 1.20e-06 ***
## ne_states     0.1533743  0.1298602   1.181  0.23757    
## so_states     0.1254839  0.1185703   1.058  0.28992    
## ce_states     0.3931101  0.1301290   3.021  0.00252 ** 
## we_states            NA         NA      NA       NA    
## government    0.3241934  0.1308627   2.477  0.01324 *  
## private              NA         NA      NA       NA    
## self                 NA         NA      NA       NA    
## educ_lths    -0.5032669  0.2182455  -2.306  0.02111 *  
## educ_hs      -0.0930431  0.1804612  -0.516  0.60614    
## educ_somecol -0.0068240  0.1880924  -0.036  0.97106    
## educ_aa       0.2059430  0.2152291   0.957  0.33864    
## educ_bac     -0.0777904  0.1798429  -0.433  0.66534    
## educ_adv             NA         NA      NA       NA    
## female       -0.0362734  0.0937104  -0.387  0.69870    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 3594.2  on 4772  degrees of freedom
## Residual deviance: 3479.6  on 4757  degrees of freedom
##   (639 observations deleted due to missingness)
## AIC: 3511.6
## 
## Number of Fisher Scoring iterations: 5
  • On regressing employment (employed) as a dependent variable with all the other variables excpt “unemployed” as a independent variable. It can be concluded from the model that employment in April 2009 is signficantally dependent on earnwke (1%), union(1%), ce_states(5%), educl_ths(10%) and government(10%)

  • The log odds of a person is employed whose average weekly earnings(earnwke) increases by 1 unit is expected to increase by .0.0005843, which can be converted to odds –> exp(.0005843) = 1.0005844. That is, the odds of a person is employed increases by 1.0005844.

  • The log odds of a person is employed in April 2009 given that he is a member of a union is expected to decrease by 0.6221243, which can be converted to odds –> exp(0.6221243) = 1.862. That is, the odds of a person is employed decreases by 1.862.

  • The log odds of a person is employed in April 2009 given that he is from central state is expected to increase by 0.39311, which can be converted to odds –> exp(0.39311) = 1.481. That is, the odds of a person is employed increases by 1.481.

The four variables whose coff and other parameters is NA, are correlated with other IV and there inclusion or exclusion doesn’t affect the findings of the model.

b) Use the regressions to discuss the characteristics of workers who were hurt most by the Great Recession.

In this we will remove employed column and then design a model with unemployed as a dependant variable and all other as independent variable

unemp<- subset(emp_table,select= -c(employed))
model2= glm(unemployed~.,data=unemp,family="binomial")
summary(model2)
## 
## Call:
## glm(formula = unemployed ~ ., family = "binomial", data = unemp)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.7344  -0.3543  -0.2899  -0.2096   3.2340  
## 
## Coefficients: (4 not defined because of singularities)
##                Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  -2.5881339  0.4592125  -5.636 1.74e-08 ***
## age           0.0028027  0.0061165   0.458  0.64679    
## race          0.0654106  0.1151866   0.568  0.57013    
## earnwke      -0.0002189  0.0001529  -1.431  0.15231    
## married      -0.3649877  0.1446854  -2.523  0.01165 *  
## union         0.4012370  0.2093985   1.916  0.05535 .  
## ne_states    -0.4324184  0.2085682  -2.073  0.03815 *  
## so_states    -0.1398996  0.1787341  -0.783  0.43379    
## ce_states    -0.3135712  0.1944757  -1.612  0.10688    
## we_states            NA         NA      NA       NA    
## government   -1.7114917  0.3389927  -5.049 4.45e-07 ***
## private              NA         NA      NA       NA    
## self                 NA         NA      NA       NA    
## educ_lths     0.9147459  0.3544147   2.581  0.00985 ** 
## educ_hs       0.4943808  0.3131599   1.579  0.11441    
## educ_somecol  0.1312873  0.3313591   0.396  0.69195    
## educ_aa      -0.0390540  0.3720514  -0.105  0.91640    
## educ_bac      0.2192801  0.3209544   0.683  0.49447    
## educ_adv             NA         NA      NA       NA    
## female       -0.4173813  0.1463844  -2.851  0.00435 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 1843.8  on 4772  degrees of freedom
## Residual deviance: 1742.3  on 4757  degrees of freedom
##   (639 observations deleted due to missingness)
## AIC: 1774.3
## 
## Number of Fisher Scoring iterations: 7
  • On regressing unemployment (unemployed) as a dependent variable with all the other variables excpt “employed” as a independent variable. It can be concluded from the model2 that unemployment in April 2009 is signficantally dependent on married (10%), government(1%), ne_states(10%), educl_ths(5%) and female(5%)

  • The log odds of a person is unemployed in April 2009 given that he/she is a married is expected to decrease by 0.3649877, which can be converted to odds –> exp(0.364987) = 1.4404. That is, the odds of a person is unemployed decreases by 1.4404.

  • The log odds of a person is unemployed in April 2009 given that he is employed by the government is expected to decrease by 1.7114917, which can be converted to odds –> exp(1.71149) = 5.5372. That is, the odds of a person is unemployed decreases by 5.5372.

  • The log odds of a person is unemployed in April 2009 given that his/her highest level of education is less than a high school graduate is expected to increase by 0.9147459, which can be converted to odds –> exp(0.9147459) = 2.496. That is, the odds of a person is unemployed increases by 2.496.

  • The log odds of a person is unemployed in Aplril 2009 given that the person is female is expected to decrease by 0.417338, which can be converted to odds –> exp(0.6221243) = 1.862. That is, the odds of a person is unemployed decreases by 1.862.

Q2

2.Do citizens demand more democracy and political freedom as their incomes grow? i.e., is democracy a normal good? The data file Income_Democracy, which contains a panel data set from 195 countries for the years 1960, 1965, . . . , 2000 is attached with the email. A detailed description is given in Income_Democracy_Description. The dataset contains an index of political freedom/democracy for each country in each year, together with data on the country’s income and various demographic controls.

Based on your analysis, what conclusions do you draw about the effects of income on democracy?

Ans

We will read the csv file then convert the data into panal form and then use plm function to analyse the panal data model.

First we will use pooled model regression

library(plm)
## Warning: package 'plm' was built under R version 4.0.2
income= read.csv("income_democracy.csv")
names(income)
##  [1] "country"    "year"       "dem_ind"    "log_gdppc"  "log_pop"   
##  [6] "age_1"      "age_2"      "age_3"      "age_4"      "age_5"     
## [11] "educ"       "age_median" "code"
pdata<-pdata.frame(income,index=c("code","year"))
pooled<-plm(dem_ind~log_gdppc+log_pop+educ+age_median+age_1+age_2+
              age_3+age_4+age_5,data=pdata,model="pooling")
summary(pooled)
## Pooling Model
## 
## Call:
## plm(formula = dem_ind ~ log_gdppc + log_pop + educ + age_median + 
##     age_1 + age_2 + age_3 + age_4 + age_5, data = pdata, model = "pooling")
## 
## Unbalanced Panel: n = 95, T = 1-8, N = 679
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.7292940 -0.1702722  0.0050744  0.1742260  0.6671328 
## 
## Coefficients:
##                Estimate  Std. Error t-value  Pr(>|t|)    
## (Intercept)  2.1079e+05  1.4680e+05  1.4359    0.1515    
## log_gdppc    1.2088e-01  2.0213e-02  5.9803 3.626e-09 ***
## log_pop     -1.0271e-02  6.5739e-03 -1.5624    0.1187    
## educ         3.2376e-02  6.9735e-03  4.6427 4.140e-06 ***
## age_median   9.2906e-03  1.7428e-02  0.5331    0.5941    
## age_1       -2.1079e+05  1.4680e+05 -1.4359    0.1515    
## age_2       -2.1079e+05  1.4680e+05 -1.4359    0.1515    
## age_3       -2.1079e+05  1.4680e+05 -1.4359    0.1515    
## age_4       -2.1079e+05  1.4680e+05 -1.4359    0.1515    
## age_5       -2.1079e+05  1.4680e+05 -1.4359    0.1515    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    84.23
## Residual Sum of Squares: 41.864
## R-Squared:      0.50297
## Adj. R-Squared: 0.49629
## F-statistic: 75.2231 on 9 and 669 DF, p-value: < 2.22e-16

There is a significant positive relation between index of democracy and log of GDP per capta of a particular country. Specifically on average 1% increase in GDP of a country, the index of democracy of its citizens increases by 1.2088/e units i.e 0.444 units.

Now we will use fixed and random effect model

attach(pdata)
X<- cbind(log_gdppc,educ,age_median,age_3)
within<-plm(dem_ind~X,data=pdata,model="within")
random<-plm(dem_ind~X,data=pdata,model="random")

Hausman test to identify which model to use.

Our null hypothesis is : Preferred model is the ramdom effect model

phtest(random,within)
## 
##  Hausman Test
## 
## data:  dem_ind ~ X
## chisq = 18.088, df = 4, p-value = 0.001186
## alternative hypothesis: one model is inconsistent

Since p value comes out to be less than 0.05 we will reject the null hypothesis and use FE model i.e “within” model

summary(within)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = dem_ind ~ X, data = pdata, model = "within")
## 
## Unbalanced Panel: n = 95, T = 1-8, N = 679
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -0.5819239 -0.0924471  0.0037669  0.1013702  0.5542269 
## 
## Coefficients:
##               Estimate Std. Error t-value  Pr(>|t|)    
## Xlog_gdppc  -0.0326337  0.0398281 -0.8194 0.4129146    
## Xeduc        0.0460580  0.0117798  3.9099 0.0001033 ***
## Xage_median  0.0213791  0.0091385  2.3395 0.0196498 *  
## Xage_3      -2.3119238  0.8192815 -2.8219 0.0049378 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    25.846
## Residual Sum of Squares: 24.125
## R-Squared:      0.066565
## Adj. R-Squared: -0.091153
## F-statistic: 10.3402 on 4 and 580 DF, p-value: 4.2849e-08

There is no significant relation between index of democracy and log of GDP per capta of a particular country.

But there are control variables such as average years of education and fraction of population between age 30-44 will have a significant positive and negative relationship respectively with index of democracy of a country.

Q3

3.Does viewing a violent movie lead to violent behavior? If so, the incidence of violent crimes, such as assaults, should rise following the release of a violent movie that attracts many viewers. Alternatively, movie viewing may substitute for other activities (such as alcohol consumption) that lead to violent behavior, so that assaults should fall when more viewers are attracted to the cinema. You will find the data file Movies, attached to the email which contains data on the number of assaults and movie attendance for 516 weekends from 1995 through 2004.5 A detailed description is given in Movies_Description. The dataset includes weekend U.S. attendance for strongly violent movies (such as Hannibal), mildly violent movies (such as Spider-Man), and nonviolent movies (such as Finding Nemo). The dataset also includes a count of the number of assaults for the same weekend in a subset of counties in the United States. Finally, the dataset includes indicators for year, month, whether the weekend is a holiday, and various measures of the weather.

Model ln_assaults. Based on the regression, does viewing a strongly violent movie increase or decrease assaults?

Ans.

First we will load the dynlm package used for dynamic linear and time series regression and then read the csv file

library(dynlm)
## Warning: package 'dynlm' was built under R version 4.0.2
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.0.2
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
movies<-read.csv("movies.csv")
names(movies)
##  [1] "wkd_ind"     "assaults"    "attend_v"    "attend_m"    "attend_n"   
##  [6] "pr_attend_v" "pr_attend_m" "pr_attend_n" "attend_v_f"  "attend_m_f" 
## [11] "attend_n_f"  "attend_v_b"  "attend_m_b"  "attend_n_b"  "h_chris"    
## [16] "h_newyr"     "h_easter"    "h_july4"     "h_mem"       "h_labor"    
## [21] "w_maxa"      "w_maxb"      "w_maxc"      "w_mina"      "w_minb"     
## [26] "w_minc"      "w_rain"      "w_snow"      "year1"       "year2"      
## [31] "year3"       "year4"       "year5"       "year6"       "year7"      
## [36] "year8"       "year9"       "year10"      "month1"      "month2"     
## [41] "month3"      "month4"      "month5"      "month6"      "month7"     
## [46] "month8"      "month9"      "month10"     "month11"     "month12"

Now we will convert the data into time series data using ts function and then apply dynlm function to analyse time series model

tsdata<-ts(movies, start=c(1995),frequency =52)
assaults <-dynlm(log(assaults)~attend_v+attend_m+attend_n+pr_attend_v
                 +pr_attend_m+pr_attend_n+attend_v_b+attend_n_b+attend_m_b
                 +attend_v_f+attend_m_f+attend_n_f+h_chris+h_newyr+h_easter
                 +h_july4+h_mem+h_labor,data=tsdata)

summary(assaults)
## 
## Time series regression with "ts" data:
## Start = 1995(1), End = 2004(48)
## 
## Call:
## dynlm(formula = log(assaults) ~ attend_v + attend_m + attend_n + 
##     pr_attend_v + pr_attend_m + pr_attend_n + attend_v_b + attend_n_b + 
##     attend_m_b + attend_v_f + attend_m_f + attend_n_f + h_chris + 
##     h_newyr + h_easter + h_july4 + h_mem + h_labor, data = tsdata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.6129 -0.3190  0.1281  0.4211  1.2076 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.302603   0.131446  55.556  < 2e-16 ***
## attend_v     0.168081   0.046938   3.581 0.000376 ***
## attend_m     0.026546   0.023641   1.123 0.262035    
## attend_n    -0.054034   0.021290  -2.538 0.011453 *  
## pr_attend_v -0.161894   0.044344  -3.651 0.000289 ***
## pr_attend_m -0.010093   0.022968  -0.439 0.660539    
## pr_attend_n  0.067106   0.021306   3.150 0.001734 ** 
## attend_v_b   0.013990   0.014797   0.945 0.344871    
## attend_n_b   0.016113   0.008646   1.864 0.062960 .  
## attend_m_b   0.027554   0.008558   3.220 0.001368 ** 
## attend_v_f   0.012291   0.015241   0.806 0.420382    
## attend_m_f   0.018350   0.008800   2.085 0.037557 *  
## attend_n_f   0.014432   0.008860   1.629 0.103949    
## h_chris     -0.644123   0.301826  -2.134 0.033325 *  
## h_newyr     -0.174545   0.303875  -0.574 0.565960    
## h_easter     0.070814   0.189443   0.374 0.708711    
## h_july4      0.030872   0.269699   0.114 0.908912    
## h_mem       -0.060819   0.180778  -0.336 0.736691    
## h_labor      0.283799   0.191564   1.481 0.139111    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5858 on 497 degrees of freedom
## Multiple R-squared:  0.1669, Adjusted R-squared:  0.1367 
## F-statistic:  5.53 on 18 and 497 DF,  p-value: 5.906e-12

On regressing log of assaults as a dependent variable with attend_v as independent variable and others as contral variable it can be inferred that there is a significant positive relation between average number of assaults in a subset of US counties and the number of persons watched stongly violent movies (in millions).Specifically, on average per million increase in the number of persons who have watched strongly voilent movies at a particular weekend there is a 16.808% increase in the assaults cases.

Now we will use 2SLS because there is an endogenity problem

library(ivpack)
## Warning: package 'ivpack' was built under R version 4.0.2
## Loading required package: AER
## Warning: package 'AER' was built under R version 4.0.2
## Loading required package: car
## Loading required package: carData
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 4.0.2
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 4.0.2
## Loading required package: survival
attach(movies)
## The following object is masked _by_ .GlobalEnv:
## 
##     assaults
Y1<-cbind(log(movies$assaults)) #Dependent Variable
Y2<-cbind(attend_v,attend_m,attend_n) #Endogenous Variables
X1<-cbind(h_chris,h_newyr,h_easter,h_july4, h_mem,h_labor) #Exogenous Variables
X2<- cbind(pr_attend_v,pr_attend_m,pr_attend_n,attend_m_f,attend_m_b,attend_n_b,
           attend_n_f,attend_v_b,attend_v_f) # Instrument Variables
ivreg<-ivreg(Y1~Y2+X1|X1+X2)
summary(ivreg)
## 
## Call:
## ivreg(formula = Y1 ~ Y2 + X1 | X1 + X2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7297 -0.3642  0.1064  0.4529  1.1353 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.482450   0.122854  60.905  < 2e-16 ***
## Y2attend_v   0.019814   0.013268   1.493   0.1360    
## Y2attend_m   0.051251   0.007502   6.832 2.42e-11 ***
## Y2attend_n   0.035293   0.007898   4.469 9.71e-06 ***
## X1h_chris   -0.697856   0.307349  -2.271   0.0236 *  
## X1h_newyr   -0.441602   0.310010  -1.424   0.1549    
## X1h_easter   0.031734   0.194957   0.163   0.8708    
## X1h_july4    0.009813   0.275935   0.036   0.9716    
## X1h_mem     -0.232950   0.184113  -1.265   0.2064    
## X1h_labor    0.222720   0.194712   1.144   0.2532    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6071 on 506 degrees of freedom
## Multiple R-Squared: 0.08889, Adjusted R-squared: 0.07268 
## Wald test: 6.562 on 9 and 506 DF,  p-value: 7.066e-09

From the 2SLS model it can be inferred that there is no significant relationship between the number of assaults and the number of people who attended stongly violent movies.

But there are other variables such as attend_m and attend_n will have a significant positive relationship with number of assaults.

Q4

4.Some U.S. states have enacted laws that allow citizens to carry concealed weapons. These laws are known as “shall-issue” laws because they instruct local authorities to issue a concealed weapons permit to all applicants who are citizens, are mentally competent, and have not been convicted of a felony. (Some states have some additional restrictions.) Proponents argue that if more people carry concealed weapons, crime will decline because criminals will be deterred from attacking other people. Opponents argue that crime will increase because of accidental or spontaneous use of the weapons.

In this question, you need analyze the effect of concealed weapons laws on violent crimes. You will find the data file Guns attached with the email, which contains a balanced panel of data from the 50 U.S. states plus the District of Columbia for the years 1977 through 1999. A detailed description is given in Guns_Description.

Based on your analysis, what conclusions would you draw about the effects of concealed weapons laws on these crime rates?

Ans

In this question crime rate can be measured via 3 proxy variables vio, rob and mur. so we will have to prepare 3 panal models to measure the effect of Independent variable on each Dependent variable

library(plm)
guns= read.csv("guns.csv")
names(guns)
##  [1] "year"        "vio"         "mur"         "rob"         "incarc_rate"
##  [6] "pb1064"      "pw1064"      "pm1029"      "pop"         "avginc"     
## [11] "density"     "stateid"     "shall"

Ist - Taking vio as a Dependant Variable.

First we will use the pooled model regression

pdata<-pdata.frame(guns,index=c("stateid","year"))
attach(pdata)
## The following object is masked from pdata (pos = 13):
## 
##     year
X<- cbind(shall,pop,density,avginc,pm1029,pw1064,pb1064)
pooled<-plm(vio~X,data=pdata,model="pooling")
summary(pooled)
## Pooling Model
## 
## Call:
## plm(formula = vio ~ X, data = pdata, model = "pooling")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -717.928 -134.829  -23.491  126.183  934.016 
## 
## Coefficients:
##             Estimate Std. Error t-value  Pr(>|t|)    
## (Intercept) 435.2969   251.7778  1.7289  0.084093 .  
## Xshall      -78.2499    15.2330 -5.1369 3.272e-07 ***
## Xpop         20.2506     1.1941 16.9591 < 2.2e-16 ***
## Xdensity    131.9368     5.7273 23.0364 < 2.2e-16 ***
## Xavginc       2.8496     3.6440  0.7820  0.434367    
## Xpm1029     -24.1257     4.6090 -5.2345 1.961e-07 ***
## Xpw1064       2.7867     3.9252  0.7100  0.477870    
## Xpb1064      21.7860     7.7750  2.8021  0.005162 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    130960000
## Residual Sum of Squares: 46781000
## R-Squared:      0.64278
## Adj. R-Squared: 0.64064
## F-statistic: 299.475 on 7 and 1165 DF, p-value: < 2.22e-16

The state having shall-carry or conceled weapon law will have significant voilent crime rate compare to the state which doesn’t have shall carry law. Specifically if an state has shall carry law then on average the number of voilent crime per 100,000 members of the population in that particular state is going to decrease by 78.2499.

Now we will evaluate using fixed and random effect model

random<-plm(vio~X,data=pdata,model="random")
within<-plm(vio~X,data=pdata,model="within")

Hausman test to identify which model to use.

Our null hypothesis is : Preferred model is the ramdom effect model

phtest(random,within)
## 
##  Hausman Test
## 
## data:  vio ~ X
## chisq = 140.9, df = 7, p-value < 2.2e-16
## alternative hypothesis: one model is inconsistent

Since p value comes out to be less than 0.05 we will reject the null hypothesis and use FE model i.e “within” model

summary(within)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = vio ~ X, data = pdata, model = "within")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -781.94444  -46.51923   -0.70089   44.81463  777.00634 
## 
## Coefficients:
##           Estimate Std. Error t-value  Pr(>|t|)    
## Xshall    -16.1363    11.4820 -1.4053 0.1601958    
## Xpop       14.6457     5.1580  2.8394 0.0046021 ** 
## Xdensity -214.7827    38.7673 -5.5403 3.766e-08 ***
## Xavginc    -2.6936     3.5314 -0.7628 0.4457702    
## Xpm1029   -26.7710     3.5292 -7.5856 6.958e-14 ***
## Xpw1064    10.7752     3.1011  3.4746 0.0005312 ***
## Xpb1064    15.7362    10.7523  1.4635 0.1436059    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    13576000
## Residual Sum of Squares: 10837000
## R-Squared:      0.20177
## Adj. R-Squared: 0.16097
## F-statistic: 40.2634 on 7 and 1115 DF, p-value: < 2.22e-16

There is no significant relation between state having shall-carry or conceled weapon law and voilent crime rate. Specifically it is because of the balanced mixed data of proponents (which says if more people carry concealed weapons, crime will decline because criminals will be deterred from attacking other people) and Opponents (which says that crime will increase because of accidental or spontaneous use of the weapons.)

But there are control variables such as population density and percent of population that is male aged between 10 to 29 will have a significant negative relationship with voilent crime rates.

2nd - Taking rob as a Dependant Variable.

First we will use the pooled model regression

pooled<-plm(rob~X,data=pdata,model="pooling")
summary(pooled)
## Pooling Model
## 
## Call:
## plm(formula = rob ~ X, data = pdata, model = "pooling")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -377.477  -40.521  -16.008   26.682  541.622 
## 
## Coefficients:
##                Estimate  Std. Error t-value  Pr(>|t|)    
## (Intercept) -105.028223  100.376829 -1.0463  0.295621    
## Xshall       -25.916729    6.072972 -4.2676 2.137e-05 ***
## Xpop          11.165774    0.476047 23.4552 < 2.2e-16 ***
## Xdensity      88.164785    2.283326 38.6124 < 2.2e-16 ***
## Xavginc        3.585047    1.452746  2.4678  0.013738 *  
## Xpm1029       -0.035313    1.837482 -0.0192  0.984670    
## Xpw1064        1.511159    1.564868  0.9657  0.334406    
## Xpb1064        8.352934    3.099670  2.6948  0.007145 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    34074000
## Residual Sum of Squares: 7435400
## R-Squared:      0.78179
## Adj. R-Squared: 0.78048
## F-statistic: 596.265 on 7 and 1165 DF, p-value: < 2.22e-16

The state having shall-carry or conceled weapon law will have significant robbery rate compare to the state which doesn’t have shaall carry law. Specifically if an state has shall carry law then on average the number of robbery incidents per 100,000 members of the population in that particular state is going to decrease by 25.916.

Now we will evaluate using fixed and random effect model

random<-plm(mur~X,data=pdata,model="random")
within<-plm(mur~X,data=pdata,model="within")

Hausman test to identify which model to use.

Our null hypothesis is : Preferred model is the ramdom effect model

phtest(random,within)
## 
##  Hausman Test
## 
## data:  mur ~ X
## chisq = 576.1, df = 7, p-value < 2.2e-16
## alternative hypothesis: one model is inconsistent

Since p value comes out to be less than 0.05 we will reject the null hypothesis and use FE model i.e “within” model

summary(within)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = mur ~ X, data = pdata, model = "within")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -22.917431  -0.927524  -0.079703   0.872282  28.994621 
## 
## Coefficients:
##            Estimate Std. Error  t-value  Pr(>|t|)    
## Xshall    -0.455328   0.318737  -1.4285  0.153417    
## Xpop      -0.324602   0.143186  -2.2670  0.023581 *  
## Xdensity -11.643307   1.076167 -10.8192 < 2.2e-16 ***
## Xavginc    0.696350   0.098030   7.1034 2.165e-12 ***
## Xpm1029    0.348937   0.097969   3.5617  0.000384 ***
## Xpw1064   -0.034033   0.086086  -0.3953  0.692664    
## Xpb1064   -1.543417   0.298479  -5.1709 2.759e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    12016
## Residual Sum of Squares: 8351
## R-Squared:      0.30502
## Adj. R-Squared: 0.26949
## F-statistic: 69.9098 on 7 and 1115 DF, p-value: < 2.22e-16

There is no significant relation between state having shall-carry or conceled weapon law and robbary rate. Specifically it is because of the balanced mixed data of proponents (which says if more people carry concealed weapons, robbery will decline because criminals will be deterred from attacking other people) and Opponents (which says that robbery will increase because of accidental or spontaneous use of the weapons.)

But there are control variables such as population density and percent of population that is black aged between 10 to 64 will have a significant negative relationship with robbary rates.

3rd - Taking mur as a Dependant Variable.

First we will use the pooled model regression

pooled<-plm(mur~X,data=pdata,model="pooling")
summary(pooled)
## Pooling Model
## 
## Call:
## plm(formula = mur ~ X, data = pdata, model = "pooling")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -25.41205  -1.92130  -0.21592   1.78573  34.69207 
## 
## Coefficients:
##              Estimate Std. Error t-value  Pr(>|t|)    
## (Intercept)  9.156885   5.665690  1.6162 0.1063219    
## Xshall      -0.649659   0.342784 -1.8952 0.0583076 .  
## Xpop         0.217672   0.026870  8.1009 1.366e-15 ***
## Xdensity     3.597484   0.128880 27.9133 < 2.2e-16 ***
## Xavginc     -0.286932   0.081999 -3.4992 0.0004843 ***
## Xpm1029      0.023107   0.103715  0.2228 0.8237321    
## Xpw1064     -0.030170   0.088328 -0.3416 0.7327351    
## Xpb1064      0.340470   0.174958  1.9460 0.0518941 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    66325
## Residual Sum of Squares: 23689
## R-Squared:      0.64284
## Adj. R-Squared: 0.64069
## F-statistic: 299.544 on 7 and 1165 DF, p-value: < 2.22e-16

There is no significant relation between state having shall-carry or conceled weapon law and murder rate. Specifically it is because of the balanced mixed data of proponents (which says if more people carry concealed weapons, murder will decline because criminals will be deterred from attacking other people) and Opponents (which says that murder will increase because of accidental or spontaneous use of the weapons.)

But there are control variables such as population of the state and its density will have a significant positive relationship with murder rates.

Now we will evaluate using fixed and random effect model

random<-plm(rob~X,data=pdata,model="random")
within<-plm(rob~X,data=pdata,model="within")

Hausman test to identify which model to use.

Our null hypothesis is : Preferred model is the ramdom effect model

phtest(random,within)
## 
##  Hausman Test
## 
## data:  rob ~ X
## chisq = 31.903, df = 7, p-value = 4.233e-05
## alternative hypothesis: one model is inconsistent

Since p value comes out to be less than 0.05 we will reject the null hypothesis and use FE model i.e “within” model

summary(within)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = rob ~ X, data = pdata, model = "within")
## 
## Balanced Panel: n = 51, T = 23, N = 1173
## 
## Residuals:
##       Min.    1st Qu.     Median    3rd Qu.       Max. 
## -370.75343  -15.80067   -0.61097   15.01612  506.70059 
## 
## Coefficients:
##          Estimate Std. Error t-value  Pr(>|t|)    
## Xshall    4.33434    5.67987  0.7631 0.4455624    
## Xpop     -0.28809    2.55156 -0.1129 0.9101232    
## Xdensity 23.67621   19.17723  1.2346 0.2172395    
## Xavginc  -9.47879    1.74689 -5.4261 7.063e-08 ***
## Xpm1029  -3.72509    1.74581 -2.1337 0.0330825 *  
## Xpw1064   4.94997    1.53404  3.2268 0.0012884 ** 
## Xpb1064  19.20277    5.31888  3.6103 0.0003194 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    2799800
## Residual Sum of Squares: 2651900
## R-Squared:      0.052845
## Adj. R-Squared: 0.004425
## F-statistic: 8.88702 on 7 and 1115 DF, p-value: 1.1088e-10

There is no significant relation between state having shall-carry or conceled weapon law and murder rate.Specifically it is because of the balanced mixed data of proponents (which says if more people carry concealed weapons, murder will decline because criminals will be deterred from attacking other people) and Opponents (which says that murder will increase because of accidental or spontaneous use of the weapons.)

But there are control variables such as real per capita personal income in the state, in thousands of dollars and percent of population that is black aged between 10 to 64 will have a significant positive and negative relationship respectively with crime rates. ```