# NOT RUN {
## 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"
# }
Run the code above in your browser using DataLab