Moving Vectors and Matrices by IndexingΒΆ

A quick way to fill in values of a vector so that they all grow at the same rate is to use the index command. It is used in conjunction with a guide series, a previously established single-variable time series, whose growth rates will be applied to each element of the vector. It operates over the range currently specified by the fdates. The form is

index <base_date> <guide> <vector_name>

For example, if “years” is the name of a series that contains years – 1980, 1981, etc. – then to make all elements of the vector pce grow by 2.0 percent per year from 1999 to 2010, the following commands can be used:

f  g02 = @exp(0.02*(years - 1980))
index 1999 g02 pce

The use of groups is allowed in the names of series to be affected. For example, to move only the sectors 1,7, and 9 of pce, we could – recalling that ‘:’ is the name of the dynamic group – do

group 1 7 9
load pce
index  1999 g02 :

To move just the sectors in the static group Mfg, the command would be

load pce
index 1999 g02 :Mfg

With a specific “vector + sector” name like exp2, the command would be

index 1999 g02 exp2

to store the currently-loaded vector, load the exp vector, and move the series exp2 by the index of g02.

A vector or matrix name not followed by a sector number means to move all vector or matrix elements by the index. This device can be used to project an entire input-output matrix, say, am, to be constant, as in this example:

fdates 1998 2020
f one = 1
index 1998 one am

A matrix name followed without space by a sector number means to move that row of the matrix by the guide. Thus, am2 means move the second row of the am matrix by the guide.

If <guide> is the name of a vector and <name> is a matrix, then the rows of the matrix will be indexed by the corresponding elements of the vector. If an element of the vector is zero in the base year, the corresponding rows of the matrix are unchanged. This feature works both for standard and packed matrices. It can be used to apply across-the-row coefficient changes to an input-output matrix. For example, if movers is a vector, we can make each row of the am matrix follow the index of the corresponding element of movers by

fdates 1998 2020
index 1998 movers am

In applying this sort of across-the-row coefficient change, one usually does not want it to apply to the diagonal elements, for they have little to do with the technological changes affecting other coefficients. To avoid changing them, the following two commands are convenient.

diagextract <matrix_name> <vector_name>
Extract diagonal elements from the matrix and put them into the named vector. The command works both for regular and packed matrices.
diaginsert <matrix_name> <vector_name>
Insert elements in the named vector into the diagonal of the matrix. The diagonal element will remain zero for a packed matrix that has zero coefficients in that position for all years.

This example combines these last three commands

fdates 1998 2020
diagextract  am  diags
index 1998 movers am
diaginsert  am diags

Previous topic

Linear Interpolation of Vectors and Matrices

Next topic

Methods of Scaling

This Page