Open tcuongd opened 5 years ago
I ran across this issue as well. My guess is that the difference lies in the fact that predict.bsts
is predicting from period 101 onward. If you check bsts_model$timestamp.info
from the code above and compare it to the what the predict.bsts
help docs say it makes sense:
The time stamps give the time points as which each prediction is desired. They must be interpretable as integer (0 or larger) time steps following the last time stamp in object. If NULL, then the requested predictions are interpreted as being at 1, 2, 3, ... steps following the training data.
Looking through https://github.com/cran/bsts/blob/d20c0f3e3dc8a02bf4485234673004892d4a92a1/R/format.prediction.data.R might shed some light.
Hi, from looking at the code I can see that
CausalImpact
generates the posterior predictive samples by getting the state value draws and sampling noise with variance equal to thesigma.obs
draws from the bsts model object.When I try to replicate the inference step using
predict.bsts
, I get different results. In particular, the credible intervals produced by generating the posterior predictive withbsts.predict
are larger thanCausalImpact
suggests. The bounds of the relative difference credible interval can differ by 2-3%. Is there inherently a difference between howCausalImpact
prediction andpredict.bsts
works? I've attached example code below.