I am trying to understand the differences in estimating diff-in-diff in different formulations. To exemplify, I'm using data from Abadie, et al., (2010), in which the authors estimate the effect of a tobacco control program implemented in California in 1989. Ps: I know in the paper they used the Synthetic Control Method, and not diff-in-diff, just took the data as example, as they also compare they results to DiD.
First, I estimate the canonical diff-in-diff model
$$Y_{it} = \beta_0 + \beta_1 \textrm{Post}_t + \beta_2 \textrm{Treated}_i + \beta_3 \textrm{Treated}_i \textrm{Post}_t + e_{it}$$
import pandas as pd
import statsmodels.api as sm
from linearmodels import PanelOLS
data=pd.read_csv("https://raw.githubusercontent.com/kevinkuranyi/archive/main/smoking.csv")
data[['Treated', 'Post']]=0
data.loc[data['state']=='California', 'Treated']=1
data.loc[data['year']>1988, 'Post']=1
data['PostxTreated']=data['Post']*data['Treated']
Y=data['cigsale']
X=data[['Post', 'Treated', 'PostxTreated']]
X = sm.add_constant(X)
print(sm.OLS(Y,X).fit().summary().tables[1])
And got the following results:
================================================================================
coef std err t P>|t| [0.025 0.975]
--------------------------------------------------------------------------------
const 130.5695 1.087 120.112 0.000 128.437 132.702
Post -28.5114 1.747 -16.318 0.000 -31.939 -25.084
Treated -14.3590 6.789 -2.115 0.035 -27.678 -1.040
PostxTreated -27.3491 10.911 -2.506 0.012 -48.756 -5.942
================================================================================
The estimated treatment effect: $\hat{\beta_{3}} = -27.349$. I understand this is numerically equivalent to the (Two-Way) Fixed Effects model, so when I estimate this (being only interested in $\tau$ I use the package for panel and add options to time and unit fixed effects):
$$y_{it}=\alpha_{i}+ \gamma_{t} +\tau_{it}TreatedxPost +\epsilon_{it}$$
df_panel=data.set_index(['state', 'year'])
Y=df_panel["cigsale"]
X=df_panel['PostxTreated']
X=sm.add_constant(X)
model=PanelOLS(Y,X, entity_effects=True, time_effects=True )
print(model.fit().summary.tables[1])
I got this:
Parameter Estimates
================================================================================
Parameter Std. Err. T-stat P-value Lower CI Upper CI
--------------------------------------------------------------------------------
const 119.16 0.3423 348.14 0.0000 118.49 119.84
PostxTreated -27.349 4.4095 -6.2024 0.0000 -36.001 -18.698
================================================================================
As expected, $\hat{\tau}=\hat{\beta_{3}} = -27.349$
1st QUESTION: Why are the standard errors so different? Which one is correct?
2nd QUESTION: Which specification should I use if I want to include covariates?
If I include the covariate retprice
, results from both estimations are completely different:
In the first model, replacing X=data[['Post', 'Treated', 'PostxTreated']]
by X=data[['Post', 'Treated', 'PostxTreated', 'retprice]]
I got:
================================================================================
coef std err t P>|t| [0.025 0.975]
--------------------------------------------------------------------------------
const 146.0978 1.889 77.352 0.000 142.392 149.803
Post -1.4389 3.216 -0.447 0.655 -7.749 4.871
Treated -13.8457 6.532 -2.120 0.034 -26.662 -1.030
PostxTreated -21.2837 10.517 -2.024 0.043 -41.917 -0.650
retprice -0.2407 0.024 -9.874 0.000 -0.289 -0.193
================================================================================
In the second model, using X=df_panel[['PostxTreated', 'retprice']]
, results are:
Parameter Estimates
================================================================================
Parameter Std. Err. T-stat P-value Lower CI Upper CI
--------------------------------------------------------------------------------
const 171.71 4.6146 37.211 0.0000 162.66 180.77
PostxTreated -15.101 4.3142 -3.5002 0.0005 -23.565 -6.6360
retprice -0.4861 0.0426 -11.415 0.0000 -0.5697 -0.4026
================================================================================
What am I estimating in each of these cases? Which of the estimators is biased, and why?