Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: RE: nl-function log4-formula


From   "Brian P. Poi" <bpoi@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: nl-function log4-formula
Date   Wed, 16 Nov 2011 08:38:52 -0600

Jennyfer Wolf wrote:
Dear Nick,

thanks for your answer.
I tried with the parantheses outside:

2. nl(VAR1={b0}+{b1}/(1+exp(-{b2}*(VAR2-{b3})))) if VAR3=="xxx"

It does not change anything. Still I don't get same reults as with
log4 and only an estimate for b0.
Would you have another idea?

Thank you!
Jennyfer

The difference between using -nl-'s log4 routine and typing in the substitutable expression yourself lies with the starting values that -nl- uses in its optimization routine.  The logistic function that -nl- calls log4 is somewhat sensitive to the starting values you use.  When you type in your own substitutable expression, unless you specify your own starting values, -nl- initializes all the parameters to zero.  On the other hand, -nl-'s log4 routine examines your data to come up with better starting values.  With sensitive nonlinear functions, it's not unheard of for the optimizer to find a different value for the constant term but leave all the other parameters at zero; "strange" results like that are usually a good indication that you should try different starting values.

For the log4 function y = b0 + b1/(1 + exp(-b2*(x-b3))), -nl- sets b0 to slightly less than the smallest value of y in your data and sets b1 to slightly more than the difference between the largest and smallest values of y.  b2 and b3 are initialized based on a linear regression that uses a transformation of y as the dependent variable.  To see the nitty gritty details, you can type in

   . viewsource nllog4.ado

The program code in between the -quietly- braces gets the initial values.


Brian P. Poi
Senior Economist
StataCorp LP
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index