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

st: Re: nl error


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: nl error
Date   Tue, 11 Oct 2005 11:29:47 -0400

You seem to have an extra space in your line

if "`1' " == "?" {

the space appears after the closing single quote , you need to write "`1'", not "`1' ". That typo means that the if statement will never be true and nl gives the appropriate error message about nlspline refusing the query.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- From: <lm335@drexel.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, October 11, 2005 11:18 AM
Subject: st: nl error



Dear all,
I’ve been having trouble with the nl command in stata. I’m trying to estimate the following function

Crh= b0 + b1*triwk + b2*(max(triwk-k1,0))

The code is given below


gen trisp1=max(triwk -14, 0)
regress crh triwk trisp1
global b0= _b[_cons]
global b1= _b[triwk ]
global b2= _b[trisp1]

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

nl spline crh

When I run the code I get the error:

variable ? not found
nlsplinec refused query, rc=111
<snip>
Thank you for your help.

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