Announcement

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

  • nlsur nonlinear parameter constraints

    I want to estimate a system of equations, imposing that one
    coefficient of the first equation equal the inverse of a coefficient of the
    second equation.

    nlsur (y1 = {b0}+{b1}*x1+{b2}*x2+{b3}*x3+{b4}*x4) (y2 ={d0}+{d1}*x5+{d2}*x6) (y3= {g0}+{g1}*x7)

    and want to impose b1=1/d2. How would you do that? Is the lnsur command the appropriate command for what I'm trying to do?

    Many thanks,

    Jules.

  • #2
    Replace {b1} with 1/{d2} in equation 1. For example

    Code:
    webuse petridish,clear
    //unconstrained
    nlsur (p1 = {b1}*{b2}^t) (p2 = {g1}*{g2}^t)
    //constrained
    nlsur (p1 = {b1=1}*{b2}^t) (p2 = (1/{b1=1})*{g2}^t)

    Comment


    • #3
      And with your type of constraint it is crucial to specify a starting value for the parameter different from 0. Apparently Stata -nlsur- by default initialises the parameters at 0, and this causes a problem with your type of constraint 1/b:

      Code:
      . webuse petridish,clear
      
      . nlsur (p1 = {b1}*{b2}^t) (p2 = (1/{b1})*{g2}^t)
      (obs = 25)
      
      Calculating NLS estimates...
      could not evaluate equation 2
      starting values invalid or some RHS variables have missing values
      r(480);
      
      . nlsur (p1 = {b1=1}*{b2}^t) (p2 = (1/{b1=1})*{g2}^t), nolog
      (obs = 25)
      Calculating NLS estimates...
      Calculating FGNLS estimates...
      
      FGNLS regression 
      -----------------------------------------------------------------------
             Equation |        Obs   Parms       RMSE      R-sq     Constant
      ----------------+------------------------------------------------------
       1           p1 |         25       2   .7212319    0.9264*      (none)
       2           p2 |         25       2    .642312    0.9353*      (none)
      -----------------------------------------------------------------------
      * Uncentered R-sq
      
      ------------------------------------------------------------------------------
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               /b1 |   .9395144   .0558379    16.83   0.000      .830074    1.048955
               /b2 |   1.072133   .0043015   249.25   0.000     1.063702    1.080564
               /g2 |   1.062249   .0043854   242.23   0.000     1.053654    1.070844
      ------------------------------------------------------------------------------
      
      .

      Comment


      • #4
        Works perfectly now. I did not set initial values at first.

        Thanks a lot to both!

        Comment

        Working...
        X