recserar命令可以生成AR(1)过程。
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.