as_bssm
function!)For state space models supported by bssm
, often only a small number (e.g. 10) particles is enough for accurate likelihood estimate.
Post-correction is easy to parallelize and the needs to be done only for accepted θ.
yt=dt+Ztαt+Htϵt,ϵt∼N(0,I)αt+1=ct+Ttαt+Rtηt,ηt∼N(0,I)α1∼N(a1,P1)
# univariate LGSSM, ssm_mlg for multivariate versionssm_ulg(y, Z, H, T, R, a1, P1, D, C, init_theta, prior_fn, update_fn)# Basic structural time series modelbsm_lg(y, sd_level = gamma(1, 2, 10), sd_y = 1, xreg = X, beta = normal(0, 0, 10))
ssm_ung(y, Z, T, R, distribution = "poisson")ssm_mng(...)bsm_ng(...)svm(...)ar1_ng(...)
# latent random walkalpha <- cumsum(rnorm(100, sd = 0.1))# observationsy <- cbind(rpois(100, exp(alpha)), rpois(100, exp(alpha)))# function which defines the log-prior densityprior_fun <- function(theta) { dgamma(theta, 2, 0.01, log = TRUE)}# function which returns updated model componentsupdate_fun <- function(theta) { list(R = array(theta, c(1, 1, 1)))}model <- ssm_mng(y = y, Z = matrix(1, 2, 1), T = 1, R = 0.1, P1 = 1, distribution = "poisson", init_theta = 0.1, prior_fn = prior_fun, update_fn = update_fun)
Non-linear Gaussian models: yt=Zt(αt)+Ht(αt)ϵt,αt+1=Tt(αt)+Rt(αt)ηt,α1∼N(a1,P1),
Models where the state equation is defined as a continuous-time diffusion: dαt=μ(αt)dt+σ(αt)dBt,t≥0,
These use user-defined C++ -snippets for model components based on a template provided
data("drownings")model <- bsm_ng( y = drownings[, "deaths"], u = drownings[, "population"], xreg = drownings[, "summer_temp"], distribution = "poisson", beta = normal(init = 0, mean = 0, sd = 1), sd_level = gamma(init = 0.1, shape = 2, rate = 10), sd_slope = gamma(0, 2, 10))fit <- run_mcmc(model, iter = 20000, particles = 10)summary(fit, TRUE)[,1:4]
## Mean SD SE ESS## sd_level 0.1029887 0.02195574 0.0007928511 766.8547## sd_slope 0.0161829 0.01130342 0.0003732525 917.0944## coef_1 0.1109080 0.01743323 0.0005728851 926.0207
Some references:
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |