Announcement

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

  • Errors in Starting Values using nl

    I'm currently using nonlinear least squares to estimate parameters for a function, but I'm getting an error that says starting values invalid or some RHS variables have missing values. Can someone explain what exactly this means?

    The code I'm using is as follows: nl ((var3) = ({b0}(var1)^({b1}) + (1-{b0})(var2)^({b1}))^(1/{b1}))

    I thought that perhaps I need to add initial values, so I used the initial option as follows: initial(b0 1 b1 0.1), but that doesn't seem to solve my problem. It is true that some values for var2 are missing. Is there an option so that the estimation skips observations that have a missing value for var2?

    I'm very new to using Stata, so thanks for the help!

  • #2
    Products can not be implied using parentheses in this case. And you need to be very careful with the parentheses here. Try
    Code:
    nl ( (var3) = {b0}*( (var1)^({b1}) ) + (1-{b0}) * ( ( (var2)^( {b1} ) )^ ( 1/{b1} ) ) ), initial(b1 1 b0 1)
    Jorge Eduardo Pérez Pérez
    www.jorgeperezperez.com

    Comment


    • #3
      Your observations with missing values will be ignored. There is no option to do this; it will happen anyway, as Stata has no way of knowing what to do about missing values in this problem.

      Comment


      • #4
        Thanks Jorge, I no longer get an error 111 message. However it still says "starting values invalid or some RHS variables have missing values". What other things could be the source of this error?

        Comment


        • #5
          You can try to run the command over the subsample without missing values

          Code:
          gen missing=mi(var2,var3)
          nl ( (var3) = {b0}*( (var1)^({b1}) ) + (1-{b0}) * ( ( (var2)^( {b1} ) )^ ( 1/{b1} ) ) ) if !missing , initial(b1 1 b0 1)
          Jorge Eduardo Pérez Pérez
          www.jorgeperezperez.com

          Comment


          • #6
            My experience of nl is that you do often need really good initial choices. But your initial values look fairly wild in the sense that they might be difficult to recover from if bad choices. Setting b0 to 1 makes the second term vanish. Setting b1 to 0.1 makes the first term start at var0.1 but that's nearly constant. I would try b0 = 0.5, b1 = 1.

            Another stratagem is to plot var3 versus var2 and versus var1 to get an idea of rough behaviour.

            I don't think the message about missing variables applies to the original variables; it implies a problem after (possibly nonlinear) operations on the RHS of the model.

            Comment

            Working...
            X