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: Two seemingly similar NL estimations give different results
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Two seemingly similar NL estimations give different results
Date
Thu, 23 Jan 2014 08:50:42 +0000
The key question is what in your code is free to vary? Only parameters
that are free to vary can be estimated by -nl-; the others are fixed
constants.
Nick
[email protected]
On 23 January 2014 08:44, Michael Boehm <[email protected]> wrote:
> Dear all,
>
> We are struggling with nonlinear least square regression with a
> function evaluator programme. We don’t understand why assigning to the
> left-hand side variable, lhs, directly an expression for the
> right-hand side is different to first computing the right-hand side
> variable, rhs, and then assigning lhs=rhs.
> Both residual SS and parameter estimates differ across the two
> scenarios. A sketch of the two codes, which we thought would give the
> same results are:
>
> program nltest_1
>
> version 13.1
> syntax varlist(min=4 max=4) [aw fw iw]
> if, at(name)
>
> // Retrieve variables
> local lhs: word 1 of `varlist'
> local s: word 2 of `varlist'
> local j: word 3 of `varlist'
> local e: word 4 of `varlist'
>
> // replace the lhs directly:
> replace `lhs'= <Function of Parameters
> and Variables> if `s'==0
> replace `lhs'= <Function of Parameters
> and Variables> if `s'==1
> end
>
> ********************************************************************
> program nltest_1
>
> version 13.1
> syntax varlist(min=4 max=4) [aw fw iw]
> if, at(name)
>
> // Retrieve variables
> local lhs: word 1 of `varlist'
> local s: word 2 of `varlist'
> local j: word 3 of `varlist'
> local e: word 4 of `varlist'
>
> // Compute RHS of regression
> tempvar RHS
> replace `RHS'= <Function of Parameters
> and Variables> if `s'==0
> replace `RHS'= <Function of Parameters
> and Variables> if `s'==1
>
> //Assign lhs=rhs.
> replace `lhs' = `RHS'
>
> end
> ********************************************************************
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/