Dear Statalisters,
I apologize for a beginner-question, but I have some problems writing a substitutable
_expression_ program for nonlinear regression. The model is:
y = y0 * (1-x^q)
y and x are given, q is to be estimated and y0 is the y-value of a specific data-point,
namely the smallest x.
The problems I have are
- “explaining” Stata y0 and
- Stata returns the following error message: “verify that nlreg is a substitutable
_expression_ program and that you have specified all options that it requires” and I
can’t find the error.
Here is my program:
program nlreg, rclass
version 10
syntax varlist(min=2 max=2) [aw fw iw] [if] [in]
tempvar touse
mark `touse' `if' `in'
local lhs: word 1 of `varlist'
local rhs: word 2 of `varlist'
*specifying y0, even to me that looks complicated
tempname a b
su `rhs' if `touse’, meanonly
scalar `a' = r(min)
gen `b’=`lhs’ if `rhs’==`a’
su `b’, meanonly
scalar `y0’=r(min)
return local eq "`lhs' = `y0'*(1-`rhs'^{gamma})"
return local title "`lhs' = `y0'*(1-`rhs'^gamma)"
end
So happy for any suggestions!
Thanks!
Sarah