3-8. RATS Basics: Functions
In addition to built-in instructions, such as LINREG and FORECAST, RATS offers more than eighty functions. Functions are used in expressions (e.g., the right hand side of SET or COMPUTE instructions), for tasks such as inverting or transposing arrays, taking natural logs or square roots, getting the month, day, or year of a given observation, drawing random numbers, and much more.
Here are a few examples:
This uses the SQRT function to store the square roots of the IMPORTS series in a series called SQ_IMPORTS:
SET SQ_IMPORTS = SQRT(IMPORTS)
For a matrix X, this uses the inverse function (INV) and the transpose function (TR) to compute the (X'X) inverse matrix:
COMPUTE XPXINV = INV(X*TR(X))
Computes the cosine of Y:
COMPUTE COSINE = COS(Y)
Computes the Kroneker product of two arrays:
COMPUTE KP = %KRONEKER(A,B)
|