## programs for forecast combination

For questions regarding programming in the EViews programming language.

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

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

### programs for forecast combination

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: 356
Joined: Thu Apr 25, 2013 7:48 pm

### Re: programs for forecast combination

Hello,

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 +lcreate u 1' Parameters for the combination, modeled after n-choose-k, C(n, k).!n = 5!k = 3' Initialize the first combination.vector(!k) combinationfor !i = 1 to !k   combination(!i) = !inextwhile 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   next   logmsg "---"   ' Advance to the next combination   !j = !k   while !j > 1 and combination(!j) = !j + !n - !k      !j = !j - 1   wend   !s = combination(!j) + 1   for !i = !j to !k      combination(!i) = !s      !s = !s + 1   nextwend`

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

Hi Matt