mssm (version 0.1.3)

mssm-pf: Particle Filter Function for Multivariate State Space Model

Description

Function returned from mssm which can be used to perform particle filtering given values for the parameters in the model.

Arguments

cfix

values for for coefficient for the fixed effects.

disp

additional parameters for the family (e.g., a dispersion parameter).

F.

matrix in the transition density of the state vector.

Q

covariance matrix in the transition density of the state vector.

Q0

optional covariance matrix at the first time point. Default is the covariance matrix in the time invariant distribution.

mu0

optional mean at the first time point. Default is the zero vector.

trace

integer controlling whether information should be printed during particle filtering. Zero yields no information.

seed

integer to pass to set.seed. The seed is not set if the argument is NULL.

what, N_part

same as in mssm_control.

Value

An object of class mssm with the following elements

pf_output

A list with an element for each time period. Each element is a list with particles: the sampled particles, stats: additional object that is requested to be computed with each particle, ws: unnormalized log particle weights for the filtering distribution, and ws_normalized: normalized log particle weights for the filtering distribution.

Remaining elements are the same as returned by mssm.

If gradient approximation is requested then the first elements of stats are w.r.t. the fixed coefficients, the next elements are w.r.t. the matrix in the map from the previous state vector to the mean of the next, and the last element is w.r.t. the covariance matrix. Only the lower triangular matrix is kept for the covariance matrix. See the examples in the README at https://github.com/boennecd/mssm. There will be an additional element for the dispersion parameter if the family has a dispersion parameter.

If the Hessian is requested then the \tilde \beta_n^{(i)}s in Poyiadjis et al. (2011) are returned after the gradient elements. These can be used to approximate the observed information matrix. That is, using that the approximation of the observed information matrix is

\tilde S_n\tilde S_n^\top - \sum_{i = 1}^n \tilde W_n^{(i)}(\tilde\alpha_n^{(i)}\tilde\alpha_n^{(i)\top} + \tilde \beta_n^{(i)}), \qquad \tilde S_n = \sum_{i=1}^n \tilde W_n^{(i)}\tilde\alpha_n^{(i)}

as in Poyiadjis et al. (2011). See the README for an example.

References

Poyiadjis, G., Doucet, A. and Singh, S. S. (2011) Particle Approximations of the Score and Observed Information Matrix in State Space Models with Application to Parameter Estimation. Biometrika, 98(1), 65--80.

See Also

mssm.

Examples

Run this code
# NOT RUN {
if(require(Ecdat)){
  # load data and get object to perform particle filtering
  data("Gasoline", package = "Ecdat")

  library(mssm)
  ll_func <- mssm(
    fixed = lgaspcar ~ factor(country) + lincomep + lrpmg + lcarpcap,
    random = ~ 1, family = Gamma("log"), data = Gasoline, ti = year,
    control = mssm_control(N_part = 1000L, n_threads = 1L))

  # run particle filter
  cfix <- c(0.612, -0.015, 0.214, 0.048, -0.013, -0.016, -0.022, 0.047,
            -0.046, 0.007, -0.001, 0.008, -0.117, 0.075, 0.048, -0.054, 0.017,
            0.228, 0.077, -0.056, -0.139)
  pf <- ll_func$pf_filter(
    cfix = cfix, Q = as.matrix(2.163e-05), F. = as.matrix(0.9792),
    disp = 0.000291)
  print(pf)
}
# }

Run the code above in your browser using DataCamp Workspace