|
recserar
Purpose
Computes a vector of autoregressive recursive series.
Format
y = recserar(x,y0,a);
Input
x
NxK matrix
y0
PxK matrix.
a
PxK matrix.
Output
y
NxK matrix containing the series.
Remarks
recserar is particularly useful in dealing with time series.
Typically, the result would be thought of as K vectors of length N.
y0 contains the first P values of each of these vectors (thus, these are prespecified). The remaining elements are constructed by computing a Pth order “autoregressive” recursion, with weights given by a, and then by adding the result to the corresponding elements of x. That is, the tth row of y is given by:
and
Note that the first P rows of x are not used.
Example
n = 10;
fn multnorm(n,sigma) = rndn(n,rows(sigma))*chol(sigma);
let sig[2,2] = { 1 -.3, -.3 1 };
rho = 0.5~0.3;
y0 = 0~0;
e = multnorm(n,sig);
x = ones(n,1)~rndn(n,3);
b = 1|2|3|4;
y = recserar(x*b+e,y0,rho);
In this example, two autoregressive series are formed using simulated data. The general form of the series can be written:
y[1,t] = rho[1,1]*y[1,t-1] + x[t,.]*b + e[1,t]
y[2,t] = rho[2,1]*y[2,t-1] + x[t,.]*b + e[2,t]
The error terms (e[1,t] and e[2,t]) are not individually serially correlated, but they are contemporaneously correlated with each other. The variance-covariance matrix is sig.
|