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: Could someone help me with my nl evaluation program? I update my program.


From   张志强 <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Could someone help me with my nl evaluation program? I update my program.
Date   Fri, 31 Jan 2014 21:37:46 +0800

Thanks Scott.
My program is working well if the dyadic of individual distance is
smaller than 20. is there a limitation for local macro number in nl
command in stata ?
I mean if the dist variables is larger than 20, my nl command did not work.
I sincerely hope that you can help me!



2014-01-30 Scott Merryman <[email protected]>:
> It looks like the  -`if'-  is on a different line following the -gen
> double...- statement.
>
> The example below works:
>
>
> sysuse auto,clear
> gen lnprice = ln(price)
> gen lowweight = (weight < 3000)
> gen lowgear = (gear < 3)
>
> capture program drop nlwage1
> program nlwage1
>  version 12
>  syntax varlist(min=5 max=5) if, at(name)
>  local lnwage : word 1 of `varlist'
>  local income : word 2 of `varlist'
>  local dist1: word 3 of `varlist'
>  local dist2: word 4 of `varlist'
>  local dist3:word 5 of `varlist'
>  tempname k0 k1 k2
>  scalar `k0' = `at'[1, 1]
>  scalar `k1' = `at'[1, 2]
>  scalar `k2' = `at'[1, 3]
>  tempvar eterm
>  gen double `eterm'=`income'*exp(`k2'*`dist1') ///
>      +`income'*exp(`k2'*`dist2') ///
>      +`income'*exp(`k2'*`dist3') `if'
>  replace `lnwage' = `k0' +`k1'*ln(`eterm') `if'
>  end
>
>  nl wage1 @ lnprice mpg foreign lowweight lowgear, ///
>    parameters(k0 k1 k2 ) initial(k0 0.05 k1 0.02 k2 0.03)
>
>
> Scott
> *
> *   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