RATS 10.1
RATS 10.1

RATS is one of the few econometric software programs which includes spectral analysis. We consider it to be an important tool in time-series analysis.

 

With RATS, you do spectral analysis using a sequence of primitive instructions such as FFT for Fourier transform and WINDOW for spectral window smoothing. This permits a great deal of flexibility, and ensures that you know exactly what is happening. On the other hand, the proper use of the instructions demands a somewhat higher level of sophistication on your part than from some other programs.

 

However, we have put together procedures which handle many of the key applications. These operate much like standard rats instructions. You can rely upon them if you are unsure of your skills.

 

While there are some uses for direct spectral and cross-spectral analysis, the most important use of spectral methods is as a computational device. Many techniques are actually applications of the frequency domain filtering.

 

Complex-Valued Expressions

Complex is a more general type than real or integer. If needed, RATS will automatically convert an integer or a real to complex (with zero imaginary part). The explicit type conversion functions are:

 

%real(z)

returns the (real-valued) real part of z

%imag(z)

returns the (real-valued) imaginary part of z

%cmplx(x1,x2)

creates the complex x1 + i x2 from the real numbers/expressions x1 and x2

Using Operators with Complex Values

The following operators can be used in complex-value calculations:

+,- and / function as expected.

* multiplies the first number by the conjugate of the second number, that is, \(A*B = A\bar B\).

^ or ** function as expected. The only operation not supported is raising a negative real number (with zero imaginary part) to a power.

 

Relational Operators

You can use the == and <> operators to test equality or inequality of two complex numbers. You cannot use any of the other relational operators ( >, <, >=, <= ).

 

Predefined Variables

%pi          is the constant \(\pi\) (REAL variable)

 

Functions

 

The functions of particular interest are (x’s are real, z’s are complex, t’s are integer, N is the number of frequency ordinates):

 

sin(x), cos(x), tan(x)

Sine, cosine, tangent (real-valued)

%asin(x), %acos(x), %atan(x)

Inverse sine, cosine, tangent

%cmplx(x1,x2)

Complex number x1 + i x2

%real(z), %imag(z)

Real and imaginary parts (real-valued)

%conjg(z), %csqrt(z)

Complex conjugate and complex square root

%cabs(z), %arg(z)

Absolute value and argument. z can be decomposed as %CABS(z)*EXP(i%ARG(z))

%clog(z), %cexp(z)

Complex natural logarithm and antilogarithm

%unit(x), %unit2(t1,t2)

Unit circle values \(e^{i{\kern 1pt} x} \) and \(e^{i{\kern 1pt} {\kern 1pt} 2\pi {\kern 1pt} {\kern 1pt} {{t_2 {\kern 1pt} {\kern 1pt} \left( {t_1  - 1}\right)} \mathord{\left/{\vphantom {{t_2 {\kern 1pt} {\kern 1pt} \left( {t_1  - 1} \right)} N}} \right.} N}} \)

%zlag(t1,t2)

Unit circle value \(e^{i{\kern 1pt} {\kern 1pt} 2\pi {\kern 1pt} {\kern 1pt} {{t_2 {\kern 1pt} {\kern 1pt} \left( {t_1  - 1} \right)} \mathord{\left/{\vphantom {{t_2 {\kern 1pt} {\kern 1pt} \left( {t_1  - 1} \right)} N}} \right.} N}} \)

                     

 


                                

Complex Series vs Real Series

Complex series and real series are separate types. You can’t substitute one where RATS expects the other. While there are many similarities in structure between the two types, there is little similarity in their use.

 

The data type name of a complex series is SERIES[COMPLEX], or CSERIES for short.

 

Creating Series

As with real series, you can create complex series by name when needed. However, it usually is more convenient to set up the full block of series needed (using FREQUENCY) and to refer to the series by numbers rather than by names. There are several reasons for this:

Most frequency domain procedures are short and straightforward and are adapted easily for use with different data sets. Referring to series by number simplifies this process.

A single series usually is subjected to several transformations in succession. In most instances, you can keep transforming the series onto itself. Giving a single name to the series would be misleading.

These points will become more obvious as you look at the examples.

 

CSET Used Less Often

You will note a similarity between the frequency domain instructions and the time domain instructions. However, a different set of instructions is important. While there is an instruction CSET (the complex analog of SET), specialized transformation instructions, such as CMULTIPLY and CLN (complex log) are used much more often.

 

FREQUENCY Instruction

The FREQUENCY instruction sets up a block of complex series of a specific length. Each use of FREQUENCY eliminates the previous block of complex series. This makes it possible (and desirable) to write self-contained procedures for your analysis, as each procedure can have its own FREQUENCY instruction to meet its needs.

 

FREQUENCY also defines a reserved variable %Z, which is a RECTANGULAR[COMPLEX] array with dimensions length \(\times\) cseries that holds the complex series set up by FREQUENCY. You can access entry m of complex series n as %Z(m,n).

 

No “CSMPL” Instruction

There is no “CSMPL” instruction corresponding to SMPL. Since most series are defined over the full FREQUENCY range and most transformations use all entries, the use of the defined range as the default is almost always adequate.

 


 

Complex-Valued Matrices and FRML’s

The two main types of matrices of complex numbers are the VECTOR[COMPLEX] (or CVECTOR for short) for a one-dimensional array and RECT[COMPLEX] (CRECT) for a general two-dimensional array. There’s also a SYMMETRIC[COMPLEX], but symmetric arrays aren’t as useful as the real-valued version. (The true analogue of the symmetric real array is a conjugate symmetric or self-adjoint matrix).

 

You declare these with instructions like DECLARE, LOCAL, TYPE and OPTION just as you would real-valued arrays. And you can dimension them with DIMENSION, or on DECLARE or LOCAL.

 

You can define series of complex matrices: SERIES[CRECT], for instance, is a series of complex 2–dimensional arrays. And you can define FRML’s which evaluate to complex numbers or complex matrices with the types FRML[COMPLEX] (formula evaluating to complex numbers), FRML[CVECTOR] and FRML[CRECT].

 

Operators and Functions

When applied to complex matrices, the operators +, - and * have the expected meanings. Note that * is just a standard matrix multiply. You can use * to multiply complex matrices by real-valued matrices or real or complex scalars as well.

There’s a much more limited set of functions for complex matrices:

 

%cxinv(Z)

Matrix inverse

%cxadj(Z)

Adjoint (conjugate transpose)

%cxsvd(Z)

Singular value decomposition returning a VECT[CRECT] with three components

%cxeigdecomp(Z)

Eigen decomposition returning a VECT[CRECT] with two components

          

Most calculations with complex-valued arrays are done with COMPUTE or with GSET. The latter is used when working with series of complex arrays, when you have one for each frequency.

 

Complex Eigenvalues/vectors of Real-valued Matrices

The instructions EIGEN (for eigen decomposition) and QZ (for generalized Schur decomposition) can both create complex vectors for their eigenvalues. For both instructions, you use the option CVALUES=VECTOR[COMPLEX] for eigenvalues. With EIGEN, you can also get the complex matrix for the (column) eigenvectors with the CVECTORS=RECT[COMPLEX] of eigenvectors.

 

 

 

 

 


Copyright © 2025 Thomas A. Doan