Title: | Computes Powell's Generalized Synthetic Control Estimator |
---|---|
Description: | Computes the generalized synthetic control estimator described in Powell (2017) <doi:10.7249/WR1142>. Provides both point estimates, and hypothesis testing. |
Authors: | Philip Barrett |
Maintainer: | Philip Barrett <[email protected]> |
License: | GPL-2 |
Version: | 1.0.0 |
Built: | 2024-10-30 06:51:53 UTC |
Source: | CRAN |
Wrapper function for GSC estimation
pgsc(dta, dep.var, indep.var, b.init, method, sol.it = NULL, wt.init = NULL, print.level = 0, g.i = NULL, g.i.grad = NULL, ...)
pgsc(dta, dep.var, indep.var, b.init, method, sol.it = NULL, wt.init = NULL, print.level = 0, g.i = NULL, g.i.grad = NULL, ...)
dta |
A data frame |
dep.var |
A string defining the dependent variable |
indep.var |
A vector of strings defining the independent (treatment) variables |
b.init |
An initial value for the treatment variable coefficients. Must have same length as 'indep.var' |
method |
The GSC iteration method to be used. Must be one of:
|
sol.it |
The first step solution used in the two-step methods. If omitted, a new one-step solution is computed. |
wt.init |
An initial value for the weighting matrix |
print.level |
The level of detail provided in the printed output |
g.i |
A function defining a restriction on the parameters. Used in hypothesis testing. |
g.i.grad |
The gradient of |
... |
Other arguments to be passed to the optimization |
See the vignette "Using pgsc
" for an extended example.
Returns the point estimate of the model as a gsc
object, a list with entries:
The point estimate of the coefficients on the dependent variables
The difference between successive iterations
The maximum error on the within-iteration optimization problems
Number of iterations require to solve
The unit-specific MSEs from the solution
The "full" weighting matrix for counterfactuals, containing own-unit weights (all zero) and unit-N weights
The "minimal" weighting matrix, omitting own-unit weights and weights on unit N (which can be computed as one-minus-rowsum)
data("pgsc.dta") sol <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = c(0,0), method='onestep' ) summary(sol) g.i <- function(b) b[1] ; g.i.grad <- function(b) c(1,0) sol.r <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = sol$b, method='onestep', g.i=g.i, g.i.grad=g.i.grad ) summary(sol.r)
data("pgsc.dta") sol <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = c(0,0), method='onestep' ) summary(sol) g.i <- function(b) b[1] ; g.i.grad <- function(b) c(1,0) sol.r <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = sol$b, method='onestep', g.i=g.i, g.i.grad=g.i.grad ) summary(sol.r)
A dataset with an outcome given by a treatment and a set of factors.
pgsc.dta
pgsc.dta
A data frame with 750 rows and 8 variables:
The unit, here labeled as a US state
The time period
The outcome variable
The first treatment variable
The second treatment variable
The first observed confounding factor
The second observed confounding factor
The third observed confounding factor
Generated by code in the package vignette "Using pgsc
".
A wrapper for the wald test of a restricted solution
pgsc.wald.test(dta, dep.var, indep.var, sol.rest, n.boot = 10000, seed = 42)
pgsc.wald.test(dta, dep.var, indep.var, sol.rest, n.boot = 10000, seed = 42)
dta |
A dataframe |
dep.var |
A vector of strings of names of dependent variables. |
indep.var |
A vector of strings of names of independent (treatment) variables. |
sol.rest |
A restricted solution which is being tested |
n.boot |
The number of bootstrapped samples for the variance calculation. Default is 10000. |
seed |
Randomization seed. Default is 42. |
See the vignette "Using pgsc
" for an extended example.
Returns the wald test as gsc.wald
object, a list with entries:
The point estimate of the coefficients on the dependent variables
The Wald statistic
The bootstrapped Wald statistic
The p-value for the Wald statistic.
data("pgsc.dta") g.i <- function(b) b[1] ; g.i.grad <- function(b) c(1,0) sol.r <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = c(0,1), method='onestep', g.i=g.i, g.i.grad=g.i.grad ) wald <- pgsc.wald.test( pgsc.dta, 'y', indep.var = c('D1','D2'), sol.r ) summary(wald) plot(wald)
data("pgsc.dta") g.i <- function(b) b[1] ; g.i.grad <- function(b) c(1,0) sol.r <- pgsc(pgsc.dta, dep.var = 'y', indep.var = c('D1','D2'), b.init = c(0,1), method='onestep', g.i=g.i, g.i.grad=g.i.grad ) wald <- pgsc.wald.test( pgsc.dta, 'y', indep.var = c('D1','D2'), sol.r ) summary(wald) plot(wald)