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]

st: Two seemingly similar NL estimations give different results


From   Michael Boehm <[email protected]>
To   [email protected]
Subject   st: Two seemingly similar NL estimations give different results
Date   Thu, 23 Jan 2014 09:44:31 +0100

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/


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