Hello everyone,

I am trying to estimate the parameters a and c of a nonlinear equation. The nonlinear equation is: y=a*(x/10)^(c-1). The code that I use is the following:


Code:
program nlces

    version 17
    
    syntax varlist(min=2 max=2) [if], at(name)
    local y: word 1 of `varlist'
    local x: word 2 of `varlist'


    // Retrieve parameters out of at
    tempname a c
    scalar `a' = `at'[1,1]
    scalar `c' = `at'[1,2]


    // Some temporary variables
    tempvar dterm
    generate double `dterm' = (`x'/10)^(`c'-1) `if'
    

    // Now fill in dependent variable
    replace `y' = `a'*`dterm' `if'

end

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

nl ces @ y x, parameters(a c) initial(a 0.0001 c 1)
However, I get the error "nlces returned 9, verify that nlces is a function evaluator program". Could someone give me a hint on how to correct the error? In another question I read that the problem could be that I define the scalars as temporary, but that I refer to them in the -replace- function. Is this the problem? If yes, how can I solve it?

Thank you very much for your help!