ssKalmanSmooth

Purpose

Performs the Rauch-Tung-Striebel backward recursion smoother for state variables and state covariances.

Format

{ a_smooth, p_smooth } = ssKalmanSmooth(ssm, y)
{ a_smooth, p_smooth } = ssKalmanSmooth(ssm, kfRslt)
Parameters:
  • ssm (Structure) – A filled instance of a ssModel structure.

  • y (Matrix) – Optional, data. If a data matrix is passed, a first stage Kalman filtering will be performed.

  • y – Optional, a filled instance of the kalmanResult structure. If a kalmanResult structure is passed, no first stage Kalman filtering is performed.

Returns:
  • a_smooth (Vector) – Smoothed state variable.

  • p_smooth (Array) – Smoothed state covariances.

Examples

new;
library tsmt, sslib, cmlmt;

y = loadd(getGAUSSHome $+ "pkgs/tsmt/examples/nile.dat");

sigma_e = 15099;
sigma_n = 1469.1;

// Initialize Kalman filter
a_0 = 0;
p_0 = 10e7;

// Specify state-space system matrices
struct ssModel ssm;
ssm.Z = 1;
ssm.H = sigma_e;
ssm.T = 1;
ssm.Q = sigma_n;
ssm.R = 1;
ssm.d = 0;
ssm.c = 0;

struct kalmanResult rslt;
rslt = sskalmanFilter(y, ssm, a_0, p_0);

// Smooth data
{ a_smooth, p_smooth } = kalmanSmooth(ssm, rslt);

The first five observations of the filtered state variable compared to the smoothed state variable are:

rslt.filtered_state[1:5]
 1119.830917
 1140.845842
 1072.750253
 1117.275521
 1129.948494

a_smooth[1:5]
 1111.623497
 1110.824812
 1105.241488
 1113.497953
 1112.364977

Source

ssmain.src

See also

Functions ssgetAICC(), ssgetBIC(), ssgetHQIC()