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: RE: what is wrong with my nl function in stata?
From
张志强 <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: what is wrong with my nl function in stata?
Date
Thu, 30 Jan 2014 07:51:43 +0800
thanks kieran, after I add the *, the program still can not work.
besides, the prov variable of my program is the d_ij variable in my nl
function. I found Professor Nick once help someone to estimate the
same equation with local macro, it is on the website :
http://stackoverflow.com/questions/18815618/nonlinear-least-squares-in-stata-how-to-model-summation-over-variables-sets
something like:
forval j = 1/3 {
local call `call' S_over_H_`j'^({alpha2}) * exp({alpha3} * distance_`j')
}
nl (ln_wage = {alpha0} + {alpha1} * ln(`call')
but i still can not figure out how to use the local macro for my nl
evaluation program, can someone help me with this?
Thanks
Happy Chinese lunar new year!
2014-01-30 Kieran McCaul <[email protected]>:
> ...
>
> There is a "*" missing in the second exp() term:
>
> gen double `eterm'=`income'*exp(`k2'*`prov1')+`income'*exp(`k2'`prov2')+`income'*exp(`k2'*`prov3') `if'
>
> It should be:
>
> gen double `eterm'=`income'*exp(`k2'*`prov1')+`income'*exp(`k2'*`prov2')+`income'*exp(`k2'*`prov3') `if'
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of ???
> Sent: Thursday, 30 January 2014 12:56 AM
> To: [email protected]
> Subject: st: what is wrong with my nl function in stata?
>
> Dear all
> I try to estimate a nonlinear lease square function in stata,It need to estimate a compound summation terms like
> lnwage_ij=ko+k1*ln(∑(income*exp(k2*d_ij) , d_ijis the distance between individual observation i and observation j. My problems is how to deal with the ∑ in my nl evaluation function. My naive code are as follows,
>
> the code is as follows:
> 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 prov1: word 3 of `varlist'
> local prov2: word 4 of `varlist'
> local prov3: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'*`prov1')+`income'*exp(`k2'`prov2')+`income'*exp(`k2'*`prov3')
> `if'
>
> replace `lnwage' = `k0' +`k1'*log(`eterm') `if'
>
> end
>
> nl wage1 @lnwage income prov1 prov2 prov3, parameters(k0 k1 k2)
> initial(k0 0.05 k1 0.02 k2 0.03)
>
>
> it return error
>
> nlwage1 returned 199
> verify that nlwage1 is a function evaluator program
>
> What is wrong with my stata code?
> I sincerely hope that someone can help me
>
> Zhiqiangzhang
>
> *
> * 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/
*
* 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/