Question

I'm a beginner in Stata. I'm trying to run the following regression:

regress logy logI logh logL

but I would like to constrain the slope of logh to be one. Can someone tell me the command for this?

Was it helpful?

Solution

There are at least three ways to do this in Stata.

1) Use constrained linear regression:

. sysuse auto
(1978 Automobile Data)

. constraint 1 mpg = 1

. cnsreg price mpg weight, constraints(1)

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

 ( 1)  mpg = 1
------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         mpg |          1  (constrained)
      weight |   2.050071   .3768697     5.44   0.000     1.298795    2.801347
       _cons |  -46.14764   1174.541    -0.04   0.969    -2387.551    2295.256
------------------------------------------------------------------------------

2) Variable transformation (suggested by whuber in the comment above):

. gen price2 = price - mpg

. reg price2 weight 

      Source |       SS       df       MS              Number of obs =      74
-------------+------------------------------           F(  1,    72) =   29.59
       Model |   185318670     1   185318670           Prob > F      =  0.0000
    Residual |   450916627    72  6262730.93           R-squared     =  0.2913
-------------+------------------------------           Adj R-squared =  0.2814
       Total |   636235297    73  8715552.01           Root MSE      =  2502.5

------------------------------------------------------------------------------
      price2 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   2.050071   .3768697     5.44   0.000     1.298795    2.801347
       _cons |  -46.14764   1174.541    -0.04   0.969    -2387.551    2295.256
------------------------------------------------------------------------------

3) Using a GLM model with an offset:

. glm price weight , family(gaussian) link(identity) offset(mpg)

Iteration 0:   log likelihood = -683.04238  
Iteration 1:   log likelihood = -683.04238  

Generalized linear models                          No. of obs      =        74
Optimization     : ML                              Residual df     =        72
                                                   Scale parameter =   6262731
Deviance         =  450916626.9                    (1/df) Deviance =   6262731
Pearson          =  450916626.9                    (1/df) Pearson  =   6262731

Variance function: V(u) = 1                        [Gaussian]
Link function    : g(u) = u                        [Identity]

                                                   AIC             =  18.51466
Log likelihood   = -683.0423847                    BIC             =  4.51e+08

------------------------------------------------------------------------------
             |                 OIM
       price |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      weight |   2.050071   .3768697     5.44   0.000      1.31142    2.788722
       _cons |  -46.14764   1174.541    -0.04   0.969    -2348.205    2255.909
         mpg |          1  (offset)
------------------------------------------------------------------------------

The glm route could also handle the log transformation of your outcome for you if you change the link and family options appropriately.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top