illustrate matrix manipulations. Consider the first five lines of Program 5.3 on the file
CHAPTER5.PRG:
compute number = 24
all number
com alpha = ||1.1, -.4, .2 ||
com beta = ||-.7, .3||
The first two lines set the default length of any series to 24. You can change the value of
“number” to obtain a smaller or larger number of impulse responses.
The third and fourth lines create the vectors alpha and beta. The two vectors hold the
coefficients of the ARMA model. Here you can enter as many or as few values for αi and βi as
desired. In the example, α1 = 1.1, α2 = -0.4, α3 = 0.2, β1 = -.7 and β2 = 0.3. Hence, these first
four lines have accomplished task 1. However, we did not DECLARE either alpha or beta to be
vectors—refer to the individual elements of each as alpha(1,1), alpha(1,2), alpha(1,3), beta(1,1)
and beta(1,2).
Now we need to do some bookkeeping. Our first bookkeeping task is to compute values of p and
q, i.e., the dimensions of the alpha and beta vectors. The function %cols(A) returns the number
of columns in matrix A. Hence, we can obtain p and q using:
compute p = %cols(alpha)
compute q = %cols(beta)
Unless otherwise specified, creation of a literal vector using COMPUTE causes RATS to create
a row vector. Hence, alpha has 1 row and 3 columns while beta has 1 row and 2 columns.
Next, we need to set up a vector—that we call phi—to hold the twenty-four values of the {φi}.
However, there is a small problem in that a vector cannot have an element zero. Thus, we cannot
use the notation φ0, φ1 … because we cannot have an element of a vector designated as phi(0).
Instead, we need to store the first value of φ in phi(1), the second value in phi(2), … . Thus,
phi(1) will equal 1, phi(2) will equal β1 + α1phi(1), … . In essence, we need to create the phi
vector such that phi(1) = φ0, phi(2) = φ1, … Hence, we will replace the usual formula for
calculating impulse responses with:
φ1 = 1
Σ=
+ + − = +
j
k
j j k j k
1
1 1 φ β α φ for j = 1, 2, 3, … , 23
We can DECLARE the phi vector to contain 24 elements and initialize the first value phi(1) = 1
com phi(1) = 1.
We cannot directly use the formula above since αk is undefined for k > p and βj is undefined for j
> q. The final bookkeeping task concerns treatment of these values. One straightforward method
is to define two new vectors of dimension 24. We can let the first p elements of vector A hold the
elements of alpha and set the remaining values to zero. Similarly, we can let the first q elements
of vector B hold the elements of beta and set the remaining values to zero.
dec vect a(number) b(number)
com a = %const(0.) , b = %const(0.)
ewise a(i) = %if(i<=p, alpha(1,i), 0.0)
ewise b(i) = %if(i<=q ,beta(1,i), 0.0)
Hence, the DECLARE instruction in the program segment above creates the vectors A and B and
sets the dimension of each to 24. COMPUTE uses the %CONST(x) instruction to set all values
of A and B to equal the constant zero.36 Next, looping over p, equates the first p values of A with
the corresponding elements of alpha. Similarly, looping over q sets the first q elements of B
equal to the corresponding elements of beta. Finally, we can write a routine that calculates the
remaining values of phi.
do j = 1,number-1
com phi(j+1) = b(j)
do k = 1,j ; com phi(j+1) = phi(j+1) + phi(j+1-k)*a(k) ; end do k
end do j
The first loop initializes phi(j+1) equal to βj. Each time through the inner loop (i.e., for each
value of k), αkφj+1-k is added to phi(j+1). Exiting this inner loop yields the desired sum:
Σ=
+ + − = +
j
k
j j k j k
1
1 1 φ β α φ
This process is repeated for each value of j up to and including j = 23.
The last task is to create a bar graph of the phi sequence. Since phi is a vector, it cannot be
graphed directly. However, we can convert phi into a series called response and graph response
using:
set response = phi(t)
gra(style=bar,heade