Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = TRUE, warning = FALSE, message = FALSE, out.width = '90%', out.height = '600px', fig.align='center' ) set.seed(123)
In this vignette I show how {bsynth} can be used for causal estimation when you have multiple treated accounts. In particular, I use the synthetic data exaple from Xu, Yiqing, 2017. In this example, the treatment starts in period 21 and increases by one each period (e.g. the effect is 5 period 25 and 10 in period 30).
knitr::include_graphics(path = "https://ignacio.martinez.fyi/synthetic_control/gsynth.png")
library(bsynth) ci_width <- 0.95 data(gsynth, package = "gsynth") dplyr::glimpse(simdata) outcome_data <- simdata %>% dplyr::select(time, id, D, Y) covariates <- simdata %>% dplyr::select(time, id, X1, X2) synth <- bsynth::bayesianSynth$new( data = outcome_data, time = time, id = id, treated = D, outcome = Y, ci_width = ci_width, covariates = covariates ) synth$timeTiles + ggplot2::theme(text = ggplot2::element_text(size=6))
synth$fit()
synth$synthetic
synth$effectPlot(subset = c("Average"), facet = FALSE) + ggplot2::scale_y_continuous(breaks=seq(-2,12,2))
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.