I'm wanting to use a custom bsts model within the CausalImpact package, and I understand that I need to use a control group in my data; however, I don't really understand where that control group fits within the bsts model.

I know my dependent variable is from the test group and that my independent variables are from the control group. I'm confused at how that looks when actually making the model.

For example, if I want to predict sessions of the test group, would I just have a few control groups and use their sessions to predict? Or do I use one control group and use its predictor values?

Here's the code I would theoretically write for both of those scenarios:

Scenario 1:

bsts( test_sessions ~ control1_sessions + control2_sessions + control3_sessions, data = data, ss, niter = 1000)

Scenario 2:

bsts(test_sessions ~ control1_adwords+ control1_paidkeywords+ control1_organickeywords, data = data, ss, niter = 1000)

1 Answer 1


You can use any variable from the control group as long as it's not affected by the intervention.

Of course it makes sense to take variables that are expected to be predictive for the response of interest. But even including variables that are not predictive should not hurt the model as CausalImpact performs automatic variable selection (a random noise variable should automatically be excluded). Concretely: if control1_adwords and control2_paidkeywords (they needn't be from the same control group) are good predictors for test_sessions in the pre-intervention period, it's fine to include them as predictors in addition to control1_sessions, control2_sessions, etc.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.