programs for forecast combination

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

Posts: 2
Joined: Thu Aug 30, 2018 8:20 am

programs for forecast combination

Postby cecelia » Wed Sep 05, 2018 4:07 am

Hi there
I am struggling to write programs for forecast combinations. The built-in function 'forecast averaging' only considers one combination, which is to combine all of the individual forecasts. I need to consider all possible combinations of the individual forecasts. For example, if there are 9 individual forecasts, any possible 8, 7, ..., 2 combinations require looking at, ending with 502 possible combinations in total. And the corresponding weights need to be worked out using different weighting schemes. Have you got any insights to write such programs? I am a beginner in programming and am highly appreciated if you can provide any solutions or suggestions.
Many thanks

EViews Matt
EViews Developer
Posts: 292
Joined: Thu Apr 25, 2013 7:48 pm

Re: programs for forecast combination

Postby EViews Matt » Wed Sep 05, 2018 10:34 am


One of the core sub-problems you have is generating all combinations of a certain size. Here's an example EViews program that generates such combinations, storing them as indices in a vector. Since you're generating combinations of multiple sizes, you can surround the relevant code in another loop to iterate through the sizes.

Code: Select all

logmode +l
create u 1

' Parameters for the combination, modeled after n-choose-k, C(n, k).
!n = 5
!k = 3

' Initialize the first combination.
vector(!k) combination
for !i = 1 to !k
   combination(!i) = !i

while combination(!k) < !n + 1
   ' Do your work evaluating the combination.
   ' As an example, we'll just display the indices that represent the combination.
   for !i = 1 to !k
      %tmp = @str(combination(!i))
      logmsg %tmp
   logmsg "---"

   ' Advance to the next combination
   !j = !k
   while !j > 1 and combination(!j) = !j + !n - !k
      !j = !j - 1
   !s = combination(!j) + 1
   for !i = !j to !k
      combination(!i) = !s
      !s = !s + 1

Posts: 2
Joined: Thu Aug 30, 2018 8:20 am

Re: programs for forecast combination

Postby cecelia » Fri Sep 07, 2018 7:36 am

Hi Matt
Thank you very much for your reply!
My work does need to evaluate the forecasting performance, which is to get the percentage of the superior combinations. I will study the code you provide first, and think about the follow-on work afterwards.

Many thanks!

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 10 guests