ACCUMULATE Instruction |
ACCUMULATE( options ) series start end newseries newstart
Computes newseries as the partial sums of series. Explicitly, entry N of newseries is the sum of the first N entries of series.
Wizard
You can use the Data/Graphics—Transformations Wizard to compute partial sums.
Parameters
series |
source series |
start, end |
range over which to compute partial sums (range of series by default) |
newseries |
result series (series by default) |
newstart |
start for newseries (start by default) |
Options
STANDARDIZE/[NOSTANDARDIZE]
Normalize result to end at 1.0. (This was called SCALE/NOSCALE in very old versions of RATS).
Examples
set du 1 500 = %ran(1.0)
acc du / u
creates a random walk in U by integrating the series DU of N(0,1) random variates.
acc sales / totalsales
set pchange = sales/totalsales{1}
linreg pchange
# constant totalsales{1}
takes the series SALES, computes the total sales through each entry, then computes a linearized logistic trend regression.
impulse(model=varmodel,result=impulses,noprint,steps=nsteps)
dec rect[ser] accumimp(%nvar,%nvar)
do i=1,%nvar
do j=1,%nvar of
accumulate impulses(i,j) 1 nsteps accumimp(i,j)
end do i
end do j
This stores accumulated impulse responses into an array of series called ACCUMIMP.
Notes
ACCUMULATE is sometimes used when all that is needed is the final value, not the whole series of sums. For that, it's better to use SSTATS:
sstats(mean) 1963:1 1963:12 deuip>>avg1963
computes (into AVG1963) the average value of DEUIP over 1963:1 to 1963:12.
ACCUMULATE is (almost) the inverse of DIFFERENCE. DIFFERENCE followed by ACCUMULATE loses the information about the level included in the first value of the original series. The SET instruction with the FIRST option can be used to do roughly the same thing as ACCUMULATE, but with a non-zero "pre-sample" value:
uforecast(equation=diffeq) dxfore fstart fend
set(first=x{1}+dxfore) xfore fstart fend = xfore{1}+dxfore
forecasts DXFORE as the first difference of X. To compute the corresponding forecasts of X itself, the SET instruction then uses the last observed value of X in computing entry FSTART, then uses the lagged value of the XFORE for all the remaining entries.
Use MVSTATS if you want to compute averages across a set of entries which shifts as you move through the data set—that is, over a moving “window” of entries. ACCUMULATE just adds new entries on at the end without dropping the early ones.
Missing Values
RATS excludes missing values in series from the calculation of the partial sums and sets the corresponding entries in newseries to missing. For example:
set trend 1 10 = t
set trend 5 6 = %na
accumulate trend / trendsum
produces the following output
ENTRY TREND TRENDSUM
1 1 1
2 2 3
3 3 6
4 4 10
5 NA NA
6 NA NA
7 7 17
8 8 25
9 9 34
10 10 44
Copyright © 2024 Thomas A. Doan