Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Carolina Lopez <carolina.univ@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Problem with a nl func.eval.program containing 2 other nl programmes |
Date | Tue, 14 Sep 2010 16:00:27 +0200 |
Hi everyone, I need to estimate a non linear cost equation of the form: LnC= rho*(equation1) + (1-rho) * [gamma*(equation2)+(1-gamma)*(equation3)] Where rho and gamma are both dummies. Equation 1 and 2 are non linear, and I have built a nl program for each that work independently- Equation 3 is a regular OLS I am building this NL program, but I cannot make it work. Can I put nl programs in the terms? If not, how can I do this in stata? program define nlcomplete version 11 syntax varlist(min=10 max=10) if, at(name) global lcost: word 1 of `varlist' global lpko: word 2 of `varlist' global lsalratio: word 3 of `varlist' global lgasi: word 4 of `varlist' global sum_lpko: word 5 of `varlist' global sum_lsalratio: word 6 of `varlist' global sum_lgasi: word 7 of `varlist' global n: word 8 of `varlist' global rho: word 9 of `varlist' global gamma: word 10 of `varlist' tempname b0 alpha k bl bq scalar `b0' = `at'[1,1] scalar `alpha' = `at'[1,2] scalar `k' = `at'[1,3] scalar `bl' = `at'[1,4] scalar `bq' = `at'[1,5] tempvar term1 term2 generate double `term1' = (nl case1 @ lcost lpko lsalratio lgasi sum_lpko sum_lsalratio sum_lgasi n, r parameters(b0 alpha k bq bl) initial(startv)) `if' generate double `term2' = (nl case2 @ lcost lpko lsalratio lgasi sum_lpko sum_lsalratio sum_lgasi n, r parameters(b0 alpha k bq bl) initial(startv)) `if' replace `lcost' = ((`rho'*`term1')+((1 -`rho')*(`gamma'*`term2') + (1-`gamma')*(`b0'+`bq'*`lpko'+`bl'*`lsalratio'+`lgasi'))) `if' end nl complete @ lcost lpko lsalratio lgasi sum_lpko sum_lsalratio sum_lgasi n rho gamma, r parameters(b0 alpha k bq bl) initial(startv) Many thanks!!! Carolina * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/