SynthControl.jl

A Julia package for estimating causal effects via synthetic control estimators

Package Overview

SynthControl aims to provide a wide coverage of synthetic control estimators, written in pure Julia. The package is under development, with new estimators and options for statistical inference added. Where possible, estimators are implemented following reference implementations by the original authors.

The following table provides an overview of the planned scope of the package as well as current implementation status

EstimatorPoint estimateCovariatesStandard ErrorsReference implementation
Simple SCM🟢🟥🟡None
ADH2010🟡🟥🟥None
SyntheticDiD🟢🟥🟡synthdid (R)
PenalizedSCM🟥🟥🟥pensynth (R)
AugmentedSCM🟥🟥🟥augsynth (R)
MC-NNM🟡🟥🟥fect (R)

Contributions to add methods to the package scope - or even better, full implementations! - are very much welcome.

Documentation outline

API

SynthControl.SimpleSCMType
SimpleSCM

Takes in a TreatmentPanel and holds the results of calling the fit! method, optimal weights for comparator units and the resulting predicted outcome of the synthetic control unit as well as the estimated treatment effect from comparing synthetic control and observed outcome of the treated unit.

source
SynthControl.SyntheticDiDType
SyntheticDiD

Synthetic Differences-in-Differences (SDID) estimator as described in Arkhangelsky et al. (2021). SDID is defined as

μ̂, α̂, β̂, τ̂ = argmin ∑ₙ∑ₜ(Yᵢₜ - μ - αᵢ - βₜ - Wᵢₜτ)²ω̂ᵢλ̂ₜ

where i = 1, 2, ..., N denotes the observation units in the panel, t = 1, ..., T denotes the time periods, Y is an (N×T) matrix of outcomes, W is an (N×T) indicator matrix of treatment status, ω is a unit weight and λ is a time period weight.

The implementation follows the author's reference implementation in the R package synthdid, published by the authors under a BSD-3 license at https://github.com/synth-inference/synthdid/

NOTE: The implementation assumes that the outcomes and treatment matrices are sorted such that treated units come last in both Y and W. It therefore checks whether W is sorted and swaps rows in both Y and W to sort both matrices accordingly if required.

source
SynthControl.fit!Function
fit!(s::SimpleSCM; placebo_test = false)

Fit the SimpleSCM s by finding the weights that minimize the distance between the pre-treatment outcomes for the observational unit of interest and the weighted average pre-treatment outcomes for unweighted units.

If placebo_test = true is supplied, additional placebo tests will be performed by using every non-treated unit in the data set as the treated unit in turn and estimating the treatment impact on this unit. Results are stored in the p_test_res field and can be used as the basis for inference.

source
SynthControl.isfittedFunction

isfitted(s::SimpleSCM)

Check whether the SimpleSCM object s has been fitted.

Examples

julia> df = load_brexit();

julia> s = SimpleSCM(df, :country, :dateid, :realgdp, 86, "United Kingdom");

julia> isfitted(s)
false

julia> fit!(s);

julia> isfitted(s)
true
source