Hands-on lab · US state panel, 1982–1988
PIET A.1.1 · CoBrA 1.1.0
States with higher beer taxes had higher traffic death rates in the pooled data. The slope turns negative when we compare changes within states and account for common year effects. Reproduce both estimates, then decide what the evidence says about a tax increase.
Download the lab script and the labeled dataset.
The unit of observation is one US state in one year. The panel follows the 48 contiguous states from 1982 through 1988. The first question is whether a change in beer tax is associated with a change in traffic deaths. In section 7 the policy changes to a preliminary breath-test law.
clear all. It loads the built-in sample with sysuse fatalities, clear; no separate CSV import is needed.describe. Expect 336 rows and 45 variables. In Graphics, expect three plots. The script also writes tour_en_scatter.svg and tour_en_did.svg to the working directory, replacing those two files when rerun. Enter pwd to see that directory.Find in the script gen frate = fatal/pop*10000
Read the frate line in section 1. It divides the number of deaths by the state population, then multiplies by 10,000. Alabama had 839 deaths among about 3.94 million residents in 1982, or 2.13 deaths per 10,000. The mean of frate is 2.040. Each state-year gets equal weight. To calculate a national population-weighted rate, you would instead divide total deaths by total population.
xtset statenum year identifies the state and calendar year so PIET can locate the previous observation for that state. Of the 336 state-years, 155 have a preliminary breath-test law in force and 181 do not.
Find in the script regress frate beertax
In Results, find beertax in each regression table. Its coefficient gives the difference in deaths per 10,000 associated with one additional dollar of real tax per case of beer. The rows use the same panel.
| Comparison | Beer-tax coefficient | Standard error | p-value |
|---|---|---|---|
| All state-years, tax only | +0.3646 | 0.0622 | <0.001 |
| Same regression, heteroskedasticity-robust errors | +0.3646 | 0.0529 | <0.001 |
| Add unemployment and log income | +0.1103 | 0.0627 | 0.080 |
| Add state fixed effects, cluster by state | −0.3696 | 0.2665 | 0.172 |
| State and year fixed effects, same controls and clustering | −0.4604 | 0.3081 | 0.142 |
The first row mixes persistent differences between high- and low-tax states with tax changes over time. State fixed effects remove each state’s stable characteristics, such as geography. Year effects absorb shocks shared across states. The last row associates a 10-cent increase per case with 0.046 fewer traffic deaths per 10,000 residents, conditional on income, unemployment and those fixed effects. For a one-dollar increase the 95% interval runs from −1.080 to +0.159. Concurrent state-level enforcement changes, or taxes raised in response to accidents, could still confound a causal reading.
In the pooled regression, estat hettest rejects constant error variance (χ²=17.18). With the two controls, VIFs are 1.27–1.85 and the RESET test gives p=0.486. These address collinearity and functional form. Whether a tax change is exogenous requires separate evidence. The random-effects estimate is +0.0550. It relies on the additional assumption that unobserved state effects are uncorrelated with the regressors.
The two-way fixed-effects slope stays at −0.4604. Its conventional standard error is 0.1633 (p=0.005), the heteroskedasticity-robust one is 0.2250 (p=0.042), and the state-clustered one is 0.3081 (p=0.142). State policy and driving conditions can persist across years. Clustering allows errors in a given state to be correlated across observations. The joint test of all three slopes gives F(3,47)=21.36. That test can reject even when the beer-tax coefficient alone is imprecise.
reghdfe frate beertax unemp lincome i.year, absorb(statenum) vce(cluster statenum)
boottest beertax, reps(9999) seed(42)Under the null of a zero tax coefficient, the wild cluster bootstrap gives observations within a state the same random sign. Look for 48 clusters, 9,999 repetitions and Rademacher weights. The symmetric two-sided p-value is 0.1834 and the equal-tail p-value is 0.1824. The fixed seed reproduces the draws. This version needs the year indicators entered explicitly for this test. The resulting tax coefficient and t statistic (−1.4942) match the specification absorbing both state and year.
How long did it take? On an Apple M1 with 8 GiB RAM running macOS 26.6.2, the A.1.1 binary took 1.01 seconds on the first run of the benchmark and a median of 0.265 seconds on the next five (range 0.263–0.277). Each measurement started a new process, loaded the built-in sample, constructed variables, fitted the model and printed the 9,999-draw test. This timing covers the short benchmark on this panel.
Find in the script test baptist
Read the three pooled regressions controlling for unemployment and log income. One percentage point more Southern Baptists is associated with $0.02771 more beer tax per case (first-stage F=146.33). The reduced-form slope for the death rate on the same instrument is 0.01459. With one instrument for one endogenous variable, the IV slope is their ratio, about +0.527 deaths per 10,000 per dollar. As a comparison, the share living in dry counties has a first-stage F of only 0.75. Both F statistics here use conventional OLS errors.
The first instrument predicts taxes well. Religious composition could also affect drinking or driving habits through other channels. In that case the exclusion restriction fails. The numerical strength of the first stage gives no assurance that +0.527 measures the causal effect of taxation.
Find in the script reghdfe lfatal beertax unemp lincome lpop, absorb(statenum year) vce(cluster statenum)
The regression uses log fatality counts and includes log population. Holding population and the other regressors fixed, the beer-tax coefficient of −0.1324 gives a ratio of exp(−0.1324) ≈ 0.876 for a one-dollar difference. That is about 12.4% lower on the exponentiated log scale (p=0.276). Log population has coefficient 0.594 with a 95% interval from −0.142 to 1.330. That interval includes the unit elasticity implied by a specification that fixes population exposure proportionally.
Find in the script csdid frate unemp lincome, ivar(statenum) time(year) gvar(gvar) method(dripw)
Identify the comparison groups in tabulate gvar. 22 states had no law in force during the panel. 18 had one in the first year. The remaining first-adoption groups contain five states in 1983 and one each in 1984, 1986 and 1987. A frequency of 35 for the 1983 cohort means 35 state-years, or five states observed seven times. Indiana and Louisiana had the law in the first year and later switched to “no.” The cohort variable records first observed exposure. Use drinkd for the actual status in a given year. The first-year cohort has no observed pre-adoption period to identify an adoption effect.
| Output | Question | Result in deaths per 10,000 |
|---|---|---|
| estat simple | What is the average effect among adopters? | ATT −0.0741, SE 0.1180, 95% interval [−0.3054, +0.1573], p=0.530 |
| estat event | How do estimates vary with time to adoption? | Pre-adoption average +0.0271 (p=0.479), adoption year +0.0133, post-adoption average −0.0815 |
| estat calendar | How do effects vary by calendar year? | −0.1587 in 1986 and −0.0784 in 1988 |
| estat group | How do effects vary by adoption cohort? | 1983 −0.0836, 1984 −0.0775, 1986 −0.0323, 1987 +0.0148 |
ATT compares adopters to how they would have fared without adopting. The design uses never-treated states to infer that unobserved path. It relies on parallel trends conditional on the controls and on the absence of anticipatory effects. The short panel gives limited power to detect pre-trends. The 1984 cohort’s p-value of 0.037 comes from a cohort of just one adopting state.
Find in the script coefplot m_fe, keep(beertax)
Open Graphics and move through the plots in order. For the last plot, the script uses preserve, computes group means with collapse, and then uses restore to recover the 336 observations. That last step matters for the lag regressions.
Find in the script regress frate L.beertax unemp lincome
L. selects the previous year’s value in the same state. D. subtracts it from this year’s value. Each state’s first year drops out, leaving 288 observations. All four models below are pooled OLS regressions of this year’s fatality rate.
| Regressors of interest | How to read the output |
|---|---|
| Last year’s tax, controlling for unemployment and log income | L.beertax +0.1560. State-years with higher taxes the year before have higher current fatality rates in this comparison. |
| Current and lagged taxes, same controls | Current +0.4026, lagged −0.2322. Their standard errors of 0.7186 and 0.6958 show how difficult it is to separate the two slopes. |
| Annual tax change, same controls | D.beertax −0.2836 (p=0.673). The dependent variable is still the level of this year’s rate. |
| Lagged death rate and current tax | L.frate +0.8787. Fatality rates are persistent, and this pooled comparison also includes stable differences across states. The coefficient cannot tell us how long a tax shock lasts. |
Use the name in the first column in your commands. The descriptions are the actual variable labels in fatalities_labeled_en.dta. A value of 0.21 for youngdrivers means 21%, while unemp=7 means 7%. The law fields use yes/no. Jail and service each have one missing observation. In the separate CSV, rownames is an export row number. The bundled sample omits it. AER dataset documentation
| Variable | Label |
|---|---|
state |
US state abbreviation |
year |
Calendar year |
spirits |
Spirits consumption |
unemp |
State unemployment rate (%) |
income |
Personal income per capita (1987 dollars) |
emppop |
State employment-to-population ratio (%) |
beertax |
Real state tax per case of beer (dollars) |
baptist |
Southern Baptists as a share of the population (%) |
mormon |
Mormons as a share of the population (%) |
drinkage |
Minimum legal drinking age (years) |
dry |
Population living in dry counties (%) |
youngdrivers |
Share of drivers aged 15-24 (fraction from 0 to 1) |
miles |
Average miles driven per driver |
breath |
Preliminary breath-test law in force (yes/no) |
jail |
Mandatory jail for a first drunk-driving conviction (yes/no) |
service |
Mandatory community service for a first drunk-driving conviction (yes/no) |
| Variable | Label |
|---|---|
fatal |
Traffic fatalities (people) |
nfatal |
Nighttime traffic fatalities (people) |
sfatal |
Single-vehicle traffic fatalities (people) |
fatal1517 |
Traffic fatalities, ages 15-17 (people) |
nfatal1517 |
Nighttime traffic fatalities, ages 15-17 (people) |
fatal1820 |
Traffic fatalities, ages 18-20 (people) |
nfatal1820 |
Nighttime traffic fatalities, ages 18-20 (people) |
fatal2124 |
Traffic fatalities, ages 21-24 (people) |
nfatal2124 |
Nighttime traffic fatalities, ages 21-24 (people) |
afatal |
Estimated alcohol-involved traffic fatalities (people) |
pop |
State population (people) |
pop1517 |
Population ages 15-17 (people) |
pop1820 |
Population ages 18-20 (people) |
pop2124 |
Population ages 21-24 (people) |
milestot |
Total vehicle miles traveled in the state (millions) |
unempus |
US unemployment rate (%) |
emppopus |
US employment-to-population ratio (%) |
gsp |
Growth rate of gross state product (0.01 means 1%) |
| Variable | Label |
|---|---|
frate |
Traffic deaths per 10,000 residents |
lincome |
Natural log of real personal income per capita |
lfatal |
Natural log of traffic fatalities |
lpop |
Natural log of state population |
drinkd |
Breath-test law in force this year (1 yes, 0 no) |
statenum |
Numeric state ID for panel analysis |
ols_resid |
Pooled OLS residual (observed minus fitted fatality rate) |
treatyr |
Year of observation when the breath-test law is in force |
gvar |
First observed year with the law (0 if never observed in force) |
evertreat |
Law ever observed in force during the panel (1 yes, 0 no) |
_est_m_fe |
Observation used in the stored two-way FE model (1 included) |
The residual ols_resid belongs to the first tax-only OLS model. Treatyr records every year observed with the law in force. Gvar repeats the earliest such year across observations for the same state. PIET creates _est_m_fe when it stores the model named m_fe. L.beertax and D.beertax are expressions evaluated during estimation and do not add columns to the dataset.
Use the two-way fixed-effects model to describe a 25-cent difference in the beer tax. Multiply both the coefficient and interval endpoints by 0.25. You should get −0.115 deaths per 10,000 residents, with a 95% interval from −0.270 to +0.040. In a report, specify the comparison within states, the tax and outcome units, and the uncertainty around the estimate.