vector_autoregression

Estimates a vector auto-regressive time series model with optional moving average components.

Synopsis

#include <imsls.h>

float *imsls_f_vector_autoregression (int n_obs, int n_cols, float y[], int p, 0)

The type double function is imsls_d_vector_autoregression.

Required Arguments

int n_obs (Input)
The number of rows in y. n_obs is equal to the number of observations of each time series.

int n_cols (Input)
The number of columns in y. n_cols = K, the number of individual time series.

float y[] (Input)
An array of size n_obs by n_cols containing the data.

int p (Input)
The autoregressive lag order.

Return Value

An array containing the estimated coefficients. The array has length n_cols×(trend+n_xvars+n_cols×(p+q+1)) if a non-trivial A0 is included in the model. Otherwise, the array has length n_cols×(trend+n_xvars+n_cols×(p+q)). trend = 1 if IMSLS_TREND is specified, and 0 otherwise.

The array elements occur in this order:

If IMSLS_TREND is specified, the trend coefficient vector (b0) of length K (K=n_cols).
The coefficient matrix for the deterministic variables (D), of size K by n_xvars, oriented by column.
The p (or p+1) autoregressive coefficient matrices (A), each of size K by K, oriented by column.
The q moving average coefficient matrices (M), each of size K by K, oriented by column.

This arrangement corresponds to the vectorized coefficient matrix,

B = vec[b0DA0A1ApM1M2Mq]

or

B = vec[b0DA1ApM1M2Mq]

See also optional argument IMSLS_RETURN_USER for a different form of these output values. To release this space, use imsls_free. If no value can be computed, or IMSLS_RETURN_USER is supplied, returns NULL.

Synopsis with Optional Arguments

#include <imsls.h>

float *imsls_f_vector_autoregression (int n_obs, int n_cols, float y[], int p,
IMSLS_MA_LAG, int q,
IMSLS_A0,
IMSLS_AR_MODEL, int ar[],
IMSLS_MA_MODEL, int ma[],
IMSLS_AR_CONSTANTS, float ar_c[],
IMSLS_MA_CONSTANTS, float ma_c[],
IMSLS_PRESAMPLE, int n_T,
IMSLS_MAX_LAG, int max_lag,
IMSLS_N_STEPS, int max_steps,
IMSLS_MAX_ITERATIONS, int max_iter,
IMSLS_TOLERANCE, float tol,
IMSLS_TREND,
IMSLS_SCALE,
IMSLS_CENTER,
IMSLS_X_DATA, int n_xvars, float x[],
IMSLS_ERROR_CORRECTION, int irank,
IMSLS_CAUSALITY, int size_S1, int S1[], int S2[],
IMSLS_CAUSALITY_STATS, float stats[],
IMSLS_VAR_INFO, Imsls_f_regression **var_info,
IMSLS_VARMA_INFO, Imsls_f_regression **varma_info,
IMSLS_UNIT_ROOT, f_complex **ur_evals,
IMSLS_UNIT_ROOT_USER, f_complex ur_evals[],
IMSLS_VECM_COEF, float **vecm_coef,
IMSLS_VECM_COEF_USER, float vecm_coef[],
IMSLS_VECM_EIGENVALUES, f_complex **vecm_eigens,
IMSLS_VECM_EIGENVALUES_USER, f_complex vecm_eigens[],
IMSLS_VECM_ALPHABETA, float **vecm_alphabeta,
IMSLS_VECM_ALPHABETA_USER, float vecm_alphabeta[],
IMSLS_FORECASTS, float **forecasts,
IMSLS_FORECASTS_USER, float forecasts[],
IMSLS_CRITERIA, float criteria[],
IMSLS_LOG_LIKELIHOOD, float *ll,
IMSLS_RETURN_USER, float b0[], float d[], float a[], float m[],
0)

Optional Arguments

IMSLS_MA_LAG, int q (Input)
Fit a moving average component of order q.
Default: q = 0.

IMSLS_A0, (Input)
Indicates that the model has a non-trivial, lower-triangular leading AR operator, A0. See the Description section for more details. By default, A0 = Ik, where K = n_cols and Ik is the K by K identity matrix.

IMSLS_AR_MODEL, int ar[] (Input)
An array used to specify restrictions on the AR coefficient matrices. If IMSLS_A0 is present, ar is of length K by K by (p+1). If IMSLS_A0 is not present, ar is K by K by p. Each element of ar should be one of {-1, 0, 1}. If IMSLS_A0 is present, indicating a non-trivial A0, the ordering of AR corresponds to the parameters as follows:

[α11,0,α21,0 αK1,0,,α1K,0, α2K,0αKK,0,

α11,1, α21,1αK1,1, , α1K,1,α2K,1αKK,1,

α1K,p,α2K,p, ,αKK,p]

If A0 is trivial (equal to the identity matrix), the ordering is the same but the elements αKi,0 are left out and the first element is α11,1. If ar[i]=1 or ar[i]=-1, A(k,i) = αki,j is estimated. If ar[i]=0, the parameter is restricted to be equal to 0 or some other constant. Constants other than 0 can be specified in the optional argument IMSLS_AR_CONSTANTS. By default, all parameters are estimated.
Default: ar[i] = 1.

IMSLS_MA_MODEL, int ma[] (Input)
An array of length K by K by (q+1)if IMSLS_A0, or K by K by q if not IMSLS_A0. ma is used to specify restrictions on the moving-average coefficients. ma is constructed analagously to the ar restriction matrix detailed above. If IMSLS_A0, the first K by K by 1 entries in ma are only used when ar is not provided, because it is assumed that M0 = A0 .
Default: ma[i] = 1.

IMSLS_AR_CONSTANTS, float ar_c[] (Input)
An array of length K by (p+1)(or K by p) specifying the constants when certain of the AR parameters are restricted. Note that a lower triangular A0 is always assumed, with 1's on the diagonal. However, constants for the lower triangle can be specified using this optional argument.
Default ar_c[i] = 0.

IMSLS_MA_CONSTANTS, float ma_c[] (Input)
An array of length K by (q+1)(or K by q) specifying the constants when certain of the MA parameters are restricted. Note that the leading MA coefficient matrix M0 = A0 and thus there is no specification for it.
Default ma_c[i] = 0.

IMSLS_PRESAMPLE, int n_T (Input).
Specifies the number of rows of y to use as a presample in the estimation procedure. n_T must be strictly greater than 0.

Default n_T = max_lag.

IMSLS_MAX_LAG, int max_lag (Input)
Specifies the maximum AR order or lag to use in the unrestricted VAR model. max_lag must be strictly greater than 0.
Default: max_lag = 6.

IMSLS_N_STEPS, int max_steps (Input)
Specifies the maximum number of steps ahead. When requested, forecasts are produced for times t+h where h = 1, 2, max_steps and t = n_T, n_T+1, n_obs.
Default: max_steps = 4.

IMSLS_MAX_ITERATIONS, int max_iter (Input)
Specifies the maximum number of iterations. max_iter > 0.
Default: max_iter = 100.

IMSLS_TOLERANCE, float tol (Input)
Specifies the error tolerance used in the iterations.
Default: tol = 100×imsls_f_machine(4).

IMSLS_TREND, (Input)
Indicates that a constant trend (intercept) term should be included in the model.
Default: No trend.

IMSLS_SCALE, (Input)
Indicates that the data series in y should be centered and then scaled before the analysis begins.
Default: No scaling.

IMSLS_CENTER, (Input)
Indicates that the data series in y should be centered before the analysis begins. Note that if IMSLS_SCALE is provided, IMSLS_CENTER has no effect.
Default: No centering.

IMSLS_X_DATA, int n_xvars, float x[] (Input)
Input values of the deterministic variables.

int n_xvars (Input)
The number of deterministic variables.

float x[] (Input)
The n_obs by n_xvars array containing the values of the deterministic variables. Note that if x is provided when forecasts are requested, x must have additional rows that can be used for the forecasts. That is, x is an array of at least (n_obs + max_steps) rows by n_xvars.
Default: n_xvars = 0.

IMSLS_ERROR_CORRECTION, int irank (Input)
Estimate the error-correcting form of the VAR model assuming the series are integrated of order 1 and there are 0 <= irank <= n_cols co-integrating relationships. When irank=0, the error-correcting model is not estimated.
Default: irank = 0.

IMSLS_CAUSALITY, int size_S1, int S1[], int S2[] (Input)
Specification for a test of Granger causality.

int size_S1 (Input)
The number of variables with indices given in array S1. 0 <= size_S1 < n_cols. No test is performed when size_S1 = 0.
Default: size_S1 = 0.

float S1[] (Input)
An array of length size_S1 containing the indices of the variables that are not Granger-caused by the variables specified in S2, under the null hypothesis. Each index must be between 1 and n_cols inclusive and must not equal any index in S2.

float S2[] (Input)
An array of length n_cols-size_S1 containing the indices of the variables that do not Granger-cause the variables specified in S1, under the null hypothesis. Each index must be between 1 and n_cols inclusive and must not equal any index in S1.

IMSLS_CAUSALITY_STATS, float stats[] (Output)
An array of length 2 containing the test statistic value and associated p-value resulting from the requested Granger causality test. It is an error to request this output without specifying the test using IMSLS_CAUSALITY.

IMSLS_VAR_INFO, Imsls_f_regression **var_info (Output)
Contains the regression information from the first stage fitting of the model, VAR(max_lag). This structure may be used as input to imsls_f_regression_summary. See also imsls_f_regression optional argument IMSLS_REGRESSION_INFO.

IMSLS_VARMA_INFO, Imsls_f_regression **varma_info (Output)
Contains the regression information from the second stage fitting of the model. VARMA(p,q). This structure may be used as input to imsls_f_regression_summary. See also imsls_f_regression optional argument IMSLS_REGRESSION_INFO.

IMSLS_UNIT_ROOT, f_complex **ur_evals (Output)
Address of a pointer to a complex array of length K by(p+q) containing the eigenvalues of the determinantal polynomial.

IMSLS_UNIT_ROOT_USER, f_complex ur_evals[] (Output)
Storage for the array ur_evals is provided by the user.

IMSLS_VECM_COEF, float **vecm_coef (Output)
Address of a pointer to an array of length K by K by (p+1)or (K by K by p) containing the estimated parameters when the model is put into the error-correcting form.

IMSLS_VECM_COEF_USER, float vecm_coef[] (Output)
Storage for the array vecm_coef is provided by the user.

IMSLS_VECM_EIGENVALUES, f_complex **vecm_eigens (Output)
Address of a pointer to an array of length K containing the eigenvalues associated with each cointegrating rank r0 <= r <= K.

IMSLS_VECM_EIGENVALUES_USER, f_complex vecm_eigens[] (Output)
Storage for the array vecm_eigens is provided by the user.

IMSLS_VECM_ALPHABETA, float **vecm_alphabeta (Output)
An array of length 2×(K by irank) containing the estimates of the coefficient matrix of the error-correction model. The first K by irank elements correspond to α and the second irank by K elements correspond to β.

IMSLS_VECM_ALPHABETA_USER, float vecm_alphabeta[] (Output)
Storage for the array vecm_alphabeta is provided by the user.

IMSLS_FORECASTS, float **forecasts (Output)
An array of length n_obs by n_cols by max_steps containing the 1, 2, max_steps ahead forecasts based on the final fitted VARMA model.

IMSLS_FORECASTS_USER, float forecasts[] (Output)
Storage for the array forecasts is provided by the user.

IMSLS_CRITERA, float criteria[] (Output)
An array of size 4 containing AIC, BIC, HQ, and FPE fit critieria for the given model.

IMSLS_LOG_LIKELIHOOD, float *ll (Output)
Log–likelihood of the estimated VARMA(p,q) model.

IMSLS_RETURN_USER, float b0[], float d[], float a[], float m[] (Output)
Storage for the return value is supplied by the user in separate arrays.

float b0[] (Output)
If IMSLS_TREND is specified, the estimated constant trend coefficient of length K (K = n_cols) is returned in b0. If IMSLS_TREND is not specified, b0 is ignored and can be NULL.

float d[] (Output)
If n_xvars > 0, the estimated K by n_xvars coefficient matrix for the deterministic variables is returned in d. If n_xvars = 0, d is ignored and can be NULL.

float a[] (Output)
If IMSLS_A0 is specified, the estimated (p+1) autoregressive matrices, each of length K by K, are returned in a. If IMSLS_A0 is not specified, the (p) autoregressive matrices, each of length K by K, are returned in a. If p = 0, a is ignored and can be NULL. Note that if p = 0, q must be greater than 0 (and vice-versa).

float m[] (Output)
The estimated (q) moving average coefficient matrices, each of length K by K, are returned in m. If q = 0, m is ignored and can be NULL. Note that if q = 0, p must be greater than 0 (and vice-versa).

Description

This function estimates a vector-autoregression moving average model using one and two-stage multivariate least squares regressions.

The general model can be written in operator notation as

A(L)(yt-μ) = M(L)ut + Dxt

where yt is a K-dimensional real-valued time series with stationary mean μ , ut is a K-dimensional white noise series with a non-singular covariance matrix, Σu′ and xt respresents a matrix of deterministic components such as trend or seasonal variables. For autoregression (ar) lag parameter, p  0 , and moving average (ma) lag parameter, q  0, the operators are defined as

A(L) = A0-A1L-A2L2-…ApLp

M(L) = M0-M1L-M2L2-…MqLq

where L is the lag or backshift operator, defined as

Lyt = yt-1, Lkyt = yt-k

and the Aj, Mj are K×K matrices of coefficients. That is,

Aj(k,i) = [αki,j], k,i = 1, ,K, j = 0, p

Mj(k,i) = [mki,j], k,i = 1, ,K, j = 0, q

The model has many equivalent forms, such as

A0(yt-μ) = A1(yt-1-μ) +   + Ap(yt-p-μ) + A0ut +  M1ut-1 + Mqut-q

A pure vector autoregression with q = 0 is often denoted VAR(p) and the autoregressive moving-average is VARMA(p,q).

The estimation procedures for the most part assume that the underlying time series is stable and invertible. These conditions are satisfied when

det(IK - A1z - - Apzp 0 for |z| 1 (stability condition)

det(IK + M1z + Mqzq 0 for |z| 1 (invertibility condition).

In other words, the conditions for a stable and invertible process are that the roots of the determinantal polynomial are outside the (complex) unit circle, or equivalently, that the eigenvalues of the determinantal matrix have modulus less than 1. To provide for unit-root tests, this function returns the eigenvalues of the estimated model via the optional argument IMSLS_UNIT_ROOT. In the case of unit-roots, when some fall on the unit circle (|z| = 1) there may still be stationary combinations of the variables. This behavior, known as cointegration, is discussed below.

Error-Correction form and Cointegration

Another form of expressing the VARMA(p,q) model is the error-correcting form:

A0Δyt = Πyt-1 + Γ(L)Δyt + M(L)ut

where

Π = -(A0-A1-…-Ap),

Γ(L) = (Γ1L + Γ2L2 +  + ΓpLp), and

M(L) = (M0 + M1L +  + MqLq) .

The error-correcting or error-correction model (ECM) was developed for economic variables that tend to track close to each other due to common trends. The concept is closely aligned with that of cointegration. A K-dimensional process is said to be integrated of order 1, denoted as yt ~ I(1), when yt is non-stationary while the first-differenced series, Δyt, is stationary. In this case, there may exist a stationary linear combination in the levels (non-differenced versions). That is, there may exist a

zt = βyt = β1ty1t + β2ty2t +  βKtyKt ,

where at least one βit  0 such that zt is stationary.

The interpretation is that cointegrated variables have common trends that cause them to move together in some sense. Consider the price of a commodity in two different locations. At their individual levels, they are non-stationary, unpredictable processes, but market forces keep the two prices from being too far apart so the difference in their prices is stationary.

We obtain an estimate of each coefficient matrix in the ECM form of the model. Then we are interested in the decomposition of Π = αβ where α,β are K×irank (rank irank coefficient matrices). From the ECM form it can be deduced that zt = βyt is the cointegrating relationship under the given assumptions. However, the cointegrating rank r is not known in practice. As discussed in Lütkepohl, 2007, Ch. 7, the most common tests for the correct cointegrating rank are

H0 : r = r0 vs H1 : r0 < r  K

and

H0 : r = r0 vs H1 : r = r0 + 1

The likelihood ratio test statistic for testing the first hypothesis is known as the trace test, and the second is known as the maximum eigenvalue test (Johansen 1988, 1995). In particular,

 

where λ1    λK are eigenvalues of a particular matrix associated with the likelihood function. To allow for various tests, this function returns the eigenvalues λ1    λK through the optional argument IMSLS_VECM_EIGENVALUES.

The Granger-Causality Test

Partition the K- dimensional time series as yt = (zt,xt), where zt is of length m and xt is of length K-m. In general, xt is said to Granger-cause zt when predictions for zt can be improved by taking xt into account, and vice-versa. In the context of a stable and invertible VAR(p) or VARMA(p,q) process, a test for Granger causality amounts to testing for certain 0 restrictions on the AR or MA coefficients. Given a partition yt = (zt,xt), the test of

H0 : xt does not Granger-cause zt

H1 : xt does Granger-cause zt

is performed using a version of the Wald statistic which has an approximate F-distribution,

λW / N  F(N,T - K(p + q- 1)

where N is the number of 0 restrictions induced by the test. This function returns the test statistic and associated p-value when a test is specified through the optional argument IMSLS_CAUSALITY.

Comments

1.   There are different notational conventions in the literature. Box, Jenkins, and Reinsel typically use (φ,Θ) in place of (A,M) and B instead of L for the backshift or lag operator. Because it is the main reference for this implementation, we follow the notation used by Lütkepohl (2007).
2.   The two-stage regression approach is robust in the sense that results are produced even when there are roots close to 1 or less than 1 (in modulus). The estimates can be tested for unstable roots using the optional argument IMSLS_UNIT_ROOT.
3.   In general a collection of K time series yt = (y1ty2tykt) is said to be cointegrated of order (d-b) when they are each individually integrated of order d, but there exists a linear combination zt = βyt = β1ty1t + β2ty2t +  βKtyKt, with βit  0 for at least one i, which is integrated of order b. In this implementation, only the case where d = 1 and b = 0 is considered. An even more general situation allows the individual time series to have differing orders of integration. For more details, see, for example, Engle and Granger, (1991).

Examples

Example 1

In this example we use a small data set with 2 time series. A VARMA(1,0) model is requested.

 

#include <imsls.h>

#include <stdlib.h>

 

int main(){

int n_obs=20, n_cols=2;

int p=1;

float *coef=NULL;

 

float y[]={0, 0,

-0.148105526820657, 0.0507420782620461,

-1.13674727366735, 0.862892721126079,

1.54366183541037, -1.13804802266371,

-0.0923211737957721, 1.65649055346038,

0.521764564424907, -2.11208211206815,

0.843683397890515, 2.56656798707681,

-2.70330819114831, -2.83452914666041,

4.93683704766295, 3.95965377457266,

-4.78314880243807, -2.23136673998374,

6.24911547448071, 0.40543051970714,

-6.76582567372196, 0.816818897274206,

6.21142944093012, -4.247694573354,

-5.29817270483491, 5.08246614505046,

4.19557583927549, -5.35697380907112,

-3.21572784971078, 7.89716072829777,

0.485717553966479, -8.25930665413043,

2.69490292018773, 10.9017252520684,

-5.41090143363388, -10.400477539227,

8.29423327234419, 9.10321370415527};

 

coef=imsls_f_vector_autoregression(n_obs, n_cols, y, p, 0);

 

imsls_f_write_matrix("A1", 2, 2, coef,

IMSLS_TRANSPOSE,

0);

 

if(coef){

imsls_free(coef);

coef = NULL;

}

}

Output

 

A1

1 2

1 -1.017 -0.296

2 0.273 -1.053

Example 2

In this example, we fit the unrestricted VARMA(1,1) model and request 1 and 2 step ahead forecasts for each observation.

 

#include <imsls.h>

#include <stdlib.h>

 

int main(){

int n_obs=50, n_cols=2, p=1, q=1, max_step=2;

float forecasts[2*2*50];

float *coef = NULL;

 

char *clabel[] = {"t","t+1,Y1","t+1,Y2 ", "t+2, Y1","t+2, Y2"};

 

float y[]=

{

0.143280117400598, 0.691517079320758, -1.054002748442,

1.89368500251305, -0.595435384283415, -1.53385197609914,

-0.450087415747451, -0.522758296071267, 0.338719815948114,

1.73890633300759, -0.0420130132503371, -0.00933890926865466,

-0.939527210947825, -0.279211957506804, 0.985111509818102,

-0.185903912738057, -0.779058630583496, -1.52829111438157,

-0.0444517646926054, -0.605935345974391, 1.17870357395841,

0.979822006409954, -1.75509211790604, -1.02617250037744,

-2.64443752185661, -0.405444884498378, -0.558146570012133,

1.17006139568333, -0.14877513906561, 1.67436399145195,

1.21251151094695, -0.236411746432856, -0.319260279201159,

1.53774676549506, -0.798919508505848,-1.25907348772775,

-0.43488363747126, 1.18754392780486, 2.49394567166528,

-0.505392075680617, -0.939902530453777, -1.3000118234638,

0.308365204823071, -0.0346715133254558, 0.155821836363299,

1.53865066350577, -0.446013548645569, 0.421382795732249,

-0.810472750765929, -0.475790066827614, -1.21547965787564,

0.873092852598299, 0.314687304446453, -0.166494291509063,

1.20846773815425, -0.21319122737697, 0.885697825416125,

1.06749862455588, -0.417811475765902, 1.81350258917296,

1.06312903931625, -0.357098401483029, -2.54962241395723,

1.58241298127273, -0.445333714405381, -1.54921054521057,

0.763932954657703, -0.459132068443737, -0.135020632775658,

0.768987806710127, -2.21000914520305, -0.416578967811937,

-0.787803924930718, -0.381994679294779, 0.651886558080692,

-0.296275077784937, -1.34100151116192, -0.695511844572305,

-1.38111408367782, -0.453263483406621, 0.546836142779091,

1.35617195687341, 1.47675672302528, -0.879275538764735,

1.33724523036386,-1.19560541543992, -0.355724070126155,

-1.35440645398376, 0.215557787562229, -0.0705280128055462,

2.64174061572298, 0.622022977819918, 1.85193603585307,

1.1425463214074, 1.47034707550646, -0.274392879035261,

-0.0256438865664471, -1.32768501270967, 1.4002259906097,

-1.13393234222336, 0.420685154939234, -1.14369662556446,

-0.229525100642792,-1.14556440309372, -0.0726173507068031,

0.537003424016424, 2.21081287812981, -0.329847605902733,

0.658135565199115, 1.25161597712012, 0.324279854980608,

-0.122777642651712, -0.746398274242844, -0.510384971856952,

-1.52397549713935,-0.590932096161281, 0.351879848132452,

-0.486815223667361, -0.582122931146207, -0.129708090826525,

-1.83261132721672, -0.438855077878885, 0.160891671954672,

0.130903505342111, -1.0930038744212, 0.858667240391389,

-0.650140333935879, -0.192590383440759, -0.495902099869389,

-0.0970274914548782, 0.271597266914655, -1.25629606008009,

-1.82411099200514, -0.0862331652538604, -1.48736902275701,

-0.702589236231933, 1.66371111576656, 0.260453048198016,

0.472465295167692, 2.03959666287312, -1.47220802239244,

0.584452376204567, 0.29538916638251, -0.424471774108761,

1.35117053520231, 0.792966672512426, 0.559666965721712,

1.03877148575442, 0.32764651319845, 0.792431599069095,

1.79713629328279, 2.53306185903747, 0.382061987152509,

-0.55974023663989, 0.261351966632211, 0.928359586004826,

1.05805881312766, -0.448798293155081, -2.8433140252059,

-1.29380365284521, 1.60167210548413, -0.58790657908656,

-0.0697276516437701, 0.669259446155372, -0.756109095074059,

-1.04262502361173, -0.689533522981508, 0.322514092974764,

-0.62456134593389, 0.343601164613668, 0.406496690190247,

-0.579352431691941, -0.38067184267295, 1.15818332237678,

-1.3763494217139, 1.07842256464695, -0.607885118048254,

-0.551750338671028, -0.688013574614753, -0.66192239892944,

0.840882344143739, 0.501181908666563, 0.810882707408453,

-0.373132840815414, -1.53884108045858, -0.0475950419868607,

-1.11456391432642, -1.39312192248506, 0.374292584707849,

0.307055843720151, 0.0883771102062163, 1.51499635303431,

0.544284404231116, 1.62863647405725, 0.666268752934375,

3.15259591439161, 0.535584045927088, 0.438326104669433,

1.25375087298954, 1.2784768691421

};

 

coef = imsls_f_vector_autoregression(n_obs, n_cols, y, p,

IMSLS_MA_LAG, q,

IMSLS_N_STEPS, max_step,

IMSLS_FORECASTS_USER, forecasts,

0);

 

imsls_f_write_matrix("* * * Forecasts * * *\n", n_obs, n_cols*max_step,

forecasts,

IMSLS_COL_LABELS, clabel,

0);

 

if(coef){

imsls_free(coef);

coef = NULL;

}

}

Output

 

* * * Forecasts * * *

 

t t+1,Y1 t+1,Y2 t+2, Y1 t+2, Y2

1 0.000 0.000 0.000 0.000

2 0.000 0.000 0.000 0.000

3 0.000 0.000 0.000 0.000

4 0.000 0.000 0.000 0.000

5 0.000 0.000 0.000 0.000

6 0.000 0.000 0.000 0.000

7 0.009 -0.739 0.002 -0.086

8 -0.501 0.893 -0.017 -0.050

9 0.773 -1.779 0.024 -0.479

10 -0.935 0.042 -0.038 -0.251

11 0.164 0.959 -0.067 0.306

12 0.393 -1.377 0.009 -0.263

13 -0.672 -0.873 0.013 -0.058

14 -0.447 0.644 0.036 0.368

15 0.187 1.540 0.027 0.689

16 0.897 -0.117 0.191 -0.172

17 0.020 0.621 -0.039 0.556

18 0.008 -1.719 0.079 -0.444

19 -1.059 0.790 -0.056 0.397

20 0.193 0.264 0.035 -0.319

21 0.194 -1.050 -0.121 -0.377

22 -0.415 0.529 -0.042 0.039

23 0.433 0.658 0.048 0.495

24 0.074 0.493 0.044 0.235

25 0.402 -1.035 0.114 -0.230

26 -0.634 0.428 -0.073 0.351

27 0.109 -0.094 0.059 -0.061

28 -0.026 0.133 0.009 -0.164

29 0.067 1.258 -0.078 0.435

30 0.677 0.780 0.105 0.674

31 0.210 -0.299 0.145 -0.250

32 -0.200 -0.262 -0.086 0.671

33 -0.656 -1.024 0.134 -0.676

34 -0.351 -0.130 -0.169 -0.188

35 -0.152 0.708 -0.084 0.377

36 0.351 -1.377 0.122 -0.147

37 -0.826 -0.399 -0.026 -0.125

38 -0.256 0.717 -0.018 -0.026

39 0.716 -0.898 0.071 -0.139

40 -0.316 -1.153 0.058 -0.236

41 -0.804 1.543 -0.100 0.486

42 0.765 0.139 0.071 -0.257

43 0.443 -0.054 0.039 -0.434

44 0.345 -1.797 -0.050 -0.503

45 -1.165 0.730 -0.124 -0.028

46 0.531 1.303 -0.022 0.174

47 0.765 1.889 0.014 0.390

48 1.281 0.188 0.069 -0.089

49 0.306 -1.741 0.017 -0.569

50 -1.140 0.239 -0.172 -0.441

Example 3

In this example we fit the following VARMA(1,1) restricted model on simulated data of two dimensions:

 

In this specification there are 7 free parameters:

 = (α21,0α11,1α21,1α12,1α22,1α21,1α12,1)

The first stage and the second stage results are shown. From the second stage results, we see that (to two decimals) the estimate is

 = (-0.03, 0.00, 0.05, -0.01, -0.06, 0.01)

#include <imsls.h>

#include <stdlib.h>

 

int main(){

int k, n_obs=100, n_cols=2, p=1, q=1;

int ar[]={0, -1, 0, 0, 1, 1, 1, 1};

int ma[]={0, -1, 0, 0, 0, 1, 1, 0};

float ar_c[]={1, 0, 0, 1, 0, 0, 0, 0};

float ma_c[]={1, 0, 0, 1, 0, 0, 0, 0};

float *coef=NULL;

int max_lag=6, n_coef1, n_coef2;

float *coef_ttests1=NULL, *coef_ttests2=NULL;

Imsls_f_regression *stage1_var_info=NULL;

Imsls_f_regression *stage2_varma_info=NULL;

char *clabel[] = {"id", "coef", "SE", "t-stat", "p-value"};

 

float y[]=

{

0.143280117400598, 0.691517079320758, -1.054002748442,

1.89368500251305, -0.595435384283415, -1.53385197609914,

-0.450087415747451, -0.522758296071267, 0.338719815948114,

1.73890633300759, -0.0420130132503371, -0.00933890926865466,

-0.939527210947825, -0.279211957506804, 0.985111509818102,

-0.185903912738057, -0.779058630583496, -1.52829111438157,

-0.0444517646926054, -0.605935345974391, 1.17870357395841,

0.979822006409954, -1.75509211790604, -1.02617250037744,

-2.64443752185661, -0.405444884498378, -0.558146570012133,

1.17006139568333, -0.14877513906561, 1.67436399145195,

1.21251151094695, -0.236411746432856, -0.319260279201159,

1.53774676549506, -0.798919508505848,-1.25907348772775,

-0.43488363747126, 1.18754392780486, 2.49394567166528,

-0.505392075680617, -0.939902530453777, -1.3000118234638,

0.308365204823071, -0.0346715133254558, 0.155821836363299,

1.53865066350577, -0.446013548645569, 0.421382795732249,

-0.810472750765929, -0.475790066827614, -1.21547965787564,

0.873092852598299, 0.314687304446453, -0.166494291509063,

1.20846773815425, -0.21319122737697, 0.885697825416125,

1.06749862455588, -0.417811475765902, 1.81350258917296,

1.06312903931625, -0.357098401483029, -2.54962241395723,

1.58241298127273, -0.445333714405381, -1.54921054521057,

0.763932954657703, -0.459132068443737, -0.135020632775658,

0.768987806710127, -2.21000914520305, -0.416578967811937,

-0.787803924930718, -0.381994679294779, 0.651886558080692,

-0.296275077784937, -1.34100151116192, -0.695511844572305,

-1.38111408367782, -0.453263483406621, 0.546836142779091,

1.35617195687341, 1.47675672302528, -0.879275538764735,

1.33724523036386,-1.19560541543992, -0.355724070126155,

-1.35440645398376, 0.215557787562229, -0.0705280128055462,

2.64174061572298, 0.622022977819918, 1.85193603585307,

1.1425463214074, 1.47034707550646, -0.274392879035261,

-0.0256438865664471, -1.32768501270967, 1.4002259906097,

-1.13393234222336, 0.420685154939234, -1.14369662556446,

-0.229525100642792,-1.14556440309372, -0.0726173507068031,

0.537003424016424, 2.21081287812981, -0.329847605902733,

0.658135565199115, 1.25161597712012, 0.324279854980608,

-0.122777642651712, -0.746398274242844, -0.510384971856952,

-1.52397549713935,-0.590932096161281, 0.351879848132452,

-0.486815223667361, -0.582122931146207, -0.129708090826525,

-1.83261132721672, -0.438855077878885, 0.160891671954672,

0.130903505342111, -1.0930038744212, 0.858667240391389,

-0.650140333935879, -0.192590383440759, -0.495902099869389,

-0.0970274914548782, 0.271597266914655, -1.25629606008009,

-1.82411099200514, -0.0862331652538604, -1.48736902275701,

-0.702589236231933, 1.66371111576656, 0.260453048198016,

0.472465295167692, 2.03959666287312, -1.47220802239244,

0.584452376204567, 0.29538916638251, -0.424471774108761,

1.35117053520231, 0.792966672512426, 0.559666965721712,

1.03877148575442, 0.32764651319845, 0.792431599069095,

1.79713629328279, 2.53306185903747, 0.382061987152509,

-0.55974023663989, 0.261351966632211, 0.928359586004826,

1.05805881312766, -0.448798293155081, -2.8433140252059,

-1.29380365284521, 1.60167210548413, -0.58790657908656,

-0.0697276516437701, 0.669259446155372, -0.756109095074059,

-1.04262502361173, -0.689533522981508, 0.322514092974764,

-0.62456134593389, 0.343601164613668, 0.406496690190247,

-0.579352431691941, -0.38067184267295, 1.15818332237678,

-1.3763494217139, 1.07842256464695, -0.607885118048254,

-0.551750338671028, -0.688013574614753, -0.66192239892944,

0.840882344143739, 0.501181908666563, 0.810882707408453,

-0.373132840815414, -1.53884108045858, -0.0475950419868607,

-1.11456391432642, -1.39312192248506, 0.374292584707849,

0.307055843720151, 0.0883771102062163, 1.51499635303431,

0.544284404231116, 1.62863647405725, 0.666268752934375,

3.15259591439161, 0.535584045927088, 0.438326104669433,

1.25375087298954, 1.2784768691421

};

 

coef=imsls_f_vector_autoregression(n_obs, n_cols, y, p,

IMSLS_MA_LAG, q,

IMSLS_A0,

IMSLS_AR_MODEL, ar,

IMSLS_MA_MODEL, ma,

IMSLS_MAX_LAG, max_lag,

IMSLS_AR_CONSTANTS, ar_c,

IMSLS_MA_CONSTANTS, ma_c,

IMSLS_VAR_INFO, &stage1_var_info,

IMSLS_VARMA_INFO, &stage2_varma_info,

0);

 

n_coef1=n_cols*max_lag;

 

for(k=0;k<n_cols;k++){

imsls_f_regression_summary(stage1_var_info,

IMSLS_INDEX_REGRESSION, k,

IMSLS_COEF_T_TESTS, &coef_ttests1,

0);

 

imsls_f_write_matrix("* * * VAR Stage 1 Coefficients * * *\n",

n_coef1, 4, coef_ttests1,

IMSLS_COL_LABELS, clabel,

0);

 

imsls_free(coef_ttests1);

}

 

/* stage 2 restricted model

estimates 1 A0 parameter, 4 A1 parameters, and 2 M1 parameters */

n_coef2=7;

 

imsls_f_regression_summary(stage2_varma_info,

IMSLS_COEF_T_TESTS, &coef_ttests2,

0);

 

imsls_f_write_matrix("* * * VARMA Stage 2 Coefficients * * *\n",

n_coef2, 4, coef_ttests2,

IMSLS_COL_LABELS, clabel,

0);

 

if(stage1_var_info){

imsls_free(stage1_var_info);

stage1_var_info=NULL;

}

if(stage2_varma_info){

imsls_free(stage2_varma_info);

stage2_varma_info=NULL;

}

if(coef){

imsls_free(coef);

coef=NULL;

}

if(coef_ttests2){

imsls_free(coef_ttests2);

coef_ttests2=NULL;

}

}

Output

 

* * * VAR Stage 1 Coefficients * * *

 

id coef SE t-stat p-value

1 0.229 0.110 2.075 0.041

2 0.292 0.125 2.345 0.021

3 -0.274 0.110 -2.501 0.014

4 -0.242 0.127 -1.896 0.062

5 0.372 0.116 3.208 0.002

6 0.280 0.128 2.198 0.031

7 -0.027 0.116 -0.232 0.817

8 -0.349 0.128 -2.722 0.008

9 0.240 0.109 2.208 0.030

10 0.296 0.128 2.316 0.023

11 -0.145 0.110 -1.323 0.190

12 -0.144 0.126 -1.136 0.259

 

* * * VAR Stage 1 Coefficients * * *

 

id coef SE t-stat p-value

1 0.182 0.099 1.840 0.069

2 0.177 0.112 1.577 0.119

3 -0.287 0.099 -2.907 0.005

4 0.064 0.115 0.561 0.577

5 0.075 0.104 0.721 0.473

6 0.066 0.115 0.579 0.564

7 -0.111 0.104 -1.066 0.290

8 -0.193 0.115 -1.675 0.098

9 -0.066 0.098 -0.675 0.501

10 0.018 0.115 0.160 0.873

11 0.034 0.099 0.348 0.729

12 0.092 0.114 0.813 0.418

 

* * * VARMA Stage 2 Coefficients * * *

 

id coef SE t-stat p-value

1 -0.099 0.232 -0.429 0.668

2 0.130 0.097 1.346 0.180

3 -0.050 0.208 -0.240 0.811

4 -0.618 0.242 -2.559 0.011

5 0.123 0.115 1.068 0.287

6 0.204 0.257 0.791 0.430

7 0.914 0.270 3.388 0.001