Constraint that sum of coefficients equals 1
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Constraint that sum of coefficients equals 1
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.
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.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Constraint that sum of coefficients equals 1
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 ) )
Code: Select all
ai = exp( bi ) / ( exp( b1 ) + exp( b2 ) + ... + exp( bk ) )
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3796
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Constraint that sum of coefficients equals 1
Estimate y = (exp(b1)/(exp(b1)+exp(b2)))*x1 + (exp(b2)/(exp(b1)+exp(b2)))*x2 + epsilonGareth 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 ) )
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
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
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
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3796
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Constraint that sum of coefficients equals 1
Remember that the estimated coefficient is (exp(c(2))/(exp(c(2))+exp(c(3)))), not c2.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
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.
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.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3796
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Constraint that sum of coefficients equals 1
You might want to post your workfile with the equation in it, or at least your output.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
please see equation 4 of the attached workfile
- Attachments
-
- case_v2 eq.1.wf1
- (127.64 KiB) Downloaded 1256 times
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3796
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Constraint that sum of coefficients equals 1
Seeing the equation was very helpful. Note three things about your equation.please see equation 4 of the attached workfile
(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.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Constraint that sum of coefficients equals 1
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:
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
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.
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
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
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
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
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
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Constraint that sum of coefficients equals 1
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
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
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
- Attachments
-
- dados em eviews.wf1
- (122.05 KiB) Downloaded 691 times
Re: Constraint that sum of coefficients equals 1
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.
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.
Who is online
Users browsing this forum: No registered users and 2 guests
