Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

SV: st: nl-command sensitive (sometimes) to unit of measurement


From   "Lina Jonsson" <lina.jonsson@vti.se>
To   <statalist@hsphsun2.harvard.edu>
Subject   SV: st: nl-command sensitive (sometimes) to unit of measurement
Date   Wed, 10 Sep 2008 08:51:56 +0200

Thank you Brian.

Specifying eps to e-9 or even e-11 makes the difference between the models smaller, now so small that they seem acceptable.

Best Regards

Lina Jonsson  

> -----Ursprungligt meddelande-----
> Från: owner-statalist@hsphsun2.harvard.edu 
> [mailto:owner-statalist@hsphsun2.harvard.edu] För Brian P. Poi
> Skickat: den 9 september 2008 19:09
> Till: statalist@hsphsun2.harvard.edu
> Ämne: Re: st: nl-command sensitive (sometimes) to unit of measurement
> 
> 
> On Tue, 9 Sep 2008, Lina Jonsson wrote:
> 
> > Dear all,
> >
> > I have encountered a strange phenomenon using the nl-command. I am 
> > estimating a model on two subsets. Among the independet 
> variables are 
> > two variables that measure a distance and when I changed 
> the unit from 
> > meters into km the estimates of other variables in the 
> models changed 
> > (by a substantial amount) for one of the subsets but not the other.
> ...
> >
> > b1 is 0.56 when the distance variables are measured in 
> meters and 0.48 
> > when measured in km, a quite large difference. Any 
> suggestions how to 
> > deal with this?
> >
> 
> A couple of thoughts come to mind.  First, you might try specifying
> eps(1e-8) or eps(1e-9) before you fit the model.  That 
> controls the convergence criterion.  You might find that by 
> tightening that up, the model does in fact converge to the 
> same solution whether you use meters or kilometers.
> 
> Second, in linear regression if you multiply a regressor by 
> 1000 then you will get the same parameters, except the 
> parameter for the regressor you multiplied by 1000 will be 
> 1/1000th of its original value.  However, that property is 
> not always true for nonlinear models.  Here is a trivial 
> example to illustrate that point:
> 
>     . sysuse auto
>     . nl (mpg = {b0} + {b1}*exp(1/gear))
> 
>           mpg |      Coef.   Std. Err.      t    P>|t|
>     --------------------------------------------------
>           /b0 |   88.36907    10.4828     8.43   0.000
>           /b1 |  -47.71047   7.446863    -6.41   0.000
> 
>     . replace gear = gear / 10
>     . nl (mpg = {b0} + {b1}*exp(1/gear))
> 
>           mpg |      Coef.   Std. Err.      t    P>|t|
>     ----------+---------------------------------------
>           /b0 |   27.02461    1.16402    23.22   0.000
>           /b1 |  -.1680976   .0298792    -5.63   0.000
> 
> 
> Thus, the fact that there are 1000 meters in 1 kilometer does 
> not automatically imply that whether you use meters or 
> kilometers will just affect your b1 parameter by a factor of 1000.
> 
> Third, you might try using slightly different starting 
> values.  Do the starting values you use affect the final results?
> 
>     -- Brian Poi
>     -- bpoi@stata.com
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index