Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Adjusting Brian Poi's nlsurquaid.ado by removing symmetry conditions and `at' in -nl-


From   "Brian P. Poi" <[email protected]>
To   [email protected]
Subject   Re: st: Adjusting Brian Poi's nlsurquaid.ado by removing symmetry conditions and `at' in -nl-
Date   Wed, 23 Feb 2011 07:50:01 -0500

On 2/22/2011 9:35 PM, Alex Olssen wrote:
Dear Statlisters,

My end goal is to estimate a nonlinear system of equations with adding up constraints similar to the QUAIDS model estimated by Brian Poi 2002 and 2008 in the Stata Journal.
Now I am trying to make one adjustment at a time to nlsurquaids.ado to get a handle on altering this function evaluator program.

Right now I am stuck trying to remove the symmetry conditions.  I am not actually estimating a demand system and I do not want the Slutsky symmetry conditions.
I altered nlsurquaids.ado by replacing all the lines that were similar to

scalar `g21' = `g12'    with     scalar `g21'=`at'[1,10]

and bumped the numbering of the [1,x] down for everything else so they didn't overlap.  Removing symmetry conditions left me with 21 parameters to estimate as opposed to Poi's 15 - the symmetry conditions constrain 6 elements below the diagonal.
I then changed the nlsur call from

nlsur quaids @ ... param(a1 a2...)  to include g21, g32 and g33 as parameters as they are no longer inferred from symmetry.

However running the code now gives me the following error messages
"could not evaluate equation 1
starting values invalid or some RHS variables have missing values"

I have successfully made another adjustment earlier and it all worked fine.
I actually don't understand what the `at' is really doing in function evaluator programs in -nl- .  I read the documentation but didn't manage to pick up what `at' was doing from there on my own.
Any help in explaining `at' or guidance with why my removal of symmetry conditions isn't working would be very much appreciated.

Kind regards,


The `at' is nothing more than a vector that contains the parameters at which -nl- or -nlsur- wants you to compute your nonlinear function. The lines like

   scalar `g21' = `at'[1,10]

just give more useful names to each of the parameters. You could write your function entirely in terms of the elements of the `at' vector directly, but for all but the simplest functions I find it easier to break out the `at' vector using names corresponding to the parameters in the model as if I were writing it down on paper.

The error message you get means one of two things. The second is the easier to take care of. None of the variables in your model can contain missing values for any observations. By default, -nlsur- doesn't know what variables are in your model, so it has no way of marking out observations with missing values. The solution is to use the variables() option; see -help nlsur-. In that option, specify all of the variables in your model. That way, -nlsur- can mark out the observations with missing values.

The other way that error message can arise even if you have no missing values is if your function cannot be evaluated at the initial values. By default, -nlsur- sets all the parameters of your model to zero. Some models cannot be evaluated if a parameter is identically zero, leading to -nlsur- issuing that error message. The solution here is to use the initial() option and specify different initial values. Without knowing what your function is, though, there is no way to know if that is the problem.

In short, try the variables() option first. If that doesn't solve the problem then, assuming there are no programming errors in your function evaluator, try specifying alternative initial values using initial().

   -- Brian Poi
   -- [email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index