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

Re: st: Nonlinear regression


From   "maartenbuis" <[email protected]>
To   [email protected]
Subject   Re: st: Nonlinear regression
Date   Sun, 09 Oct 2005 21:11:39 -0000

Dear Leny,

You forgot to close one of the comments. I do not see how that could
produce the error message you got, but it is certainly worthwile to
close it. I indicated this in your code. You can update your Stata
without charge to version 8.2, by using the -update- command. So this
could help if the version of Stata is the problem, as you suggested.
If those two things don't work than I would simplify the code to see
if you can narrow down the problem. For instance, does the command
work if you have only one knot (direct translation of the example code
I sent earlier)?  

Hope this helps,
Maarten

--- <lm335@d...> wrote:
> 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)) 

You forgot to close this comment (*/)

> 
> 
> 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.




*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index