Group: | Random Variables |
See also: | genarma armacls armalik |
Function: | genar | |
Description: | generates autoregressive processes |
Usage: | y = genar(x, startval, alpha) | |
Input: | ||
x | n x d2 x ... x d8 array, each column represents one variable plus noise of an AR(p) process | |
startval | p x 1 vector or p x d2 x ... x d8 array, each column contains p starting values of an AR(p) process | |
alpha | p x 1 vector or p x d2 x ... x d8 array, each column contains p parameters of an AR(p) process | |
Output: | ||
y | n x d2 x ... x d8 array, each column contains one generated AR(p) process |
y_t = startval, t=1,...,p
y_t = x_t + alpha[1]*y_(t-1) + ... + alpha[p]*y_(t-p), t=p+1,...,n
Note that the first p values of x are not used.
randomize(0) x = normal(5) startval = 0 alpha = 0.1 ; generates one AR(1) process genar(x, startval, alpha)
Contents of genar [1,] 0 [2,] -1.0078 [3,] 1.8495 [4,] -1.1202 [5,] -1.5462
randomize(0) x = normal(6,3) startval = #(0,3)~#(0,3)~#(1,2) alpha = #(0.1,0.7)~#(1.5,2)~#(0.3,0.1) ; generates three AR(2) processes genar(x, startval, alpha)
Contents of genar [1,] 0 0 1 [2,] 3 3 2 [3,] 2.2502 4.2341 -0.029729 [4,] 1.0198 12.551 0.39972 [5,] 0.24301 24.791 -0.026641 [6,] 1.4363 61.794 0.65928