I have problems understanding the memory demands of RATS during an out-of-sample forecasting analysis I am performing based on a really large VAR model (a global VAR of the type proposed by Pesaran et a. in a sequence of papers).
The basic structure of my code is as follows. In a first exercise I do the oos-analysis for a single GVAR specification:
Code: Select all
* There is an array that is used to store the forecasts made at each time for different horizons (dimensions refere to #countries[#variables[#fsteps]]; further dimensioning is done elsewhere)
decl vec[vec[vec[ser]]] gvarfcts(nc)
do time=simstart,simend
* This is a procedure that estimates the GVAR-Model, produces forecasts. This uses a lot of internal (local) arrays and also produces a number of global arrays that are used to return results
@GVAR(...) ...
* In a second step the forecasts are stored to the gvarfcts-array
do c=1,nc
do v=1,nv
do f=1,fsteps
set gvarfcts(c)(v)(f) time+f-1 time+f-1 = %GVARFCTS(c)(v)(t)
end do f
end do v
end do c
end do time
Now, in a second exercise I would like to make an additional loop over (nm) different model specifications. As a first attempt to save memory I do not save all of the forecasts to be able to aggregate them after the entire oos-analysis, but I just save the nm different forecasts at each simulation time, average them after looping over all models and use the same array to temporarily store the forecasts from individual models at each simulation time. The basic code looks as follows:
Code: Select all
* There is an array that is used to store the (average) forecasts made at each time for different horizons (dimensions refere to #countries[#variables[#fsteps]]; further dimensioning is done elsewhere) ...
* ... and an additional array that temporarily stores the forecasts from individual models (dimensions refere to #models[#countries[#variables[#fsteps]]]; further dimensioning is done elsewhere)
decl vec[vec[vec[ser]]] gvarfcts(nc)
decl vec[vec[vec[vec]]] tempvec(nm)
do time=simstart,simend
do m=1,nm
* This is a procedure that estimates the GVAR-Model, produces forecasts. This uses a lot of internal (local) arrays and also produces a number of global arrays that are used to return results
@GVAR(options[m]) ...
* In a second step the forecasts are stored to the tempvec-array
do c=1,nc
do v=1,nv
do f=1,fsteps
comp tempvec(m)(c)(v)(f) = %GVARFCTS(c)(v)(time+f-1)
end do f
end do v
end do c
end do m
* At this point, I average the forecasts stored in tempvec and store these in the gvarfcts-array
@aggregatefc gvarfcts tempvec time
end do time