Learn R Programming

bssm (version 1.0.0)

ssm_ung: General univariate non-Gaussian state space model

Description

Construct an object of class ssm_ung by defining the corresponding terms of the observation and state equation:

Usage

ssm_ung(
  y,
  Z,
  T,
  R,
  a1,
  P1,
  distribution,
  phi = 1,
  u = 1,
  init_theta = numeric(0),
  D,
  C,
  state_names,
  update_fn = default_update_fn,
  prior_fn = default_prior_fn
)

Arguments

y

Observations as time series (or vector) of length \(n\).

Z

System matrix Z of the observation equation. Either a vector of length m, a m x n matrix, or object which can be coerced to such.

T

System matrix T of the state equation. Either a m x m matrix or a m x m x n array, or object which can be coerced to such.

R

Lower triangular matrix R the state equation. Either a m x k matrix or a m x k x n array, or object which can be coerced to such.

a1

Prior mean for the initial state as a vector of length m.

P1

Prior covariance matrix for the initial state as m x m matrix.

distribution

Distribution of the observed time series. Possible choices are "poisson", "binomial", "gamma", and "negative binomial".

phi

Additional parameter relating to the non-Gaussian distribution. For negative binomial distribution this is the dispersion term, for gamma distribution this is the shape parameter, and for other distributions this is ignored.

u

Constant parameter for non-Gaussian models. For Poisson, gamma, and negative binomial distribution, this corresponds to the offset term. For binomial, this is the number of trials.

init_theta

Initial values for the unknown hyperparameters theta.

D

Intercept terms \(D_t\) for the observations equation, given as a 1 x 1 or 1 x n matrix.

C

Intercept terms \(C_t\) for the state equation, given as a m times 1 or m times n matrix.

state_names

Names for the states.

update_fn

Function which returns list of updated model components given input vector theta. This function should take only one vector argument which is used to create list with elements named as Z, T, R, a1, P1, D, C, and phi, where each element matches the dimensions of the original model. If any of these components is missing, it is assumed to be constant wrt. theta.

prior_fn

Function which returns log of prior density given input vector theta.

Value

Object of class ssm_ung.

Details

$$p(y_t | D_t + Z_t \alpha_t), (\textrm{observation equation})$$ $$\alpha_{t+1} = C_t + T_t \alpha_t + R_t \eta_t, (\textrm{transition equation})$$

where \(\eta_t \sim N(0, I_k)\) and \(\alpha_1 \sim N(a_1, P_1)\) independently of each other, and \(p(y_t | .)\) is either Poisson, binomial, gamma, or negative binomial distribution.