Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bsm_lg

Basic Structural (Time Series) Model


Description

Constructs a basic structural model with local level or local trend component and seasonal component.

Usage

bsm_lg(
  y,
  sd_y,
  sd_level,
  sd_slope,
  sd_seasonal,
  beta,
  xreg = NULL,
  period = frequency(y),
  a1,
  P1,
  D,
  C
)

Arguments

y

Vector or a ts object of observations.

sd_y

A fixed value or prior for the standard error of observation equation. See priors for details.

sd_level

A fixed value or a prior for the standard error of the noise in level equation. See priors for details.

sd_slope

A fixed value or a prior for the standard error of the noise in slope equation. See priors for details. If missing, the slope term is omitted from the model.

sd_seasonal

A fixed value or a prior for the standard error of the noise in seasonal equation. See priors for details. If missing, the seasonal component is omitted from the model.

beta

Prior for the regression coefficients.

xreg

Matrix containing covariates.

period

Length of the seasonal component i.e. the number of

a1

Prior means for the initial states (level, slope, seasonals). Defaults to vector of zeros.

P1

Prior covariance for the initial states (level, slope, seasonals). Default is diagonal matrix with 1000 on the diagonal.

D, C

Intercept terms for observation and state equations, given as a length n vector and m times n matrix respectively.

Value

Object of class bsm_lg.

Examples

prior <- uniform(0.1 * sd(log10(UKgas)), 0, 1)
model <- bsm_lg(log10(UKgas), sd_y = prior, sd_level =  prior,
  sd_slope =  prior, sd_seasonal =  prior)

mcmc_out <- run_mcmc(model, iter = 5000)
summary(expand_sample(mcmc_out, "theta"))$stat
mcmc_out$theta[which.max(mcmc_out$posterior), ]
sqrt((fit <- StructTS(log10(UKgas), type = "BSM"))$coef)[c(4, 1:3)]

bssm

Bayesian Inference of Non-Linear and Non-Gaussian State Space Models

v1.1.4
GPL (>= 2)
Authors
Jouni Helske [aut, cre] (<https://orcid.org/0000-0001-7130-793X>), Matti Vihola [aut] (<https://orcid.org/0000-0002-8041-7222>)
Initial release
2021-04-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.