[32m[1m Resolving[22m[39m package versions...
[32m[1m No Changes[22m[39m to `~/.julia/environments/v1.11/Project.toml`
[32m[1m No Changes[22m[39m to `~/.julia/environments/v1.11/Manifest.toml`
Instrumental Variable
using DataFrames, RDatasets, FixedEffectModels
df = dataset("plm", "Cigar")
first(df, 5)
5×9 DataFrame
Row
State
Year
Price
Pop
Pop16
CPI
NDI
Sales
Pimin
Int64
Int64
Float64
Float64
Float64
Float64
Float64
Float64
Float64
1
1
63
28.6
3383.0
2236.5
30.6
1558.3
93.9
26.1
2
1
64
29.8
3431.0
2276.7
31.0
1684.07
95.4
27.5
3
1
65
29.8
3486.0
2327.5
31.5
1809.84
98.5
28.9
4
1
66
31.5
3524.0
2369.7
32.4
1915.16
96.4
29.5
5
1
67
31.6
3533.0
2393.7
33.4
2023.55
95.5
29.6
For example, if we have an instrumental variable Price predicting CPI which predicts Sales (theoretically incorrect, just for illustration), the formula here should be:
Balanced Panel - single treated unit, continuous treatment
Treated unit: United Kingdom
Number of untreated units: 22
First treatment period: 2016-07-01
Number of pretreatment periods: 30
Number of treatment periods: 9
s = SimpleSCM(bp)
Synthetic Control Model
Treatment panel:
Model is not fitted
Balanced Panel - single treated unit, continuous treatment
Treated unit: United Kingdom
Number of untreated units: 22
First treatment period: 2016-07-01
Number of pretreatment periods: 30
Number of treatment periods: 9
fit!(s)
Synthetic Control Model
Treatment panel:
Model is fitted
Impact estimates: [-0.54, -0.31, -0.206, -0.732, -1.241, -1.482, -1.818, -2.327, -1.994]
Balanced Panel - single treated unit, continuous treatment
Treated unit: United Kingdom
Number of untreated units: 22
First treatment period: 2016-07-01
Number of pretreatment periods: 30
Number of treatment periods: 9
using Plots
plot(s)
SyntheticDiD
sp = load_smoking_panel()
Balanced Panel - single treated unit, continuous treatment
Treated unit: 3
Number of untreated units: 38
First treatment period: 1989
Number of pretreatment periods: 19
Number of treatment periods: 12
sdid_model = SyntheticDiD(sp)
Synthetic Difference-in-Differences Model
Model is not fitted
fit!(sdid_model)
Synthetic Difference-in-Differences Model
Model is fitted
Impact estimate: -15.604