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   Alex Olssen <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Adjusting Brian Poi's nlsurquaid.ado by removing symmetry conditions and `at' in -nl-
Date   Thu, 24 Feb 2011 09:10:31 +1300

Dear Brian,

Thanks a lot for your response.  I managed to remove the symmetry conditions when doing it one at a time - I think I must have made a typing error somewhere.
Your comment on `at' helps a lot.  As I understand it we need to send -nlsur- or -nl- a list of parameters to estimate.  If we don't name the parameters then we can just refer to them as elements of the vector `at'?  Renaming can make our code more readable, particularly when it contains many parameters.

I think I'm going to try right up my own function evaluator from scratch and test it part by part.  Also, thanks drawing my attention to the variable() option.

Kind regards,

Alex Olssen
Research Analyst
Motu Economic & Public Policy Research
Ph 939 4250  Fax 939 4251
This email contains information which is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this email or attachments. If you have received this in error, please notify us immediately by return email, facsimile or telephone and delete this email. Thank you

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Brian P. Poi
Sent: Thursday, February 24, 2011 1:50 AM
To: [email protected]
Subject: Re: st: Adjusting Brian Poi's nlsurquaid.ado by removing symmetry conditions and `at' in -nl-

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/

*
*   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