Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Non-linear constraint in a SURE estimation

    Dear Statalist contributors,

    I am trying to estimate a system of seemingly unrelated labor supplies for couples (called eq1 for women and eq2 for men) with the sureg command in Stata 13 for Windows.

    When I add a linear constraint, the estimation by sureg works. However, I need to impose a non-linear constraint on four coefficients but as soon as I add this, I get the following error message:

    "note: constraint number 1 caused error r(131)".

    I am able to test the constraint expost with the command testnl, but I need to impose it in my estimation.

    Hence, I would really appreciate if anyone could share how to introduce non-linear constraint in a sureg estimation.

    Below, you can find a reproducible example:

    sysuse auto.dta

    constraint 1 [Eq1]mpg*[Eq2]headroom = [Eq1]headroom*[Eq2]length

    sureg (Eq1: price = mpg trunk weight rep78 headroom)///
    (Eq2 : price = headroom length), ///
    corr constraint(1)

    (note: constraint number 1 caused error r(131))
    (note: constraint number 1 caused error r(131))
    Last edited by Iris Laugier; 21 May 2019, 05:18.

  • #2
    Your example constraint would be linear on logarithmic scale. I don't know how much that helps.

    In general, either there is a trick to make a constraint linear or you need something quite different. The help for constraint makes it quite clear: it's about linear constraints. Other kinds of constraint require quite different machinery
    Last edited by Nick Cox; 21 May 2019, 05:26.

    Comment


    • #3
      Hello,

      Thanks for your reply.
      I have tried to use the log to linearize my constraint but it still doesn't work.

      In case it can help, to be sure that's what you were suggesting, here is what I have done:

      sysuse auto.dta
      constraint 2 ln([Eq1]mpg) + ln([Eq2]headroom) = ln([Eq1]headroom) + ln([Eq2]length)
      sureg (Eq1: price = mpg trunk weight rep78 headroom) (Eq2 : price = headroom length), corr constraint(2)

      I still get the error message 131.

      Otherwise, how can I add a nonlinear constraint using another command than constraint, which is clearly not the relevant command as you highlighted?
      Last edited by Iris Laugier; 21 May 2019, 05:37.

      Comment


      • #4
        constraint 1 [Eq1]mpg*[Eq2]headroom = [Eq1]headroom*[Eq2]length
        How many ways can you satisfy this constraint? I can think of at least three.

        Comment


        • #5
          That's still a nonlinear constraint! .

          What I meant -- sorry that this did not seem clear as an implication -- was that you should consider logging your variables first.

          In turn, I don't know more than you do about these kinds of models, so if that isn't an answer, you will have to hope for a much better one from someone else.

          Comment


          • #6
            Hello again,

            Andrew Musau, what do you mean exactly ? Are you talking in terms of different ways to write the constraint ? I am not sure to understand sorry.

            Thanks for your help Nick Cox, but the issue is that some of the constrained variable are already in log. Yes I really hope someone could help me finding a command that allows to add these kinds of cross-equation constraints in my estimation...

            Comment


            • #7
              Here are the three ways to satisfy your constraint in your example:

              Code:
              sysuse auto.dta, clear
              constraint 1 [Eq1]mpg = [Eq1]headroom
              constraint 2 [Eq2]headroom = [Eq2]length
              constraint 3 [Eq1]mpg = [Eq2]length
              constraint 4 [Eq2]headroom =  [Eq1]headroom
              constraint 5 [Eq1]mpg =0
              constraint 6 [Eq2]headroom =0
              constraint 7 [Eq1]headroom =0
              constraint 8 [Eq2]length= 0
              
              
              
              *ONE
              sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              (Eq2 : price = headroom length), ///
              corr constraint(1/2)
              
              di _b[Eq1:mpg]* _b[Eq2:headroom]
              di _b[Eq1:headroom]*_b[Eq2:length]
              
              *TWO
              sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              (Eq2 : price = headroom length), ///
              corr constraint(3/4)
              
              di _b[Eq1:mpg]* _b[Eq2:headroom]
              di _b[Eq1:headroom]*_b[Eq2:length]
              
              *THREE
              sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              (Eq2 : price = headroom length), ///
              corr constraint(5/8)
              
              di _b[Eq1:mpg]* _b[Eq2:headroom]
              di _b[Eq1:headroom]*_b[Eq2:length]

              Results:

              Code:
              .
              . *ONE
              . sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              > (Eq2 : price = headroom length), ///
              > corr constraint(1/2)
              
              Seemingly unrelated regression
              --------------------------------------------------------------------------
              Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
              --------------------------------------------------------------------------
              Eq1                   69       4    2420.434    0.2992      27.49   0.0000
              Eq2                   69       1    2606.379    0.1874      17.21   0.0000
              --------------------------------------------------------------------------
              
               ( 1)  [Eq1]mpg - [Eq1]headroom = 0
               ( 2)  [Eq2]headroom - [Eq2]length = 0
              ------------------------------------------------------------------------------
                           |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              Eq1          |
                       mpg |  -27.77603   30.62623    -0.91   0.364    -87.80233    32.25027
                     trunk |   22.01142   34.80338     0.63   0.527    -46.20194    90.22479
                    weight |   1.289644   .3228062     4.00   0.000     .6569555    1.922333
                     rep78 |   178.0181   120.5124     1.48   0.140    -58.18178     414.218
                  headroom |  -27.77603   30.62623    -0.91   0.364    -87.80233    32.25027
                     _cons |   1997.623   1539.899     1.30   0.195    -1020.524    5015.769
              -------------+----------------------------------------------------------------
              Eq2          |
                  headroom |   46.69754   11.25515     4.15   0.000     24.63786    68.75723
                    length |   46.69754   11.25515     4.15   0.000     24.63786    68.75723
                     _cons |  -2786.723   2175.619    -1.28   0.200    -7050.858    1477.412
              ------------------------------------------------------------------------------
              
              Correlation matrix of residuals:
              
                      Eq1     Eq2
              Eq1  1.0000
              Eq2  0.9224  1.0000
              
              Breusch-Pagan test of independence: chi2(1) =    58.703, Pr = 0.0000
              
              .
              . di _b[Eq1:mpg]* _b[Eq2:headroom]
              -1297.0725
              
              . di _b[Eq1:headroom]*_b[Eq2:length]
              -1297.0725
              
              .
              . *TWO
              . sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              > (Eq2 : price = headroom length), ///
              > corr constraint(3/4)
              
              Seemingly unrelated regression
              --------------------------------------------------------------------------
              Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
              --------------------------------------------------------------------------
              Eq1                   69       5    2465.924    0.2726      22.20   0.0005
              Eq2                   69       2    2617.456    0.1804      13.40   0.0012
              --------------------------------------------------------------------------
              
               ( 1)  [Eq1]mpg - [Eq2]length = 0
               ( 2)  - [Eq1]headroom + [Eq2]headroom = 0
              ------------------------------------------------------------------------------
                           |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              Eq1          |
                       mpg |   39.67708   11.03947     3.59   0.000     18.04011    61.31405
                     trunk |   24.26749   37.09673     0.65   0.513    -48.44077    96.97575
                    weight |   1.480866   .3390225     4.37   0.000     .8163939    2.145338
                     rep78 |   125.6837   121.2402     1.04   0.300    -111.9427    363.3101
                  headroom |  -240.9094   364.2952    -0.66   0.508    -954.9148     473.096
                     _cons |    767.985   1443.824     0.53   0.595    -2061.857    3597.827
              -------------+----------------------------------------------------------------
              Eq2          |
                  headroom |  -240.9094   364.2952    -0.66   0.508    -954.9148     473.096
                    length |   39.67708   11.03947     3.59   0.000     18.04011    61.31405
                     _cons |  -602.0196   1989.094    -0.30   0.762    -4500.571    3296.532
              ------------------------------------------------------------------------------
              
              Correlation matrix of residuals:
              
                      Eq1     Eq2
              Eq1  1.0000
              Eq2  0.9201  1.0000
              
              Breusch-Pagan test of independence: chi2(1) =    58.414, Pr = 0.0000
              
              .
              . di _b[Eq1:mpg]* _b[Eq2:headroom]
              -9558.5818
              
              . di _b[Eq1:headroom]*_b[Eq2:length]
              -9558.5818
              
              .
              . *THREE
              . sureg (Eq1: price = mpg trunk weight rep78 headroom) ///
              > (Eq2 : price = headroom length), ///
              > corr constraint(5/8)
              
              Seemingly unrelated regression
              --------------------------------------------------------------------------
              Equation             Obs   Parms        RMSE    "R-sq"       chi2        P
              --------------------------------------------------------------------------
              Eq1                   69       3    2546.868    0.2240      15.08   0.0017
              Eq2                   69       0    2891.259    0.0000          .        .
              --------------------------------------------------------------------------
              
               ( 1)  [Eq1]o.mpg = 0
               ( 2)  [Eq2]o.headroom = 0
               ( 3)  [Eq1]o.headroom = 0
               ( 4)  [Eq2]o.length = 0
              ------------------------------------------------------------------------------
                           |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              Eq1          |
                       mpg |          0  (omitted)
                     trunk |  -33.82572   53.17986    -0.64   0.525    -138.0563    70.40489
                    weight |    1.02673   .3139409     3.27   0.001     .4114168    1.642042
                     rep78 |   313.0268   189.2084     1.65   0.098    -57.81487    683.8684
                  headroom |          0  (omitted)
                     _cons |   2437.973   1157.528     2.11   0.035     169.2588    4706.687
              -------------+----------------------------------------------------------------
              Eq2          |
                  headroom |          0  (omitted)
                    length |          0  (omitted)
                     _cons |   6146.043   348.0666    17.66   0.000     5463.845    6828.242
              ------------------------------------------------------------------------------
              
              Correlation matrix of residuals:
              
                      Eq1     Eq2
              Eq1  1.0000
              Eq2  0.7932  1.0000
              
              Breusch-Pagan test of independence: chi2(1) =    43.412, Pr = 0.0000
              
              .
              . di _b[Eq1:mpg]* _b[Eq2:headroom]
              0
              
              . di _b[Eq1:headroom]*_b[Eq2:length]
              0
              Last edited by Andrew Musau; 25 May 2019, 07:54.

              Comment


              • #8
                Hello, thanks a lot for your precise answer! I am gonna implement it in my actual program with my data.

                Best Regards,

                Comment

                Working...
                X