mssm (version 0.1.3)

mssm-Laplace: Parameter Estimation with Laplace Approximation for Multivariate State Space Model

Description

Function returned from mssm which can be used to perform parameter estimation with a Laplace approximation.

Arguments

cfix

starting values for coefficient for the fixed effects.

disp

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

F.

starting values for matrix in the transition density of the state vector.

Q

starting values for covariance matrix in the transition density of the state vector.

Q0

un-used.

mu0

un-used.

trace

integer controlling whether information should be printed during parameter estimation. Zero yields no information.

Value

An object of class mssmLaplace with the following elements

F.

estimate of F..

Q

estimate of Q.

cfix

estimate of cfix.

logLik

approximate log-likelihood at estimates.

n_it

number of Laplace approximations.

code

returned code from nlopt.

disp

estimated dispersion parameter.

Remaining elements are the same as returned by mssm.

See Also

mssm.

Examples

Run this code
# NOT RUN {
if(require(Ecdat)){
  # load data and fit glm to get starting values
  data("Gasoline", package = "Ecdat")
  glm_fit <- glm(lgaspcar ~ factor(country) + lincomep + lrpmg + lcarpcap,
                 Gamma("log"), Gasoline)

  # get object to perform estimation
  library(mssm)
  ll_func <- mssm(
    fixed = formula(glm_fit), random = ~ 1, family = Gamma("log"),
    data = Gasoline, ti = year, control = mssm_control(
      N_part = 1000L, n_threads = 1L))

  # fit model with time-varying intercept with Laplace approximation
  disp <- summary(glm_fit)$dispersion
  laplace <- ll_func$Laplace(
    cfix = coef(glm_fit), disp = disp, F. = diag(.5, 1), Q = diag(1))
  print(laplace)
}
# }

Run the code above in your browser using DataLab