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: 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 10:47:30 +0000

As I read this, every time it is called, -nl- replaces parameters with
values from the matrix you specified. That reduces the scope for
moving away from those initial values.
Nick
[email protected]


On 23 January 2014 09:21, Michael Boehm <[email protected]> wrote:
> Dear Nick,
>
> Thanks for your answer. I am not quite sure I understand it though.
> All the parameters we estimate are free to vary in both
> implementations of the -nl- command (more detailed code below), but
> the estimates are different. Or do I misunderstand something?
>
> program nlexppremia
> 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'
>
> // Retrieve parameters, stored in "at"
> tempname bG pi lambdaL1_0 lambdaL2_0 lambdaEL1_0 lambdaEL2_0
> lambdaL1_1 lambdaL2_1 lambdaEL1_1 lambdaEL2_1
>     scalar `bG' = `at'[1,1]
>     scalar `pi' = `at'[1,2]
>     scalar `lambdaL1_0' = `at'[1,3]
>     scalar `lambdaL2_0' = `at'[1,4]
>     scalar `lambdaEL1_0' = `at'[1,5]
>     scalar `lambdaEL2_0' = `at'[1,6]
>     scalar `lambdaL1_1' = `at'[1,7]
>     scalar `lambdaL2_1' = `at'[1,8]
>     scalar `lambdaEL1_1' = `at'[1,9]
>     scalar `lambdaEL2_1' = `at'[1,10]
>
> // replace the lhs directly:
>     replace `lhs' = `bG'+(`lambdaL1_0'*j+`lambdaL2_0'*j^2) +
> log(1+`pi'*exp(`lambdaEL1_0'*j+`lambdaEL2_0'*j^2)*`e') if `s'==0
>     replace `lhs' = `bG'+(`lambdaL1_1'*j+`lambdaL2_1'*j^2) +
> log(1+`pi'*exp(`lambdaEL1_1'*j+`lambdaEL2_1'*j^2)*`e') if `s'==1
> end
>
> nl exppremia @ lhs s j e, nparameters(10)
>
> ********************************************************************
>
> program nlexppremia
> 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'
>
> // Retrieve parameters, stored in "at"
> tempname bG pi lambdaL1_0 lambdaL2_0 lambdaEL1_0 lambdaEL2_0
> lambdaL1_1 lambdaL2_1 lambdaEL1_1 lambdaEL2_1
>     scalar `bG' = `at'[1,1]
>     scalar `pi' = `at'[1,2]
>     scalar `lambdaL1_0' = `at'[1,3]
>     scalar `lambdaL2_0' = `at'[1,4]
>     scalar `lambdaEL1_0' = `at'[1,5]
>     scalar `lambdaEL2_0' = `at'[1,6]
>     scalar `lambdaL1_1' = `at'[1,7]
>     scalar `lambdaL2_1' = `at'[1,8]
>     scalar `lambdaEL1_1' = `at'[1,9]
>     scalar `lambdaEL2_1' = `at'[1,10]
>
> // Compute RHS of regression
>     tempvar RHS
>     qui gen `RHS'=.
>     replace `RHS' = `bG'+(`lambdaL1_0'*j+`lambdaL2_0'*j^2) +
> log(1+`pi'*exp(`lambdaEL1_0'*j+`lambdaEL2_0'*j^2)*`e') if `s'==0
>     replace `RHS' = `bG'+(`lambdaL1_1'*j+`lambdaL2_1'*j^2) +
> log(1+`pi'*exp(`lambdaEL1_1'*j+`lambdaEL2_1'*j^2)*`e') if `s'==1
>
> //Assign lhs=rhs
>     replace `lhs' = `RHS'
>
> end
>
> nl exppremia @ lhs s j e, nparameters(10)
>
> ********************************************************************
> *
> *   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/


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