|
|
|
|
|
|
時系列分析ソフトウェア
RATS |
|
3-4. RATS Basics: Data Transformations
Most work with RATS will involve at least a few data transformations. These are usually done with the SET instruction, although RATS also provides several specialized instructions for various common transformations. The possibilities are nearly endless, so we'll just cover a few simple examples here.
Our Example Program
For our example, we need to create a linear time trend series and a series containing the two-period moving averages of farm prices. The instruction below uses a special reserved variable (T) to set entry 1 of TREND to 1.0, entry 2 of TREND to 2.0, and so on:
SET TREND = T
To create our average, we do:
SET AVGPRICES = (PRFARM+PRFARM{1})/2.0
The notation {1} indicates a one period lag, so this sets each entry of AVGPRICES equal to the sum of the current entry and one-period lag of PRFARM, divided by 2.
Other Transformations
Here are some other common transformations:
Two different ways of taking the first-difference of Y:
SET DY = Y - Y{1}
DIFF Y / DY
Two ways of taking the natural log of X:
SET LX = LOG(X)
LOG X / LX
This uses logical expressions to create a dummy variable. WARTIME will be equal to 1 for the years 1942 through 1946, and 0 elsewhere:
SET WARTIME = T>=1942:1.AND.T<=1946:1
|
|
|
←RATSのTopページに戻る |
|
|