| Libgretl Reference Manual |
|---|
kalmankalman — |
typedef kalman; kalman* kalman_new (const gretl_matrix *S, const gretl_matrix *P, const gretl_matrix *F, const gretl_matrix *A, const gretl_matrix *H, const gretl_matrix *Q, const gretl_matrix *R, const gretl_matrix *y, const gretl_matrix *x, gretl_matrix *E, int ncoeff, int ifc, int *err); void kalman_free (kalman *K); int kalman_forecast (kalman *K); int kalman_get_ncoeff (const kalman *K); double kalman_get_loglik (const kalman *K); double kalman_get_arma_variance (const kalman *K); int kalman_set_initial_state_vector (kalman *K, const gretl_matrix *S); int kalman_set_initial_MSE_matrix (kalman *K, const gretl_matrix *P); void kalman_set_nonshift (kalman *K, int n); void kalman_use_ARMA_ll (kalman *K);
kalman* kalman_new (const gretl_matrix *S, const gretl_matrix *P, const gretl_matrix *F, const gretl_matrix *A, const gretl_matrix *H, const gretl_matrix *Q, const gretl_matrix *R, const gretl_matrix *y, const gretl_matrix *x, gretl_matrix *E, int ncoeff, int ifc, int *err);
Allocates and initializes a Kalman struct, which can subsequently
be used for forecasting with kalman_forecast(). The nomenclature
for the various required matrices is that in Hamilton's Time
Series Analysis (1994, chapter 13), except that "S" is used in
place of Hamilton's \xi for the state vector.
S : |
initial state vector. |
P : |
initial MSE matrix. |
F : |
state transition matrix. |
A : |
matrix of coefficients on exogenous variables in the observation equation. |
H : |
matrix of coefficients on the state variables in the observation equation. |
Q : |
contemporaneous covariance matrix for the errors in the state equation. |
R : |
contemporaneous covariance matrix for the errors in the
observation equation (or NULL if this is not applicable).
|
y : |
T x n matrix of dependent variable(s). |
x : |
T x k matrix of exogenous variable(s). May be NULL if there
are no exogenous variables, or if there's only a constant.
|
E : |
T x n matrix in which to record forecast errors (or NULL).
|
ncoeff : |
number of adjustable coefficients (used when the Kalman filter is employed for estimation purposes). |
ifc : |
|
err : |
location to receive error code. |
| Returns : | pointer to allocated struct, or NULL on failure, in
which case err will receive a non-zero code.
|
int kalman_forecast (kalman *K);
Generates a series of one-step ahead forecasts for y, based on
information entered initially using kalman_new(), and possibly
modified using kalman_set_initial_state_vector() and/or
kalman_set_initial_MSE_matrix(). The log-likelihood is
calculated for the sequence of forecast errors on the assumption
of normality: this can be accessed using kalman_get_loglik().
If E is non-NULL, the forecast errors are recorded in this
matrix.
K : |
pointer to Kalman struct: see kalman_new().
|
| Returns : | 0 on success, non-zero on error. |
int kalman_get_ncoeff (const kalman *K);
K : |
pointer to Kalman struct. |
| Returns : | the number of adjustable coefficients associated with the Kalman filter. |
double kalman_get_loglik (const kalman *K);
Retrieves the log-likelhood calculated via a run of
kalman_forecast().
K : |
pointer to Kalman struct. |
| Returns : | ll value, or NADBL on failure. |
double kalman_get_arma_variance (const kalman *K);
Retrieves the estimated variance for an ARMA model estimated using the Kalman filter.
K : |
pointer to Kalman struct. |
| Returns : | sigma-squared value, or NADBL on failure. |
int kalman_set_initial_state_vector (kalman *K, const gretl_matrix *S);
Resets the initial value of the state vector in a Kalman
struct, using the values from S. See also kalman_new().
K : |
pointer to Kalman struct. |
S : |
matrix of values to set. |
| Returns : | 0 on success, non-zero on error. |
int kalman_set_initial_MSE_matrix (kalman *K, const gretl_matrix *P);
Resets the initial value of the MSE matrix in a Kalman
struct, using the values from P. See also kalman_new().
K : |
pointer to Kalman struct. |
P : |
matrix of values to set. |
| Returns : | 0 on success, non-zero on error. |
| << forecast | Descriptive statistics and tests >> |