Type: | Package |
Title: | Spillover Time Series Causal Inference |
Version: | 1.0 |
Imports: | CausalImpact, keras, stats, graphics, grDevices |
Date: | 2021-03-13 |
Author: | Zihao Zheng and Feiyu Yue |
Maintainer: | Feiyu Yue <yuefyopals@gmail.com> |
Description: | A time series causal inference model for Randomized Controlled Trial (RCT) under spillover effect. 'SPORTSCausal' (Spillover Time Series Causal Inference) separates treatment effect and spillover effect from given responses of experiment group and control group by predicting the response without treatment. It reports both effects by fitting the Bayesian Structural Time Series (BSTS) model based on 'CausalImpact', as described in Brodersen et al. (2015) <doi:10.1214/14-AOAS788>. |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2021-03-28 08:33:14 UTC; zhengzihao |
Depends: | R (≥ 3.5.0) |
Repository: | CRAN |
Date/Publication: | 2021-03-30 08:10:02 UTC |
Spillover Time Series Causal Inference
Description
A time series causal inference model for Randomized Controlled Trial (RCT) under spillover effect. 'SPORTSCausal' (Spillover Time Series Causal Inference) separates treatment effect and spillover effect from given responses of experiment group and control group by predicting the response without treatment. It reports both effects by fitting the Bayesian Structural Time Series (BSTS) model based on 'CausalImpact', as described in Brodersen et al. (2015) <doi:10.1214/14-AOAS788>.
Details
The DESCRIPTION file:
Package: | SPORTSCausal |
Type: | Package |
Title: | Spillover Time Series Causal Inference |
Version: | 1.0 |
Imports: | CausalImpact, keras, stats, graphics, grDevices |
Date: | 2021-03-13 |
Author: | Zihao Zheng and Feiyu Yue |
Maintainer: | Feiyu Yue <yuefyopals@gmail.com> |
Description: | A time series causal inference model for Randomized Controlled Trial (RCT) under spillover effect. 'SPORTSCausal' (Spillover Time Series Causal Inference) separates treatment effect and spillover effect from given responses of experiment group and control group by predicting the response without treatment. It reports both effects by fitting the Bayesian Structural Time Series (BSTS) model based on 'CausalImpact', as described in Brodersen et al. (2015) <doi:10.1214/14-AOAS788>. |
License: | GPL-2 |
Index of help topics:
SPORTSCausal-package Spillover Time Series Causal Inference ad_cost Advertising cost: a real experimental data under spillover effect sportscausal Time series causal inference of Randomized Controlled Trial (RCT) under spillover effect
Author(s)
Zihao Zheng and Feiyu Yue
Maintainer: Feiyu Yue <yuefyopals@gmail.com>
References
Brodersen et al. Inferring causal impact using Bayesian structural time-series models. Annals of Applied Statistics, 2015
See Also
http://google.github.io/CausalImpact/CausalImpact.html
Examples
## For more detail of the package, try ?sportscausal and ?ad_cost
Advertising cost: a real experimental data under spillover effect
Description
This dataset comes from an A/Btest, which is to evaluate how a newly-proposed algorithm will affect the cost of advertising. Assuming that the bidding environment of an advertising market is stable in a short period of time, there will be no net increase or decrease of cost. When a treatment is applied, the mutual interference between the experiment group and the control group can not be ignored. For example, the difference in cost between the experiment group and the control group might not only come from the increase of experiment group, caused by treatment effect, but also from the potential decrease in control group. That is the typical situation for spillover causal inference to be implemented.
Usage
data("ad_cost")
Format
A data frame with 49 observations on the following 3 variables.
y.exp
A numeric vector of responses in experiment group.
y.con
A numeric vector of responses in control group.
time
A numeric vector indicating time period before/after the treatment,
time = 1
represents post treatment period.
Details
This data has been linearly transformed for confidential issue.
Examples
### load data
data(ad_cost)
### define variables and visualize
y.exp = ad_cost$y.exp
y.con = ad_cost$y.con
plot(y.exp, col = "red", type = "l",
xlab = "time", ylab = "response")
lines(y.con, col = "blue")
### fit the model and return treatment/spillover effect
# notice that day-34 is the first day of treatment
fit = sportscausal(y.exp = y.exp, y.con = y.con,
pre.period = c(1:33), post.period = c(34:49), is.plot = FALSE)
fit$est.treatment
fit$est.spillover
Time series causal inference of Randomized Controlled Trial (RCT) under spillover effect
Description
'SPORTSCausal' produces treatment effect and spillover effect estimation from responses of experiment group and control group.
Usage
sportscausal(y.exp, y.con, pre.period, post.period, is.plot = TRUE,
model.select = "AIC", max.p = 3, max.d = 3, max.q = 3, feature = NULL)
Arguments
y.exp |
Response of experiment group, from pre-treatment to post-treatment |
y.con |
Response of control group, from pre-treatment to post-treatment |
pre.period |
Time period before the treatment |
post.period |
Time period during the treatment |
is.plot |
If |
model.select |
Model used to predict the time series without treatment. If |
max.p |
The max number of autoregressive terms in ARIMA model, by default |
max.d |
The max number of nonseasonal differences needed for stationarity in ARIMA model, by default |
max.q |
The max number of lagged forecast errors in the prediction equation in ARIMA model, by default |
feature |
The covariate matrix associated with the response. By default, |
Details
In the presense of spillover effect, the response of control group could be interferenced by the treatment. In order to seprate the treatment effect and spillover effect, sportscausal
uses ARIMA model or LSTM model to predict the response behavior without treatment. The point estimator and significance of both effect follow using Bayesian Structrual Time Series (BSTS) model.
Value
est.treatment |
Information of treatment effect estimation, containing point estimation, confidence interval and p-value |
est.spillover |
Information of spillover effect estimation, containing point estimation, confidence interval and p-value |
Author(s)
Zihao Zheng and Feiyu Yue
References
Brodersen et al. Inferring causal impact using Bayesian structural time-series models. Annals of Applied Statistics, 2015
See Also
See also ?ad_cost
Examples
## simulate data
set.seed(1)
y0 = 100 + arima.sim(model = list(ar = 0.3), n = 125)
y.con = y0 + rnorm(125)
y.con[101:125] = y.con[101:125] - 10 ## -10 as spillover effect
y.exp = y0 + rnorm(125)
y.exp[101:125] = y.exp[101:125] + 10 ## 10 as treatment effect
pre.period = c(1:100)
post.period = c(101:125)
## visualize
plot(y.exp, col = "red", type = "l", ylab = "response",
ylim = c(80, 120))
lines(y.con, col = "blue")
abline(v = 101, col = "grey", lty = 2, lwd = 2)
legend("topleft", legend = c("exp", "con"), col = c("red", "blue"),
cex = 1, lty = 1)
## try SPORTSCausal with ARIMA + AIC
fit.aic = sportscausal(y.exp = y.exp, y.con = y.con,
pre.period = pre.period, post.period = post.period, is.plot = FALSE)
fit.aic$est.treatment
fit.aic$est.spillover
## you can also try model.select = "CV" or "lstm"