Академический Документы
Профессиональный Документы
Культура Документы
OLS assumes that the residual 𝜀 is a random variable that is independently and identically distributed
(i.i.d.) with the properties 𝜀 ~ N(0, 𝜎2).
Normality Tests:
Shapiro-Wilk Test
shapiro.test(m2$res) for less than 2000
Kolmogorov-Smirnov Test:
ks.test(norm, m2$res) for higher no of obs <2000
Homoskedasticity:
Property of being equal variance for residual
Heteroskedastic: not having equal variance, violating the ols assumption
If residuals plot is non-linear there is possibility of missing variable in model and it suggests non-
linearity.
Tests for homoskedasticity :
Bartlette’s test for equal variances. bartlett.test(list(m2$res, m2$fit))
Endogeniety :
Two stage least square
Detecting autocorrelation:
Durbin Watson test
Drunk driving:
H1a : B drinkage < 0 young people are more prone to drink and driving so if legal drinking is increased it
will reduce the fatalities
H2a : B beertax < 0 : if we increase the beertax less number f people would by drink and eventually less
fatalities
H3a : B jail < 0 : if jail sentence increase for drunk driv people will drive carefully and fatalities would be
less
H4a : B comm < 0 : if community service for drunk driving incrase people will drive more carefully
Model 1 :
Call:
plm(formula = fatalityrate ~ beertax + as.factor(legdrinkage) +
as.factor(jail) + +as.factor(commserv) + unemprate, data = drunkdrive,
model = "random", index = c("state", "year"))
Effects:
var std.dev share
idiosyncratic 0.03377 0.18376 0.129
individual 0.22798 0.47748 0.871
theta: 0.8561
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-0.472985 -0.114130 -0.024289 0.086629 0.910719
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 2.3412319 0.1368313 17.1104 < 2.2e-16 ***
beertax 0.0607571 0.1214867 0.5001 0.6173
as.factor(legdrinkage)19 -0.0654510 0.0817920 -0.8002 0.4242
as.factor(legdrinkage)20 -0.0813748 0.0829191 -0.9814 0.3271
as.factor(legdrinkage)21 -0.1005301 0.0791180 -1.2706 0.2048
as.factor(jail)yes 0.0897133 0.1135126 0.7903 0.4299
as.factor(commserv)yes -0.0765384 0.1318356 -0.5806 0.5619
unemprate -0.0345450 0.0073345 -4.7100 3.664e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R squre for the above modle is much less than As per the above model we can suggest to increase the
legal drinking age to 21 and to increase the community service for drink n driving cases.
> summary(m3)
Oneway (individual) effect Random Effect Model
(Swamy-Arora's transformation)
Call:
plm(formula = fatalityrate ~ beertax + as.factor(legdrinkage) +
as.factor(jail) + as.factor(year) + as.factor(commserv) +
unemprate, data = drunkdrive, model = "random", index = c("state",
"year"))
Effects:
var std.dev share
idiosyncratic 0.02628 0.16213 0.103
individual 0.22905 0.47859 0.897
theta: 0.873
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-0.466201 -0.105241 -0.018079 0.094308 0.649069
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 2.8739226 0.1474620 19.4892 < 2.2e-16 ***
beertax -0.0216301 0.1195870 -0.1809 0.85658
as.factor(legdrinkage)19 -0.0140196 0.0746655 -0.1878 0.85118
as.factor(legdrinkage)20 -0.0093797 0.0763558 -0.1228 0.90231
as.factor(legdrinkage)21 -0.0095802 0.0743783 -0.1288 0.89759
as.factor(jail)yes 0.1449190 0.1083812 1.3371 0.18213
as.factor(year)1983 -0.0879033 0.0356283 -2.4672 0.01414 *
as.factor(year)1984 -0.2522745 0.0411269 -6.1341 2.510e-09 ***
as.factor(year)1985 -0.3138957 0.0422482 -7.4298 9.860e-13 ***
as.factor(year)1986 -0.2349473 0.0441156 -5.3257 1.891e-07 ***
as.factor(year)1987 -0.2958331 0.0490291 -6.0338 4.398e-09 ***
as.factor(year)1988 -0.3512523 0.0540569 -6.4978 3.096e-10 ***
as.factor(commserv)yes -0.0626118 0.1249300 -0.5012 0.61659
unemprate -0.0846675 0.0098518 -8.5941 3.693e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Looking at model we can see that there is no specific pattern of continuous icrease or descreae of
fatality rate.
The model abve gives rsq of 22% which is not quite strong though we have used the plm models .
We could increase the model by using advanced plm and time series seasonality techniques.
Log :
Y = a + b*log(x)
B = Y will change when x is changed by 100%
Log(y) = a + b*x
When x increases by 1 y increases by B *100 %
Log(y) = a + b*log(x)
When