bcallaway11 / did

Difference in Differences with Multiple Periods, website: https://bcallaway11.github.io/did
298 stars 95 forks source link

Add call to top level of model object #125

Closed grantmcdermott closed 2 years ago

grantmcdermott commented 2 years ago

Fixes #121

grantmcdermott commented 2 years ago

Reprex with example I originally raised (i.e. update()).

devtools::load_all("~/Documents/Projects/did/")
#> ℹ Loading did

library(did)

data(mpdta)

mod = att_gt(yname="lemp",
             tname="year",
             idname="countyreal",
             gname="first.treat",
             xformla=NULL,
             data=mpdta)

newdat = subset(mpdta, year!=2007)

update(mod, data = newdat)
#> 
#> Call:
#> att_gt(yname = "lemp", tname = "year", idname = "countyreal", 
#>     gname = "first.treat", xformla = NULL, data = newdat)
#> 
#> Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
#> 
#> Group-Time Average Treatment Effects:
#>  Group Time ATT(g,t) Std. Error [95% Simult.  Conf. Band]  
#>   2004 2004  -0.0196     0.0246       -0.0782      0.0390  
#>   2004 2005  -0.0787     0.0303       -0.1509     -0.0065 *
#>   2004 2006  -0.1363     0.0390       -0.2291     -0.0434 *
#>   2006 2004  -0.0026     0.0236       -0.0588      0.0537  
#>   2006 2005  -0.0019     0.0200       -0.0495      0.0456  
#>   2006 2006   0.0047     0.0172       -0.0362      0.0455  
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#> 
#> P-value for pre-test of parallel trends assumption:  0.98941
#> Control Group:  Never Treated,  Anticipation Periods:  0
#> Estimation Method:  Doubly Robust

Created on 2022-04-12 by the reprex package (v2.0.1)