# bsm: Basic Structural (Time Series) Model In bssm: Bayesian Inference of Non-Linear and Non-Gaussian State Space Models

## Description

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

## Usage

 ```1 2``` ```bsm(y, sd_y, sd_level, sd_slope, sd_seasonal, beta, xreg = NULL, period = frequency(y), a1, P1, obs_intercept, state_intercept) ```

## 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. `obs_intercept, state_intercept` Intercept terms for observation and state equations, given as a length n vector and m times n matrix respectively.

## Value

Object of class `bsm`.

## Examples

 ```1 2 3 4 5 6 7 8``` ```prior <- uniform(0.1 * sd(log10(UKgas)), 0, 1) model <- bsm(log10(UKgas), sd_y = prior, sd_level = prior, sd_slope = prior, sd_seasonal = prior) mcmc_out <- run_mcmc(model, n_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 documentation built on Nov. 22, 2018, 5:06 p.m.