Data Assignment 2 Answers and R code lines:
Information: The deadline for this exercise is 2 December, 23:59. The assignment can be done in groups
of three students. For this assignment, you should paste the relevant results in one file where you include
your answers. Always also include your R-script as an appendix so that we can check what you did (and
possibly see what went wrong).
Introduction: With the increased usage of (fast) electric bikes in the Netherlands the government is
interested in the relationship between wearing a helmet and fatality risk. As hospitals collect no detailed
data on the mode of transport used we will use a US dataset on accidents with motor cycles to investigate
this question. The first dataset (Motor_accidents) contains road accidents of motor cycles in the US
between 1988 and 2005.1 The dataset contains a range of variables that can be classified as describing (1)
the injury, (2) characteristics of the individual, (3) characteristics of the motorcycle and (4) characteristics
of the accident. The data comes from the “Fatality Analysis Reporting System”, which is managed by the
National Highway Traffic Safety Administration (NHTSA) in the US.
Binary outcome models
1. Create a table with descriptive statistics for your variables, providing the means separately for
whether the accident was fatal or not. Decide which statistics to include. Make sure to format the
table properly.
mean_large sd_largebik mean_my19
fatal count mean_helmet sd_helmet bike e 90 sd_my1990
0.498216217 0.406600249 0.49123726 0.43384184 0.49564235
0 6424 0.4573474471 2 1 55 31 03
0.397467177 0.48940254 0.43476240 0.49575458
1 8607 0.4454513768 0.497044416 9 22 27 73
mean_drive
fatal count mean_male sd_male r sd_driver mean_front sd_front
0.483180491 0.461706102 0.49857022 0.54669987 0.49785309
0 6424 0.62873599 4 1 74 55 55
0.478734829 0.526548158 0.49932370 0.58208434 0.49324479
1 8607 0.6443592425 6 5 55 99 33
mean_week sd_weeken
fatal count mean_side sd_side mean_rural sd_rural end d
0.398174477 0.509028642 0.49995739 0.51042963 0.49993012
0 6424 0.1975404732 4 6 17 89 34
0.386299757 0.516091553 0.49977002 0.50749390 0.49997288
1 8607 0.1825258511 5 4 84 03 37
fatal count mean_night sd_night mean_sl55u sd_sl55up mean_rider sd_riders2
p s2
0.437016190 0.48936880
0 6424 0.7429950187 2 0.397260274 56 1 0
0.434586344 0.49165064
1 8607 0.7472987104 8 0.408853259 4 1 0
mean_nr_vehicl sd_nr_vehicl
fatal count es es mean_age sd_age
0.649123991
0 6424 1.669053549 5 31.50809465 12.7204067
0.597379438 12.9626130
1 8607 1.649587545 3 32.92970838 4
2. Write down a linear regression model where the outcome is a dummy for whether an accident was
fatal. Your explanatory variable of interest is whether the driver/passenger was wearing a helmet.
Include age and age squared as control variables.
Linear regression model:
Fatalityi = β0 + β1(Helmeti) + β2(Agei) + β3(Agei2) + ϵi
3. Estimate your linear model and carefully interpret the meaning of your estimates. Do helmets
reduce fatality risk? Comment on the magnitude of the effect. What is the association between
age and fatality risk?
Output:
Comment:
The coefficient for helmet is -0.01773, with a standard error of 0.008193 and a p-value of 0.0304.
This indicates that wearing a helmet is statistically significantly associated with a reduction in the
probability of fatality (at the 5% significance level). The estimated reduction in fatality probability
associated with wearing a helmet is about 1.77 percentage points (0.01773), which might be a small
effect. But given the potentially severe consequences of fatal accidents, even a small reduction can be
impactful in safety contexts.
The coefficient of age is 0.003885, with a p-value of 0.0110. This indicates that age has a positive
and statistically significant association with fatality risk. For every additional year of age, the probability
of fatality increases by approximately 0.39 percentage points, holding all else constant. The coefficient of
age-squared is -0.00002373, with a p-value of 0.2552, which is not statistically significant, suggesting that
the non-linear (quadratic) relationship between age and fatality risk might be weak in this model.
4. Note that the model from question 3 was a linear probability model. What is a potential downside
of this model? Investigate and report whether this is an issue.
Linear probability models face difficulty because although probabilities must lie between 0 and 1,
some values of Yi could be outside of this range.
When tested, we found that no probabilities in this model were found outside the 0,1 range.
Therefore, it is not an issue for this case.
5. For your model in question 3, estimate a probit and a logit model. Do your coefficient estimates
confirm the results of the linear probability model? Calculate the marginal effect of each
coefficient at the mean, and interpret the result.
Probit Model:
Logit Model:
The signs of these coefficient estimates differ from the results of the linear probability model. We
cannot make direct conclusions about the significance of these estimates given the regression
because they are individualized to the person. We need to calculate the marginal effect of the mean
in order to do so. However, the difference in sign between the linear probability model and the
probit and logit models proves that these models do not confirm the results of the linear probability
model.
There are only slight differences between the probit and logit models when it comes to the marginal
effects of each coefficient at the mean. Consequently, I will interpret them together.
An individual’s use of a helmet has a -0.01776 decrease in one's fatality rate.
An increase in one’s age is associated with a 3.817x10-3 increase in fatality rate.
The age square coefficient is negative which means the impact on one’s age on mortality rate
decreases as one’s age increases.
6. Compute the average marginal effect of each coefficient from both the Logit and the Probit
regression. Compare these marginal effects to the corresponding estimated marginal effects in
question 3.
Average Marginal Effect Probit:
Average Marginal Effect Logit:
Comparison:
For the Probit and Logit models, the marginal effect of age is the same as the linear regression. It is
a comparison of 0.0038 and 0.003885. There is similarly no difference for the age_squared and
helmet marginal effects. For age square we are comparing -0.0000 to -0.00002373. The AME probit
and logit models do not show their results with scientific notation so we cannot tell if the values are
the same at the hundred thousandths digit.
7. Discuss whether you think omitted variable bias is present in your current analysis. If yes, what
would be the sign of the bias in the estimate for helmet? Explain.
8. Using the same dataset, investigate whether wearing a helmet is associated with the observable
characteristics in your dataset. Provide an interpretation of your results and link these results to
your answer in the previous question.
9. If omitted variable bias is an issue, you might consider using the Instrumental Variables approach.
Someone suggests using age as an instrument for wearing a helmet. State the two conditions for a
valid instrument, and argue whether you think they hold/do not hold in this example.
Panel data analysis
State level
For the second part of analysis you will use another dataset (“Fatal_accidents”), which contains the
number of fatal motorcycle accidents for each of 48 US states, for the years 1988 - 2005. Thus, this is a
panel dataset. Rather than observing whether riders were wearing helmets, the dataset contains a variable
(Helmet_law) indicating whether a particular state in a particular year had a law in place making helmets
mandatory for motorbike riders.2 Several states changed their legislation somewhere between 1988-2005.
You would like to estimate whether mandatory helmet laws reduce the number of fatal motorbike
accidents in a state.
By focusing on state laws you might be able to avoid the potential endogeneity problems, that you
discussed in the cross-sectional analysis.
10. Perform a pooled regression to estimate the effect of a helmet law on the log number of fatal
accidents. Include the log of state population, the unemployment rate and a geographic location as
additional control variables. Interpret your estimate corresponding to helmet_law. (Note: you will
first need to create the log of fatal accidents yourself )
Output:
Interpretation:
The coefficient of -0.44036 indicates that the presence of a helmet law is associated with a
reduction in the log number of fatal accidents by approximately 0.44036 units. In other words, the
presence of a helmet law is associated with an approximate 35.6% reduction in the number of fatal
accidents, holding all other variables constant. The p-value lower than 2e-16 suggests the relationship
between helmet laws and the log number of fatal accidents is highly statistically significant.
11. Estimate the model from the previous question with a fixed-effects model using the
within-estimator with state fixed effects. Make sure to use correct standard errors. Discuss which
controls from the previous question you can include. Again interpret the meaning of your
estimate.
Output:
Discussion:
Three variables should be included. Unemployment rate (unemp) variable is time-varying within
states, so it remains in the model. Log of state population (lpop) variable also varies over time and is valid
as a control. As a policy variable, Helmet law (helmet_law) can change over time and thus remains
included. Geographic location (geo_loc) variable is constant across time for each state, which will be
absorbed by the state-level fixed effects and cannot be included.
Interpretation:
The coefficient for helmet_law is -0.5656, which is highly statistically significant (p < 2.2e-16).
The estimate indicates that the implementation of a helmet law is associated with a 56.6% reduction in
fatal accidents, as the dependent variable is the logarithm of fatal accidents. In other words, a helmet law
experiences approximately 43.2% fewer fatal accidents, holding other variables constant. The t-value of
-12.09 and p-value lower than 2.2e-16 show strong evidence that helmet laws are associated with fewer
fatal accidents.
The coefficient of 3.0344 and p-value of 0.015 for Unemployment Rate (unemp) suggests that
higher unemployment is significantly associated with more fatal accidents. For example, a 1-unit increase
in the unemployment rate is associated with an approximate 3.03 increase in the log number of fatal
accidents, all else equal. The coefficient of 1.3113 and p-value lower than 4.187e-09 for Log of
Population (lpop) implies that a 1% increase in population corresponds to a 1.31% increase in fatal
accidents (elasticity interpretation).
12. Explain what kind of comparisons are made in the pooled regression versus the fixed-effect
regression? How many states effectively contribute to the estimate of the coefficient on helmet
laws in the fixed effects regression?
In a pooled regression, we estimate a standard OLS model, ignoring the panel structure of the data
set. This type of regression can be problematic as we are comparing some observations that are
related to each other: e.g. the same state before and after the helmet law is put into effect. This type
of regression ignores that the state has variables that remain constant before and after the law
changes. It compares the before and after period of the state as if they are two separate states. The
fixed effects regression, on the other hand, captures all the factors that are constant across time
within a state. It is therefore comparing the state before and after the law change, holding
everything that remains the same in the state constant.
Part 2:
13. How does your estimate from question 12 for helmet_law change compared to the pooled
regression? Can you think of an explanation for this?
Question “12”
Pooled regression:
The helmet law is seen as more impactful on lowering mortality rates in the fixed effects regression
compared to the pooled regression by 0.12527 units. This makes sense because when you compare a
state to itself, fatality factors that remain constant within a state over time, such as road conditions,
are considered a fixed effect and removed from the regression results. In the pooled regression you
are comparing factors such as the road quality of each state in addition to the effect of the helmet
law change. Therefore, the fixed effect regression allows us to see the full impact of the law change
for each state without other factors biasing it.
14. Reestimate your fixed-effects model but now also including year fixed effects. Explain what
potential problem the year fixed effects solve for.
15. Given an example of a source of bias that is not solved for in the fixed effects regression from the
previous question. Explain in words how you could investigate whether this source of bias is
present in this case.
Motorcycle id level
For the final part of the analysis we return to the dataset from the first part (Motor_accidents). This
dataset contains the variable vehicleid which is a unique identifier for each vehicle. This allows you to
investigate the fatality of the accident for the passenger/driver on the same motorcycle involved in the
same accident.
16. How many unique vehicles are there in the dataset? And for how many of these did the driver and
passenger differ in their helmet use?
There are 7834 unique vehicles in this data set. In 646 vehicles, drivers and passengers
differed in their helmet use.
17. Investigate whether either drivers or passengers are more likely to wear a helmet.
Neither passengers nor drivers are more likely to wear a helmet compared to the other group.
18. Reestimate your model from question 3 using the within-estimator, this time including fixed
effects for the vehicle id. Provide a discussion on which other control variables from the dataset
you could include in your model and include these. Interpret your results. Link your discussion to
your answer to question 7.
19. Of all the models you have estimated in this assignment, which do you prefer for answering the
causal question of interest from the introduction? Explain your answer.
R Code Appendix
Question 1
Question 3
Question 4
Question 5
Question 6
Question 10
Question 11
Question 16
Question 17