Page 1 of 2

Constraint that sum of coefficients equals 1

Posted: Fri Mar 13, 2009 11:10 am
by michael
Hi,

we are trying to do add two contstraints to a linear regression so that all coefficients sum up to 1 and that all coefficients are positive. Can anyone help?

Thanks.

Re: Constraint that sum of coefficients equals 1

Posted: Fri Mar 13, 2009 11:14 am
by EViews Gareth

Re: Constraint that sum of coefficients equals 1

Posted: Sun Mar 15, 2009 1:54 am
by michael
Gareth can you please clarifiy how the "hack" works. It do not in particular understand the exp in this context. thx

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

Re: Constraint that sum of coefficients equals 1

Posted: Sun Mar 15, 2009 5:32 am
by startz
Gareth can you please clarifiy how the "hack" works. It do not in particular understand the exp in this context. thx

Code: Select all
ai = exp( bi ) / ( exp( b1 ) + exp( b2 ) + ... + exp( bk ) )
Estimate y = (exp(b1)/(exp(b1)+exp(b2)))*x1 + (exp(b2)/(exp(b1)+exp(b2)))*x2 + epsilon

exp(b1) is e^b1 and has to be positive. Use of the fraction guarantees that the coefficients sum to 1.

Re: Constraint that sum of coefficients equals 1

Posted: Mon Mar 16, 2009 12:06 pm
by michael
we have plugged in the following formula but the coefficients still do not add up to 1 - any suggestions?

dlcolonial_prop_apt = (exp(c(2))/(exp(c(2))+exp(c(3))))*dlhotelreits_ind+ (exp(c(3))/(exp(c(2))+exp(c(3))))*dloffreits_ind

Re: Constraint that sum of coefficients equals 1

Posted: Mon Mar 16, 2009 12:18 pm
by startz
we have plugged in the following formula but the coefficients still do not add up to 1 - any suggestions?

dlcolonial_prop_apt = (exp(c(2))/(exp(c(2))+exp(c(3))))*dlhotelreits_ind+ (exp(c(3))/(exp(c(2))+exp(c(3))))*dloffreits_ind
Remember that the estimated coefficient is (exp(c(2))/(exp(c(2))+exp(c(3)))), not c2.

Re: Constraint that sum of coefficients equals 1

Posted: Mon Mar 16, 2009 3:09 pm
by michael
I do not understand the commment as

exp(x) / (exp (x) + exp (y))
and
exp(y) / (exp (x) + exp (y))

should in my opinion nevertheless be one (at least in excel they are). Can you please explain in more detail? Can you for sure confirm that Eviews is able to work in those constraints in the regression as the coefficients do not sum up to one as I would have expected? Thx in advance.

Re: Constraint that sum of coefficients equals 1

Posted: Mon Mar 16, 2009 3:23 pm
by startz
I do not understand the commment as

exp(x) / (exp (x) + exp (y))
and
exp(y) / (exp (x) + exp (y))

should in my opinion nevertheless be one (at least in excel they are). Can you please explain in more detail? Can you for sure confirm that Eviews is able to work in those constraints in the regression as the coefficients do not sum up to one as I would have expected? Thx in advance.
You might want to post your workfile with the equation in it, or at least your output.

Re: Constraint that sum of coefficients equals 1

Posted: Tue Mar 17, 2009 6:42 am
by michael
please see equation 4 of the attached workfile

Re: Constraint that sum of coefficients equals 1

Posted: Tue Mar 17, 2009 7:09 am
by startz
please see equation 4 of the attached workfile
Seeing the equation was very helpful. Note three things about your equation.

(1) The coefficients do add up to 1.0.
(2) EViews tells you in the output that it was unable to complete the estimation. That's what the warning
"WARNING: Singular covariance - coefficients are not unique" means.
(3) The likely reason you are getting the warning is that the coefficients summing to 1.0 is wildly violated in the data. You can see this by running the regression in linear format and doing a Wald test on the coefficients adding to 1.0.

Hope this helps.

Re: Constraint that sum of coefficients equals 1

Posted: Tue Mar 17, 2009 9:55 am
by EViews Glenn
Note that the reason that the user gets a singular covariance message is that the model, as specified, is not identified.

Here is the specification in EQ4:

Code: Select all

DLCOL_APT = (EXP(C(2))/(EXP(C(2))+EXP(C(3))))*DLHOTELR_IND+ (EXP(C(3))/(EXP(C(2))+EXP(C(3))))*DLOFFR_IND
Recall that we want an adding up condition on the coefficients. The user specifies two transformed coefficients as

exp(c(2))/(exp(c(2))+exp(c(3)))

and

exp(c(3)/(exp(c(2))+exp(c(3)))

To further clarify startz's comment that the coefficients do add up to one, note that it's the transformed coefficients that will satisfy the adding up condition in this specification, not the estimated coefficients C(2), C(3)) themselves.

Furthermore, it's easy to see that this specification is overparametrized. Suppose for a moment that I find that I want the transformed coefficients to each equal .5. Then I can set exp(c(3)) to .5 and exp(c(2)) to .5. But I can also set those two values to any (positive) multiple of .5 and, since I have a ratio of terms, I will get the same transformed coefficient values. Hence the specification is trivially not identified.

What you'll need to do to get an estimable equation is normalize one of the terms. Then the remaining coefficient in the specification will define both of the transformed values (via the adding up condition). More generally, if you have K coefficients with an adding up condition, you'll have to normalize 1 of them and the remaining K-1 will determine the remaining fractions. The easiest normalization is to set C(2) to zero (or equivalently, exp(C(2))=1) So, if we specify

Code: Select all

DLCOL_APT = (1/(1+EXP(C(3))))*DLHOTELR_IND+ (EXP(C(3))/(1+EXP(C(3))))*DLOFFR_IND
Cross-section econometrician and statistician types will recognize these as logistic transforms of the coefficient C(3) which sum to 1.

Lastly, I will note that the user hasn't specified a constant in the model above. This may or may not be what the user wanted, but I wanted to point it out.

Re: Constraint that sum of coefficients equals 1

Posted: Sun Mar 22, 2009 2:29 am
by michael
we have worked the problem out with the following solution

c = 0


equation eq7.ls dlcol_sva = c(1) + (exp(c(2))/(1+exp(c(2))) * (dlhotelr_ind - dlus_s_va)) + (exp(c(3))/(1+exp(c(3))) * (dloffr_ind - dlus_s_va)) + (exp(c(4))/(1+exp(c(4))) * (dlresr_ind - dlus_s_va)) + (exp(c(5))/(1+exp(c(5))) * (dlspecr_ind - dlus_s_va)) + (exp(c(6))/(1+exp(c(6))) * (dlus_l_va - dlus_s_va))

vector(6) test = c
vector(6) test_norm

for !i = 1 to 6
test_norm(!i) = @exp(test(!i))/(1+@exp(test(!i)))
next

vector test2 = test_norm/@sum(test_norm) ' coefficients sum to 1


If we want to do a quantile regression with the above equation we get the following error message: "Unable to estimate quantile regression: Specification is nonlinear in the parameters" due to the exp c terms in the equation. Is there any possibility to do a quantile regression with the same restrictions (coefficients sum to one and are not allowed to be negative)? Thx

Re: Constraint that sum of coefficients equals 1

Posted: Mon Mar 23, 2009 9:53 am
by EViews Glenn
Quantile regression currently requires linearity in coefficients. You'll be able to impose the adding up to 1 condition, but not the positivity. It may well turn out that you'll end up with positivity as a natural part of estimation, but you won't be able to reparameterize to guarantee that.

Re: Constraint that sum of coefficients equals 1

Posted: Mon Jun 07, 2010 2:22 pm
by rbanaco
people this is urgent if someone could help me i would be very pleased...


I want the same restriction but i'm not understanding how to do it... i have 4 coefficients and don't know how to put that restriction...

the equation is the equacao3 and i want the same for the 2 too... thank you very much

Re: Constraint that sum of coefficients equals 1

Posted: Tue May 17, 2011 11:55 am
by hermiola
Hello,
I have the following probplem.
I need to solve a Probit regression, where for one of the Variables there is a constraint that the parameter estimate should be equal to 1, i.e.

y = Probit( c(1) + c(2)*x + z)

However, it is not clear how to imput such a constrain.
Also, I face a problem that when I use specification as


equation bn1.binary(D=N) y c(1) c(2)*x z

it uses the previously obtained coefficients as inputs

If anyone has any idea, would be really glad.
THank you in advance.