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: error codes returned by NL function evaluator program to use dummy variables


From   David Raitzer <[email protected]>
To   [email protected]
Subject   Re: st: error codes returned by NL function evaluator program to use dummy variables
Date   Sat, 22 Jun 2013 20:50:52 +0800

Thank you for your help.  I noticed the missing ' just after I sent this.

However, I think the big constraint for me was understanding that the
program needs to be renamed in order for changes/corrections to be
recognized by Stata.  Now that I know that, it has been easier to get
this to run.

Thanks again.

Best,
David

On Sat, Jun 22, 2013 at 1:04 AM, Nick Cox <[email protected]> wrote:
> On a quick read-through I noticed two bugs:
>
>  scalar `drought_c = `at'[1, 6]
>
> lacks a matching ' character.
>
>  local `++atcnt'
>
> is not what you want. It's
>
> local ++atcnt
>
> Nick
> [email protected]
>
>
> On 21 June 2013 09:33, David Raitzer wrote:
>
>> I am trying to use an nl function evaluator program to run a
>> dummy-variable least squares nonlinear regression in Stata 10.1,
>> because nl returns an "expression too long" error if I try to run the
>> regression interactively.  The program that I coded is based on
>> examples posted for a production function in Stata materials, as well
>> as an example previously posted on the Statalist.
>>
>> However, it will not run, and continually returns the error "nlfe3
>> returned 198 verify that nlfe3 is a function evaluator program".
>> Other attempted permutations (where I add the panel identifier newid
>> to the list of variables) shift the error code to 198.    The code is
>> below.  Could somebody please suggest what needs to be corrected?
>
>> program nlfe3
>> version 10.1
>> syntax varlist(min=15 max=15) if, at(name)
>> args lyield lncert yearcount lnha lnirrignew drought flood  pestdum
>> blast blb herbai tungro pestai pestaiBYbph bph
>> tempname const cert year_c lnha_c irrig drought_c flood_c u blast_c
>> blb_c herb_c tungro_c insectkg bph_ins bph_c
>> tempvar kterm lterm
>> scalar `const' = `at'[1, 1]
>> scalar `cert' = `at'[1, 2]
>> scalar `year_c' = `at'[1, 3]
>> scalar `lnha_c' = `at'[1, 4]
>> scalar `irrig' = `at'[1, 5]
>> scalar `drought_c = `at'[1, 6]
>> scalar `flood_c' = `at'[1, 7]
>> scalar `u' = `at'[1, 8]
>> scalar `blast_c' = `at'[1, 9]
>> scalar `blb_c' = `at'[1, 10]
>> scalar `herb_c' = `at'[1, 11]
>> scalar `tungro_c' = `at'[1, 12]
>> scalar `insectkg' = `at'[1, 13]
>> scalar `bph_ins' = `at'[1, 14]
>> scalar `bph_c' = `at'[1, 15]
>> gen double `kterm' = `const'+`cert'*`lncert' + `year_c'*`yearcount' +
>> `lnha_c'*`lnha' +`irrig'*`lnirrignew' +`drought_c'*`drought' +
>> `flood_c'*`flood' `if'
>> gen double `lterm' = `pestdum'*ln(1/(1 + exp(`u'-(1*`blast_c'*`blast'
>> + `blb_c'*`blb' + `herb_c'*`herbai' + `tungro_c'*`tungro' +
>> `insectkg'*`pestai' +`bph_ins'*`pestaiBYbph' +`bph_c'*`bph'))))  `if'
>> replace `lyield' =  `kterm' + `lterm'  `if'
>>
>>         // Now loop over coefficients on newid indicators
>>         local atcnt = 16                 // First element of `at' for
>>                                         // newid is the sixteenth.
>>         forvalues i = 1/519 {             // 519 levels of newid
>>                 replace `lyield' = `lyield' +                         ///
>>                                 `at'[1, `atcnt']*(newid == `i') `if'
>>                 local `++atcnt'
>>         }
>>
>> end
>>
>>
>> nl fe3 @ lyield lncert yearcount lnha lnirrignew drought flood pestdum
>> blast blb herbai tungro pestai pestaiBYbph bph, nparam(533)
> *
> *   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