Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: problems with substitutable expression program for nonlinear regression


From   "Sarah Kristina Reuter" <sarah.kristina.reuter@uni-jena.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: problems with substitutable expression program for nonlinear regression
Date   Fri, 04 Nov 2011 13:46:06 +0100

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
 


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index