Page 1 of 1

fractiles of vector of series

Posted: Thu Jul 25, 2013 12:36 pm
by Gilbril
Dear Tom,

I have a pretty large vector of series which contains forecasts for the same variable from different models.
I would like to compute the fractiles of the different forecast for a specific date.
Lets say I want to compute the fractiles for the forecasts for december 2013.
i have 50 different forecast in the vector of series forecastcollect.
So I need to collect the data for that month over the 50 series in the vector of series to compute fractiles.
forecastcollet(1)......forcastcollect(50)

Commands like %xrow do no work for a vector of series.

Thanks for the help!

Re: fractiles of vector of series

Posted: Thu Jul 25, 2013 12:46 pm
by TomDoan
If I understand you correctly, this looks like it would do roughly what you want:

do time=fstart,fend
compute ftime=%xt(forecastcollect,time)
compute fract=%fractiles(ftime,||.05,.25,.50,.75,.95||)
* do something with fract
end do time

Re: fractiles of vector of series

Posted: Thu Jul 25, 2013 2:46 pm
by Gilbril
Dear Tom thanks for the help and the quick answer. I need to transfer the content oft the fractiles into a series for each fractile.
I tried the following, but the series is not filled with the fractiles for each month. Where is the mistake?



set testseries 1 200 = 0
dofor i= 100 to 150
compute ftime=%xt(test,i)
*test is a vector of series
compute fract=%fractiles(ftime,||.50||)
comp testseries(i) = fract(i)
end dofor
print /testseries

Re: fractiles of vector of series

Posted: Thu Jul 25, 2013 3:24 pm
by TomDoan
As you've written that, fract will just be a 1-vector with the median for the time period. So you would want:

comp testseries(i) = fract(1)

Re: fractiles of vector of series

Posted: Fri Jul 26, 2013 12:19 pm
by Gilbril
Dear Tom, thanks for the help. I have two more questions regarding vector of series.

Question 1.
I do want to create a vector of series for each forecast horizon.This vector stores the forecasts for a certain forecast horizon over all forecast models.
I thought about something similar like for series

dofor i = 1 to maxhorizon
dec vec[series]%s(qfcollec"+i)(50)
end dofor i

Question 2.
I do want to store the forecasts for a certain forecast horizon over all modells in the above created vector of series

dofor i = 1 to maxhorizon
dofor j = 1 to nmodels
set %s("qfcollec"+i)(j) = %s("qf"+j+i)
* qf is a series and stores the forecast j is the number of the model and i the forecast horizon
* qfcollec is avector of series
end dofor j

Unfortunately this does not work.

Many thanks again!

Re: fractiles of vector of series

Posted: Fri Jul 26, 2013 1:03 pm
by TomDoan
You might want a VECT[VECT[SERIES]] but I'm not really seeing where the inner "series" is coming into this. In your code, what is the implied "T" in the SET in

set %s("qfcollec"+i)(j) = %s("qf"+j+i)

Re: fractiles of vector of series

Posted: Fri Jul 26, 2013 3:40 pm
by Gilbril
Sorry that my description was not exact. Each forecast qf is denoted by j, which is the forecast model and i , which denotes the forecast horizon. So qf16 is a series created by model 1 which holds for each month the forecast made six months ago. Is there any equivalent function like %s for series by which I can create and call different vectors of series?

Re: fractiles of vector of series

Posted: Fri Jul 26, 2013 4:02 pm
by TomDoan
That would be the VECT[VECT[SERIES]]. Probably the simplest way to do that would be to have the outer subscript as the model, the inner as the horizon and the time subscript on the series is the date being forecast. (You could also do a RECT[SERIES], but the VECT[VECT] is probably a better description of what's happening). It sounds like you would be best off just putting the forecast information into that type of structure to start, rather than using the QFij series.

Code: Select all

dec vect[vect[series]] qf(nmodels)
do j=1,nmodels
   dim qf(j)(maxhorizon)
   set qf(j)(i) = %s("qf"+j+i)
end do j

Re: fractiles of vector of series

Posted: Fri Jul 26, 2013 4:43 pm
by Gilbril
Thanks, but the goal is to extract all forecasts of different models to compute fractiles and by this a distribution of the different forecasts. %Xt does not seem to work for a subcomponent of a vector of series %xt(Qf(2)(1), 2008:01). Therefore I thought to have a Vector of series for each forecast horizon. Then using %xt I do have all forecast for a specific date and a specific forecast horizon generated by the different forecast models. Any suggestions how I can do this?

Re: fractiles of vector of series

Posted: Sat Jul 27, 2013 12:00 pm
by TomDoan
I'm still a bit confused about what the end result is to be. For each horizon and for each date, you have H different forecasts for T time periods for N models. Is what you want the distribution for each of the H x T combinations across the N models? If that's the case, then your output will also be 3 dimensional as you will have multiple quantiles for each. Depending upon what you want to do with that, you might want a VECT[SERIES[VECT]] or a VECT[VECT[SERIES]].