data("sexratio", package = "KFAS")
model <- bsm_ng(sexratio[, "Male"], sd_level = 0.001,
u = sexratio[, "Total"],
distribution = "binomial")
imp <- importance_sample(model, nsim = 1000)
est <- matrix(NA, 3, nrow(sexratio))
for(i in 1:ncol(est)) {
est[, i] <- diagis::weighted_quantile(exp(imp$alpha[i, 1, ]), imp$weights,
prob = c(0.05,0.5,0.95))
}
ts.plot(t(est),lty = c(2,1,2))
Run the code above in your browser using DataLab