Learn R Programming

EcoEnsemble (version 1.1.2)

KalmanFilter_back: Backwards Kalman filter

Description

Finds the most likely path through a dynamical linear model.

Usage

KalmanFilter_back(rhos, dee, R, Q, C, P, xhat, Time, y, obs)

Value

A matrix with dimensions nrow(time) and length(xhat) representing the most likely values of the latent variables.

Arguments

rhos

A numeric containing the diagonal elements of the transition matrix of the evolution equation.

dee

A numeric of the same length as rho containing the discrepancies or biases in the observation process.

R

A numeric representing the variances of the observation process.

Q

A matrix of dimensions length(rho) and length(rho) representing the covariance of the evolution process.

C

A a matrix of dimensions length(rho) and length(R) representing the observation operator of the observation process.

P

A matrix of dimensions length(rho) and length(rho) representing the covariance matrix of the first state of the evolution process.

xhat

A numeric of the same length as rho representing the expectation of the first state of the evolution process.

Time

A numeric The length of time of the dynamical linear model.

y

A matrix of dimensions Time and length(R) of observations of the observation process.

obs

A matrix of dimensions Time and length(R). 1 means in the i,jth element means that the jth output is observed at tim i.

Details

For the model with the evolution process $$x_{t+1}\sim{}N(\rho{}\cdot{}x_{t},Q)$$ and observation process $$y_{t}\sim{}N(\rho{}(x_{t} + \delta),diag(R))$$.

Using the sequential Kalman filter, the function gives the mostly path of \(x_{t}\) for all \(t\).

References

Chui, C.K. & Chen, G. (2009) Kalman Filtering with Real-Time Applications. Springer, Berlin, Heidelberg, Fourth Edtion.

Kalman, R. E. (1960) A new approach to linear filtering and prediction problems. Trans. ASME, J. Basic Eng., 82, pp. 35-45.

Examples

Run this code
# \donttest{
fit <- fit_ensemble_model(observations = list(SSB_obs, Sigma_obs),
               simulators = list(list(SSB_ewe, Sigma_ewe, "EwE"),
                                 list(SSB_fs,  Sigma_fs, "FishSUMS"),
                                 list(SSB_lm,  Sigma_lm, "LeMans"),
                                 list(SSB_miz, Sigma_miz, "Mizer")),
               priors = EnsemblePrior(4,
               ind_st_params = IndSTPrior(parametrisation_form = "lkj",
               var_params= list(1,1), cor_params = 10, AR_params = c(2, 2))),
               full_sample = FALSE) #Only optimise in this case
transformed_data <- get_transformed_data(fit)
ex.fit <- fit@point_estimate$par
params <- get_parameters(ex.fit)
ret <- KalmanFilter_back(params$AR_params, params$lt_discrepancies,
                          transformed_data$all_eigenvalues_cov,params$SIGMA,
                          transformed_data$bigM, params$SIGMA_init, params$x_hat,
                          fit@ensemble_data@stan_input$time,transformed_data$new_data,
                          transformed_data$observation_available)
# }

Run the code above in your browser using DataLab