GetInclusionProbabilities <- function(bsts.object) {
# Pulls code from
# - BoomSpikeSlab::PlotMarginalInclusionProbabilities
# - bsts::PlotBstsCoefficients
burn <- SuggestBurn(0.1, bsts.object)
beta <- bsts.object$coefficients
beta <- beta[-(1:burn), , drop = FALSE]
inclusion.prob <- colMeans(beta != 0)
index <- order(inclusion.prob)
inclusion.prob <- inclusion.prob[index]
# End from BoomSpikeSlab/bsts.
return(data.frame(predictor = names(inclusion.prob),
inclusion.prob = inclusion.prob))
}
这也可以用于
CausalImpact
通过
impact$model$bsts.model
.