The VARMAX Procedure

RESTRICT Statement

  • RESTRICT restriction, …, restriction;

The RESTRICT statement places linear restrictions on the parameters and provides constrained estimation. Only one RESTRICT statement is allowed. If you specify more than one restriction in a RESTRICT statement, separate them with commas. Both equality and inequality constraints are allowed in the RESTRICT statement, although in general, the equality constraints are specified in the RESTRICT statement, and the inequality constraints are specified in the BOUND statement. If the least squares method is used, the inequality constraints are not applicable.

To use the RESTRICT statement, you need to know the form of the model. If you do not specify the P=, Q=, or XLAG= option or the GARCH statement, then the RESTRICT statement is not applicable. Nonlinear restrictions on parameters are not supported.

You compute restricted parameter estimates by introducing a Lagrangian parameter for each restriction (Pringle and Rayner, 1971). The Lagrangian parameter measures the sensitivity of the sum of squared errors to the restriction. The estimates of these Lagrangian parameters and their significance are printed in the Restrict ODS table.

Matrix Expression

The RESTRICT statement operates on matrices. That is, you can specify the parameter matrices or constant matrices through the RESTRICT statement’s built-in operators and functions. You can add elements of the matrices A and B with the expression A+B, and you can perform matrix multiplication with the expression A*B and elementwise multiplication with the expression A#B. You can get the diagonal elements of the matrix A through the function DIAG(A), and you can get the $n \times n$ identity matrix through the function I(n).

Each restriction is written as a matrix expression composed of constants, operators, and functions.

Constants

Constants are either scalar constants, such as -1.2, 0.3, …, or matrix constants enclosed in braces, such as $2\times 2$ matrix {1 2, 3 4}, $1\times 3$ matrix (or called row vector) {-0.2 5.3 12}, and so on. Constants also include the dependent variable names and exogenous variable names that represent their index values and are mostly used in the subscripts or function arguments. For example, in the following statement, according to the order of the dependent and exogenous variables in the MODEL statement, GDP is equal to 1, CPI to 2, M2 to 3, FFR to 1, and CP to 2. Hence, the function call AR(2, GDP, {CPI M2}) is equivalent to AR(2,1,{2 3}), and XL(0, CPI, {FFR CP}) is equivalent to XL(0,2,{1 2}). The use of AR and XL functions to access parameters is discussed in the section Functions.

proc varmax data=macrodata;
   model GDP CPI M2 = FFR CP / p=12 xlag=12;
   restrict AR(2, GDP, {CPI M2}) = 0,
            XL(0, CPI, {FFR CP}) = 0;
run;

The matrix constant cannot be the first item in the RESTRICT statement. For example, you cannot specify the following statement:

restrict {-0.1 -0.2, -0.3 -0.4} <= AR <= {0.1 0.2, 0.3 0.4};

You can put the first matrix constant in parentheses and specify the preceding example in the following way:

restrict ({-0.1 -0.2, -0.3 -0.4}) <= AR <= {0.1 0.2, 0.3 0.4};
Operators

Operators define the operations on operands. Table 35.2 lists all built-in operators supported by the RESTRICT statement.

Table 35.2: Operators

Operator

Name

Description

+

Addition

Adds corresponding matrix elements

=

Comparison, equal

Compares matrix elements

<

Comparison, less than

Compares matrix elements

<=

Comparison, not greater than

Compares matrix elements

>

Comparison, greater than

Compares matrix elements

>=

Comparison, not less than

Compares matrix elements

||

Concatenation, horizontal

Concatenates matrices horizontally

//

Concatenation, vertical

Concatenates matrices vertically

@

Direct product

Takes the direct product of two matrices

:

Index creation

Creates an index vector

#

Multiplication, elementwise

Performs elementwise multiplication

 

Multiplication, matrix

Performs matrix multiplication

$-$

Sign reverse

Reverses the signs of elements

$\left[\  \right]$

Subscripts

Selects submatrices

$-$

Subtraction

Subtracts corresponding matrix elements

`

Transpose

Transposes a matrix


For more information about each operator, see the section Details of Operators.

Table 35.3 shows the precedence of matrix operators in the RESTRICT statement.

Table 35.3: Operator Precedence

Priority Group

 

Operators

I (highest)

 

$\left[\  \right]$ (subscripts)

\`{~ }

       

II

 

$-$ (sign reverse)

         

III

 

*

#

@

     

IV

 

$-$ (subtraction)

+

       

V

 

||

//

:

     

VI (lowest)

 

=

<

<=

>

>=

 


Each restriction can be a compound expression that involves several matrix operators and operands. The rules for evaluating compound expressions are as follows:

  • Evaluation follows the order of operator precedence, as described in Table 35.3. Group I has the highest priority; that is, Group I operators are evaluated first. Group II operators are evaluated after Group I operators, and so on. For example, $1+2*3$ returns 7.

  • If neighboring operators in an expression have equal precedence, the expression is evaluated from left to right, except for the Group I operators. For example, $1-2-3$ returns $-4$.

  • All expressions in parentheses are evaluated first, following the two preceding rules. For example, $3*(2+1)$ returns 9.

Functions

Functions are mainly divided into two categories: one type of function refers to parameters to be estimated, such as AR(L,I,J) and CCC(I,J); the other type does not, such as I(n) and DIAG(A).

Functions that refer to the parameters are listed in Table 35.4. The arguments for functions can be matrices. The simplest case, scalar arguments, is discussed first. For convenience, the scalar indices i and j refer to the position of the element in the coefficient matrix, and scalar l refers to the lag value.

Table 35.4: Functions Referring to Parameters

Function

Description

ACH(l,i,j)

ARCH parameter of the lag l value of $\bepsilon _{t} \bepsilon _{t}’$ in a GARCH model

AR(l,i,j)

Autoregressive parameter of the lag l value of the jth dependent (endogenous) variable, $y_{j,t-l}$, to the ith dependent variable at time t, $y_{it}$

CCC(i,j)

Constant conditional correlation parameter between ith and jth standardized error processes for the CCC GARCH model

CONST(i)

Intercept parameter of the ith time series, $y_{it}$

COV(i,j)

Covariance of innovations parameter between ith and jth error processes when the maximum likelihood method is used for the fitted non-GARCH model

DCCA()

Parameter $\alpha $ in the correlation equation for the DCC GARCH model

DCCB()

Parameter $\beta $ in the correlation equation for the DCC GARCH model

DCCS(i,j)

Unconditional correlation parameter between ith and jth standardized error processes for the DCC GARCH model

EACH(l,i,j)

Exponential ARCH parameter of the lag l value of $\bepsilon _{it}/\sigma _{it}$ in the CCC or DCC GARCH model when SUBFORM=EGARCH is specified if $i=j$; if $i\neq j$, the value is set to 0.

GCH(l,i,j)

GARCH parameter of the lag l value of the covariance matrix, $H_{t}$, in a GARCH model

GCHC(i,j)

Constant parameter of the covariance matrix, $H_{t}$, in a GARCH model

LAMBDA(i)

Power parameter for the ith error process in the CCC or DCC GARCH model when SUBFORM=PGARCH is specified

LTREND(i)

Linear trend parameter of the ith time series, $y_{it}$

MA(l,i,j)

Moving-average parameter of the lag l value of the jth error process, $\bepsilon _{j,t-l}$, to the ith dependent variable at time t, $y_{it}$

PACH(l,i,j)

Power ARCH parameter of the lag l value of $\bepsilon _{it}$ in the CCC or DCC GARCH model when SUBFORM=PGARCH is specified if $i=j$; if $i\neq j$, the value is set to 0.

QACH(l,i,j)

Quadratic ARCH center parameter of the lag l value of $\bepsilon _{it}$ in the CCC or DCC GARCH model when SUBFORM=QGARCH is specified if $i=j$; if $i\neq j$, the value is set to 0.

QTREND(i)

Quadratic trend parameter of the ith time series, $y_{it}$

SD(i,j)

Same as SDUMMY(i, j)

SDUMMY(i,j)

jth seasonal dummy of the ith time series at time t, $y_{it}$, where $j=1,\ldots ,($nseason$-1)$, where nseason is based on the NSEASON= option in the MODEL statement

TACH(l,i,j)

Threshold ARCH parameter of the lag l value of $1_{\bepsilon _{it}<0} \bepsilon _{it}^2$ in the CCC or DCC GARCH model when SUBFORM=GJR is specified if $i=j$; if $i\neq j$, the value is set to 0.

XL(l,i,j)

Exogenous parameter of the lag l value of the jth exogenous (independent) variable, $x_{j,t-l}$, to the ith dependent variable at time t, $y_{it}$


The functions that refer to parameters, as shown in Table 35.4, accept vector arguments and return the matrix constructed by the corresponding parameters. According to the number of arguments, the following list shows what matrix a function returns when the arguments are vectors:

  • A function FUNC0, namely DCCA and DCCB, with zero arguments, always returns the corresponding scalar parameter.

  • A function FUNC1, namely CONST, LAMBDA, LTREND, and QTREND, with one vector argument $I$, where $I=(i_1\  i_2\  \ldots \  i_{n_ I})’$, returns a vector $R=(r_1\  r_2\  \ldots \  r_{n_ I})’$, where $r_ k=$ FUNC1($i_ k$), $k=1, ..., n_ I$.

  • A function FUNC2, namely CCC, COV, DCCS, GCHC, SD, and SDUMMY, with two vector arguments $I$ and $J$, where $I=(i_1\  i_2\  \ldots \  i_{n_ I})’$ and $J=(j_1\  j_2\  \ldots \  j_{n_ J})’$, returns a matrix

    \[  R= \left( \begin{array}{cccc} r_{1,1} &  r_{1,2} &  \cdots &  r_{1,n_ J} \\ r_{2,1} &  r_{2,2} &  \cdots &  r_{2,n_ J} \\ \cdots & & & \\ r_{n_ I,1} &  r_{n_ I,2} &  \cdots &  r_{n_ I,n_ J} \\ \end{array} \right)  \]

    where $r_{k,m}=$ FUNC2($i_ k, j_ m$), $k=1, ..., n_ I, m=1, ..., n_ J$.

  • A function FUNC3, namely ACH, AR, EACH, GCH, MA, PACH, QACH, TACH, and XL, with three vector arguments $L$, $I$, and $J$, where $L=(l_1\  l_2\  \ldots \  l_{n_ L})’$, $I=(i_1\  i_2\  \ldots \  i_{n_ I})’$, and $J=(j_1\  j_2\  \ldots \  j_{n_ J})’$, returns a matrix

    \[  R= \left( \begin{array}{cccc} r_{1,1} &  r_{1,2} &  \cdots &  r_{1,n_ L n_ J} \\ r_{2,1} &  r_{2,2} &  \cdots &  r_{2,n_ L n_ J} \\ \cdots & & & \\ r_{n_ I,1} &  r_{n_ I,2} &  \cdots &  r_{n_ I,n_ L n_ J} \\ \end{array} \right)  \]

    where $r_{k,m}=$ FUNC3($l_ m, i_ k, j_ m$), $k=1, ..., n_ I, m=1, ..., n_ L n_ J$, and $l_ m$ and $j_ m$ are the quotient and remainder of m divided by $n_ J$, respectively.

The functions that refer to parameters can accept empty arguments or omit any number of last arguments. The empty or omitted arguments are replaced with all possible values for those arguments. For example, in a bivariate (k=2) VARX(1,1) model with three exogenous variables,

   model y1 y2 = x1 x2 x3 / p=1 xlag=3;

in order to restrict the third exogenous variable from having an effect on the first dependent variable, and to restrict the first exogenous variable from having an effect on the second dependent variable, you can use the following statement:

restrict XL({0 1 2 3}, 1, 3) = 0,
         XL({0 1 2 3}, 2, 1) = 0;

Taking advantage of empty arguments, you can specify the preceding example as follows:

restrict XL( , 1, 3) = 0,
         XL( , 2, 1) = 0;

To get all coefficients of the first lag exogenous variables on dependent variables, you can use XL(1, {1 2}, {1 2 3}) or XL(1, , ) or XL(1). To get all coefficients of exogenous variables on dependent variables, you can use XL({0 1 2 3}, {1 2}, {1 2 3}), or XL( , , ) or XL() or even just XL.

Another type of function does not refer to parameters but generates useful matrices. Table 35.5 lists all built-in functions supported by the RESTRICT statement.

Table 35.5: Functions Not Referring to Parameters

Function

Description

DIAG(A)

Creates a diagonal matrix from a vector or extracts the diagonal elements of a matrix

I(n)

Creates an $n \times n$ identity matrix

J(m,n,elem)

Creates an $m \times n$ matrix with all elements equal to elem

SHAPE(A,m,n)

Creates a $m \times n$ matrix with elements of matrix A


For more information about each function in Table 35.5, see the section Details of Functions.

Examples

The following examples show how to use the RESTRICT statement.

This example shows a bivariate (k=2) VAR(2) model:

proc varmax data=one;
   model y1 y2 / p=2;
   restrict AR(1,1,2)=0, AR(2,1,2)=0.3;
run;

The AR(1,1,2) and AR(2,1,2) parameters are fixed as AR(1,1,2)=0 and AR(2,1,2)=0.3, respectively, and other parameters are to be estimated.

The following example shows a bivariate (k=2) VAR(1) model, estimated using the ML method:

proc varmax data=two;
   model y1 y2 = / p=1 method=ml;
   restrict cov(1,1)=cov(2,2), cov(1,2)=0;
run;

The COV(1,1) and COV(2,2) parameters are equal, and the correlation between the two series is fixed at 0. You can also express the preceding restrictions in matrix expressions as follows; this approach is very convenient when the number of dependent variables is large:

proc varmax data=two;
   model y1 y2 = / p=1 method=ml;
   restrict cov = cov(1,1)*I(2);
run;

When restricting a linear combination of parameters to be 0, you can omit the equal sign. For example, the following two RESTRICT statements are equivalent:

restrict AR(1)[1,1)-AR(1)[2,2], 2*MA(1)[1,2]-MA(1)[2,1];
restrict AR(1)[1,1]-AR(1)[2,2] = 0, 2*MA(1)[1,2]-MA(1)[2,1] = 0;

The following RESTRICT statement constrains four parameter estimates to be equal:

restrict AR(1)[1,1] = AR(1)[1,2],
         AR(1)[1,2] = AR(1)[2,1],
         AR(1)[2,1] = AR(1)[2,2];

This restriction can be abbreviated as follows:

restrict AR(1)[1,1] = AR(1)[1,2] = AR(1)[2,1] = AR(1)[2,2];

Or, in matrix expressions,

restrict AR(1,1:2,1:2) = J(2,2,AR(1,1,1));

The VARMA representation $A(L)y_ t = \Theta (L)\varepsilon _ t$, where $A(L) = I_ k-A_1 L - \cdots - A_ p L^ p$ and $\Theta (L) = I_ k-\Theta _1 L - \cdots - \Theta _ q L^ q$, is said to be in final equation form if $A(L) = a(L)I_ k$, where $a(L) = 1 - a_1 L - \cdots - a_ p L^ p$ is a scalar operator with $a_ p\neq 0$. If p and k are large, it would be difficult and inconvenient to restrict AR parameters element by element in standard form to estimate the VARMA model in final equation form. However, when you use matrix expressions, the restrictions become very simple, as shown in the following statement for a trivariate ($k=3$) VARMA(p, q) model, where p might be any positive integer:

restrict AR = AR(,1,1) @ I(3);

Details of Operators

This section describes all operators that are available in the RESTRICT statement. Each subsection shows how the operator is used, followed by a description of the operator.

Addition Operator:   +

matrix1 + matrix2

matrix + scalar

matrix + vector

The addition operator (+) computes a new matrix whose elements are the sums of the corresponding elements of matrix1 and matrix2. If matrix1 and matrix2 are both $n\times p$ matrices, then the addition operator adds the element in the ith row and jth column of the first matrix to the element in the ith row and jth column of the second matrix, for $i=1,\ldots , n, j=1,\ldots , p$. For example, {1 2 3, 4 5 6} + {7 8 9, 10 11 12} results in {8 10 12, 14 16 18}.

You can also use the addition operator as follows to conveniently add a value to each element of a matrix, to each column of a matrix, or to each row of a matrix:

  • When you use the matrix + scalar form, the scalar value is added to each element of the matrix.

  • When you use the matrix + vector form, the vector is added to each row or column of the $n\times p$ matrix.

    • If you add an $n\times 1$ column vector, each row of the vector is added to each row of the matrix.

    • If you add a $1\times p$ row vector, each column of the vector is added to each column of the matrix.

For example, you can obtain {2 3 4, 5 6 7} from {1 2 3, 4 5 6} + 1 or {1 2 3, 4 5 6} + {1 1 1} or {1 2 3, 4 5 6} + {1, 1}.

Comparison Operators:   =, <, <=, >, >=

matrix1 = matrix2

matrix1 < matrix2

matrix1 <= matrix2

matrix1 > matrix2

matrix1 >= matrix2

The comparison operators (=, <, <=, >, >=) compare two matrices element by element and return a list of equivalent restrictions on only scalar constants and parameters.

For example, the RESTRICT statement with matrix expressions

restrict AR(1,{1,2},{1,2}) = MA(2,{3,4},{3,4});

is transformed into the following equivalent RESTRICT statement with scalar parameters:

restrict AR(1,1,1) = MA(2,3,3),
         AR(1,1,2) = MA(2,3,4),
         AR(1,2,1) = MA(2,4,3),
         AR(1,2,2) = MA(2,4,4);

You can also use the comparison operators to conveniently compare all elements of a matrix with a scalar:

  • If either argument is a scalar, then the VARMAX procedure performs an elementwise comparison between each element of the matrix and the scalar.

You can also compare an $n\times p$ matrix with a row or column vector:

  • If the comparison is with an $n\times 1$ column vector, the VARMAX procedure compares each row of the vector to each row of the matrix.

  • If the comparison is with a $1\times p$ row vector, the VARMAX procedure compares each column of the vector to each column of the matrix.

For example, the following statements are equivalent:

restrict AR(1,1:2,1:3) >= 0.2;
restrict AR(1,1:2,1:3) >= {0.2, 0.2};
restrict AR(1,1:2,1:3) >= {0.2 0.2 0.2};
Concatenation Operator, Horizontal:   ||

matrix1 $\parallel $ matrix2

The horizontal concatenation operator (||) produces a new matrix by horizontally joining matrix1 and matrix2. The matrices must have the same number of rows, which is also the number of rows in the new matrix. The number of columns in the new matrix is the number of columns in matrix1 plus the number of columns in matrix2.

For example, {1 1 1, 7 7 7} || {0 0 0, 8 8 8} returns {1 1 1 0 0 0, 7 7 7 8 8 8}.

Concatenation Operator, Vertical:   //

matrix1 // matrix2

The vertical concatenation operator (//) produces a new matrix by vertically joining matrix1 and matrix2. The matrices must have the same number of columns, which is also the number of columns in the new matrix. The number of rows in the new matrix is the number of rows in matrix1 plus the number of rows in matrix2.

For example, {1 1 1} // {0 0 0, 8 8 8} returns {1 1 1, 0 0 0, 8 8 8}.

Direct Product Operator:   @

matrix1 @ matrix2

The direct product operator (@) computes a new matrix that is the direct product (also called the Kronecker product) of matrix1 and matrix2. For matrices $\mb{A}$ and $\mb{B}$, the direct product is denoted by $\mb{A} \otimes \mb{B}$. The number of rows in the new matrix equals the product of the number of rows in matrix1 and the number of rows in matrix2; the number of columns in the new matrix equals the product of the number of columns in matrix1 and the number of columns in matrix2.

Specifically, if $\mb{A}$ is an $n\times p$ matrix and $\mb{B}$ is a $m\times q$ matrix, then the Kronecker product $\mb{A}\otimes \mb{B}$ is the following $nm\times pq$ block matrix:

\[  \mb{A}\otimes \mb{B}= \left[ \begin{matrix}  A_{11} B   &  \cdots   &  A_{1p}B   \cr \vdots   &  \ddots   &  \vdots   \cr A_{n1} B   &  \cdots   &  A_{np} B   \end{matrix} \right]  \]

For example, {1 2, 3 4} @ {0 2} returns {0 2 0 4, 0 6 0 8}, and {0 2} @ {1 2, 3 4} returns {0 0 2 4, 0 0 6 8}. Note that the direct product of two matrices is not commutative.

Index Creation Operator:   :

value1 : value2

The index creation operator (:) creates a column vector whose first element is value1, whose second element is value1+1, and so on, until the last element, which is less than or equal to value2.

For example, 3 : 6 returns {3 4 5 6}.

If value1 is greater than value2, a reverse-order index is created. For example, 6 : 3 returns {6 5 4 3}.

Neither value1 nor value2 is required to be an integer.

Multiplication Operator, Elementwise:   #

matrix1 # matrix2

matrix # scalar

matrix # vector

The elementwise multiplication operator (#) computes a new matrix whose elements are the products of the corresponding elements of matrix1 and matrix2.

For example, {1 2, 3 4} # {4 8, 0 5} returns {4 16, 0 20}.

In addition to multiplying matrices that have the same dimensions, you can use the elementwise multiplication operator to multiply a matrix and a scalar:

  • When either argument is a scalar, each element in matrix is multiplied by the scalar value.

When you use the matrix # vector form, each row or column of the $n\times p$ matrix is multiplied by a corresponding element of the vector:

  • If you multiply by an $n\times 1$ column vector, each row of the matrix is multiplied by the corresponding row of the vector.

  • If you multiply by a $1\times p$ row vector, each column of the matrix is multiplied by the corresponding column of the vector.

For example, a $2 \times 3$ matrix can be multiplied on either side by a $2 \times 3$, $1 \times 3$, $2 \times 1$, or $1 \times 1$ scalar.

The product of elementwise multiplication is also known as the Schur or Hadamard product. Elementwise multiplication (which uses the # operator) should not be confused with matrix multiplication (which uses the * operator).

Multiplication Operator, Matrix:   *

matrix1 * matrix2

The matrix multiplication operator (*) computes a new matrix by performing matrix multiplication. The first matrix must have the same number of columns as the second matrix has rows. The new matrix has the same number of rows as the first matrix and the same number of columns as the second matrix. That is, if $\bm {A}$ is an $n\times p$ matrix and $\bm {B}$ is a $p\times m$ matrix, then the product $A*B$ is an $n\times m$ matrix. The $ij$th element of the product is the sum $\sum _{k=1}^ p A_{ik}B_{kj}$.

For example, {1 2, 3 4} * {1, 2} returns {5, 11}.

Sign Reversal Operator:   –

- matrix

The sign reversal operator ($-$) computes a new matrix whose elements are formed by reversing the sign of each element in matrix. The sign reversal operator is also called the unary minus operator.

For example, -{-1 7 6, 2 0 -8} returns {1 -7 -6, -2 0 8}.

Subscripts:   [ ]

matrix[rows, columns]

matrix[elements]

Subscripts are used with matrices to select submatrices, where rows, columns, and elements are expressions that evaluate to scalars or vectors. If these expressions are numeric, they must contain valid subscript values of rows and columns, or the indices, in the argument matrix.

For example, {1 2 3, 4 5 6, 7 8 9}[2,3] returns 6, {1 2 3, 4 5 6, 7 8 9}[2,1:3] returns {4 5 6}, and {1 2 3, 4 5 6, 7 8 9}[,3] returns {3, 6, 9}. Because the VARMAX procedure stores matrices in row-major order, {11 22 33, 44 55 66, 77 88 99}[{3 5 9}] returns {33, 55, 99}.

Subtraction Operator:   –

matrix1 - matrix2

matrix - scalar

matrix - vector

The subtraction operator ($-$) computes a new matrix whose elements are formed by subtracting the corresponding elements of matrix2 from those of matrix1.

In addition to subtracting conformable matrices, you can also use the subtraction operator to subtract a scalar from a matrix or subtract a vector from a matrix:

  • When either argument is a scalar, the VARMAX procedure performs the subtraction between the scalar and each element of the matrix argument. For example, when you use the matrix - scalar form, the scalar value is subtracted from each element of the matrix.

  • When you use the matrix - vector form, the vector is subtracted from each row or column of the $n\times p$ matrix.

    • If you subtract an $n\times 1$ column vector, each row of the vector is subtracted from each row of the matrix.

    • If you subtract a $1\times p$ row vector, each column of the vector is subtracted from each column of the matrix.

For example, {1 2 3, 4 5 6} - {1 1 1, 1 1 1} returns {0 1 2, 3 4 5}. The same results can be obtained by {1 2 3, 4 5 6} - 1 or {1 2 3, 4 5 6} - {1 1 1} or {1 2 3, 4 5 6} - {1, 1}.

Transpose Operator:  `

matrix`

The transpose operator, denoted by the backquote character (`), exchanges the rows and columns of matrix, producing the transpose of matrix. If v is the value in the ith row and jth column of matrix, then the transpose of matrix contains v in the jth row and ith column. If matrix contains n rows and p columns, the transpose has p rows and n columns.

For example, {1 2, 3 4, 5 6}` returns {1 3 5, 2 4 6}.

Details of Functions

DIAG Function

DIAG(matrix)

The DIAG function creates a diagonal matrix from a vector or extracts the diagonal elements of a matrix. The matrix argument can be either a square matrix or a vector.

If matrix is a vector, the DIAG function creates a matrix whose diagonal elements are the values in the vector. All off-diagonal elements are zeros.

If matrix is a square matrix, the DIAG function creates a vector from the diagonal elements of the matrix.

For example, DIAG({1 2 3, 4 5 6, 7 8 9}) returns {1, 5, 9}. Also, DIAG({1 5 9}) or DIAG({1, 5, 9}) or DIAG(DIAG({1 2 3, 4 5 6, 7 8 9})) returns {1 0 0, 0 5 0, 0 0 9}.

I Function

I(dim)

The I function creates an identity matrix that contains dim rows and columns. The diagonal elements of an identity matrix are ones; all other elements are zeros. The value of dim must be an integer greater than or equal to 1. Noninteger operands are rounded to the nearest integer.

For example, I(3) returns {1 0 0, 0 1 0, 0 0 1}.

J Function

J(nrow, ncol, value)

The J function creates a matrix that contains nrow rows and ncol columns, in which all elements are equal to value.

The arguments nrow and ncol are both integers; value can be any expression that returns a linear combination of scalar constants and parameters.

For example, J(2, 3, 1) returns {1 1 1, 1 1 1}. J(2, 3, 5+2*AR(1,1,1)) returns the same result as J(2, 3, 1) * (5+2*AR(1,1,1)).

SHAPE Function

SHAPE(matrix, nrow, ncol)

The SHAPE function creates a new matrix from data in matrix. The values nrow and ncol specify the number of rows and columns, respectively, in the new matrix. The SHAPE function produces the result matrix by traversing the argument matrix in row-major order until it reaches the specified number of elements. If necessary, the SHAPE function reuses elements.

For example, SHAPE({1 2 3, 4 5 6}, 3, 2) returns {1 2, 3 4, 5 6}; SHAPE({1 2 3, 4 5 6}, 5, 2) returns {1 2, 3 4, 5 6, 1 2, 3 4}; and SHAPE({1 2 3, 4 5 6}, 1, 4) returns {1 2 3 4}.