PDA

View Full Version : Constrained Regression in Stata

meg
06-02-2011, 04:07 PM
Hi!

I need to do a constrained regression in stata-I need all the beta coefficents to sum to 1.

I have 11 independent variables so my regression is:
reg Rrf bills it lt cor lcvalue lcgrowth medcap smallcap noncanbonds us jap if fundno ==`i'

I need all the betas to sum to 1 and there to be a constant.
Can anyone help me with this? Im relatively new to Stata and cant figure this out at all!!

Thanks a lot!

bukharin
06-02-2011, 06:15 PM
I have never done it but found this using the built-in search functions. You can use -cnsreg-. First you need to specify the constraint. Example:
. sysuse auto
(1978 Automobile Data)

. reg price mpg foreign weight

Source | SS df MS Number of obs = 74
-------------+------------------------------ F( 3, 70) = 23.29
Model | 317252881 3 105750960 Prob > F = 0.0000
Residual | 317812515 70 4540178.78 R-squared = 0.4996
-------------+------------------------------ Adj R-squared = 0.4781
Total | 635065396 73 8699525.97 Root MSE = 2130.8

------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg | 21.8536 74.22114 0.29 0.769 -126.1758 169.883
foreign | 3673.06 683.9783 5.37 0.000 2308.909 5037.212
weight | 3.464706 .630749 5.49 0.000 2.206717 4.722695
_cons | -5853.696 3376.987 -1.73 0.087 -12588.88 881.4934
------------------------------------------------------------------------------

. constraint 1 foreign + weight + mpg = 1

. cnsreg price mpg foreign weight , constraints(1)

Constrained linear regression Number of obs = 74
Root MSE = 2500.5874

( 1) mpg + foreign + weight = 1
------------------------------------------------------------------------------
price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
mpg | -88.12063 83.59085 -1.05 0.295 -254.7961 78.5548
foreign | 87.57609 84.06441 1.04 0.301 -80.04358 255.1958
weight | 1.544541 .6042899 2.56 0.013 .3396211 2.749461
_cons | 3352.273 3391.93 0.99 0.326 -3411.044 10115.59
------------------------------------------------------------------------------