Dear stata list users,
I want to estimate a non-linear least squares model but seem to be unable to create a function evaluator program.
The Name of my program is myreg.
The error I get is the following:
nlmyreg returned 199
verify that nlmyreg is a function evaluator program
I attach a sample of my data that contains my LHS variable, rel_estab_size_c_interp, and the RHS variable, ageq.
Here is the program :
nl myreg @ rel_estab_size_c_interp ageq, parameters(gg a2 a3 q delta zeta) initial(gg 1.0008873 a2 0.5 a3 0.3 q 20 delta 0.018 zeta 2.8)
program nlmyreg
version 12
syntax varlist (min=2) if, at(name)
local rel_estab_size_c_interp: word 1 of `varlist'
local ageq: word 2 of `varlist'
// Retrieve parameters
tempname gg a2 a3 q delta zeta
scalar `gg' = `at'[1,1]
scalar `a2' = `at'[1,2]
scalar `a3' = `at'[1,3]
scalar `q' = `at'[1,4]
scalar `delta' = `at'[1,5]
scalar `zeta' = `at'[1,6]
// Calculate correction factor
matrix define z = J(`q',2,0)
matlist z
forval s = 0/`q' {
z[s+1,2] = ( `gg'^s / ( 1 + `a2' * `a3'^s) )^`zeta'
z[s+1,1] = `delta' * (1-`delta')^s
}
generate double `size_avg_estab' = sum(z(:,1).*z(:,2))/sum(z(:,1)) `if'
// Fill in dependent variable
replace `rel_estab_size_c_interp' = (((`gg'^`ageq')/(1+`a2'*`a3'^`ageq'))^`zeta'))/`size_avg_estab' `if'
end
Thanks in advance for any help.
Best,
Eniko
I want to estimate a non-linear least squares model but seem to be unable to create a function evaluator program.
The Name of my program is myreg.
The error I get is the following:
nlmyreg returned 199
verify that nlmyreg is a function evaluator program
I attach a sample of my data that contains my LHS variable, rel_estab_size_c_interp, and the RHS variable, ageq.
Here is the program :
nl myreg @ rel_estab_size_c_interp ageq, parameters(gg a2 a3 q delta zeta) initial(gg 1.0008873 a2 0.5 a3 0.3 q 20 delta 0.018 zeta 2.8)
program nlmyreg
version 12
syntax varlist (min=2) if, at(name)
local rel_estab_size_c_interp: word 1 of `varlist'
local ageq: word 2 of `varlist'
// Retrieve parameters
tempname gg a2 a3 q delta zeta
scalar `gg' = `at'[1,1]
scalar `a2' = `at'[1,2]
scalar `a3' = `at'[1,3]
scalar `q' = `at'[1,4]
scalar `delta' = `at'[1,5]
scalar `zeta' = `at'[1,6]
// Calculate correction factor
matrix define z = J(`q',2,0)
matlist z
forval s = 0/`q' {
z[s+1,2] = ( `gg'^s / ( 1 + `a2' * `a3'^s) )^`zeta'
z[s+1,1] = `delta' * (1-`delta')^s
}
generate double `size_avg_estab' = sum(z(:,1).*z(:,2))/sum(z(:,1)) `if'
// Fill in dependent variable
replace `rel_estab_size_c_interp' = (((`gg'^`ageq')/(1+`a2'*`a3'^`ageq'))^`zeta'))/`size_avg_estab' `if'
end
Thanks in advance for any help.
Best,
Eniko
Comment