Hello to all,

I want to estimate the parameters of a nonlinear equation via a function evaluator program. For this purpose, first, I simulate the data involved in the function:
Code:
gen demand= rnormal(100,40)

gen price=0.3 * (demand/10)^(2.5-1) + rnormal(0, 1)
And then I employed the function evaluator program as the following:

Code:
capture program drop nlces

program nlces

version 12

 syntax varlist(min=2 max=2) [if], at(name)    

//Retrieve the Stata variables from the varlist, use local statements

 local price: word 1 of `varlist'

 local demand: word 2 of `varlist'

//Retrieve the parameters from the matrix specified in at(name), use:

//and reference the parameters as local macros within the program.

tempname a c

 scalar `a' = `at'[1,1]

 scalar `c' = `at'[1,2]

// Some temporary variables

 tempvar dterm

 gen double `dterm' =(`demand'/10)^(`c'-1) `if'

 // Now fill in dependent variable

 replace `price' = `a'*`dterm' `if'

end




 //Call nl like this, specifying initial values for some or all of the parameters:

nl ces @ price demand, parameters(a c)///

initial(a 0.0001 c 1)
However I got the error “nlces returned 198, verify that nlces is a function evaluator program”


I dont see the problem, as I have used the same kind of program with a ces production function and it works perfectly. Can someone help me to solve this? Thank you in advance!