Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Nonlinear regression


From   <lm335@drexel.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Nonlinear regression
Date   Fri, 07 Oct 2005 14:49:42 -0400

Dear all,
         I'm trying to use the nl command to estimate the parameters of the following equation.

crh= b0 + b1*triwk + b2*(max(triwk  - k1,0)) + b3*(max(triwk - k2, 0)) 

I'm using version 8.1 and the code and the error message given below. 

gen  trisp1=max(triwk -14, 0) if group1==0 & TRI <=3
gen  trisp2=max(triwk -25, 0) if group1==0 & TRI <=3
regress crh triwk trisp1 trisp2 if group1 ==0 & TRI <=3
global b0= _b[_cons]
global b1= _b[triwk ]
global b2= _b[trisp1]
global b3= _b[trisp2]

/*The model is crh=b0 + b1*triwk + b2*(max(triwk  - k1,0)) + b3*(max(triwk - k2, 0)) 


capture program drop nlspline
program define nlspline
if "`1' " =="?"{
global S_1 "b0 b1 b2 b3 k1 k2"
global b0= $b0
global b1= $b1
global b2= $b2
global b3= $b3
global k1=14
global k2=25
exit
}
replace `1' = $b0 + $b1*triwk + $b2*(max(triwk - $k1, 0)) + $b3*(max(triwk - $k2, 0))
end

nl spline crh

triwk- invalid name
nlspline refused query, rc=198
r(198);


I found a similar query in the archives which turned out to be a problem with the version of Stata  being used. I rechecked my code and it seems to follow the syntax. I would appreciate any help on this issue.

Thank you

Leny




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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