Page 1 of 1

Non negativity constraints on forecasts

Posted: Tue Nov 22, 2016 3:42 pm
by jacarandas
Hi,

I am attempting to forecast a few variables (ratios) in a very simple manner - using a time trend and lag value of the variable. In the following code, a b c are groups with the variables in them. There are two requirements:
1. The forecasts of these variables (ratios) are constrained by the identity set out below. Basically, the ratios will sum up to 1. (Actually, I just realised that sum of the identity appears to be imposed, while some aren't. Is there a standard way of making sure the ratios sum up to 1 in the forecasts?)
2. The forecasts of these variables can't be negative. How can I go about setting up this constraint in the following code?
I had a look at this thread: http://forums.eviews.com/viewtopic.php?t=48. But, I am still not entirely sure how to add in this non-negativity constraint in my case.

Code: Select all

for %g a b c model shares_{%g} for !i=1 to {%g}.@count %1 = {%g}.@seriesname(!i) equation eqxr{%1}.ls xr{%1} c @trend xr{%1}(-1) shares_{%g}.merge eqxr{%1} next next shares_a.append @identity asum = a1 + a2 + a3 shares_b.append @identity bsum = b1 + b2 + b3 + b4 shares_c.append @identity csum = c1 + c2 + c3 + c4 + c5 smpl July2014 July2050 for %g a b c shares_{%g}.solve next
Any help would be greatly appreciated. Thanks.

Re: Non negativity constraints on forecasts

Posted: Tue Nov 29, 2016 2:17 am
by jacarandas
Hi,

Just wondering if anyone is able to help? I have a large number of identities in each model. But, I'm not entirely sure how to go about imposing the inequality as follows:

Mixed equality and inequality

A commonly encountered mixed type of restriction is to have all parameters non-negative and sum up to one


ai > 0 and a1 + a2 + ... + ak = 1


A reparameterization that satisfies these constraints is

Code: Select all
ai = exp( bi ) / ( exp( b1 ) + exp( b2 ) + ... + exp( bk ) )


where the bi parameters are unconstrained.


Any help would be great.

Thanks.

Re: Non negativity constraints on forecasts

Posted: Tue Nov 29, 2016 10:37 am
by EViews Glenn
Where are the ai coming from in your original example?

Re: Non negativity constraints on forecasts

Posted: Tue Nov 29, 2016 9:43 pm
by jacarandas
Hi,

My ai's in this example are:

shares_a system - a1, a2, a3
shares_b system - b1, b2, b3, b4
shares_c system - c1, c2, c3, c4, c5

So, these are historical ratios I have calculated, and they add up to 1.

But, I wasn't sure how to ensure that when the system is solved, the forecasts of these ratios are all positive and add up to 1. The identities I have imposed appear to add most of them up to 1. But, some of them don't.

Any help would be great.

Re: Non negativity constraints on forecasts

Posted: Wed Nov 30, 2016 1:00 pm
by EViews Glenn
Can you post what you've currently done.

Re: Non negativity constraints on forecasts

Posted: Wed Nov 30, 2016 3:54 pm
by jacarandas
Hi,

Here's what I have done so far. The identity was one way I thought would ensure that the ratios sum up to 1 in the forecasts. But, I am doubtful now.

Here are the constraints I am hoping to implement:
- Forecast ratios in each group sum up to 1
- None of the forecast ratios are <1

Any help on how I can amend the code would be appreciated.

Code: Select all

'Calculate historical ratios for %g a b c for !i=1 to {%g}.@count %1 = {%g}.@seriesname(!i) series xr{%1} = {%1}/@rsum({%g}) series xr{%g}sum = @rsum({%g})/@rsum({%g}) next next 'Create and estimate models to forecast ratios for %g a b c model shares_{%g} for !i=1 to {%g}.@count %1 = {%g}.@seriesname(!i) equation eqxr{%1}.ls xr{%1} c @trend xr{%1}(-1) shares_{%g}.merge eqxr{%1} next next 'Create adding up constraints shares_a.append @identity xrasum = a1 + a2 + a3 shares_b.append @identity xrbsum = b1 + b2 + b3 + b4 shares_c.append @identity xrcsum = c1 + c2 + c3 + c4 + c5 'Solve the model smpl July2014 July2050 for %g a b c shares_{%g}.solve next