I'm using S-PLUS Enterprise Developer Version 7.0.6 for Microsoft
Windows, and want to run a constrained non-linear regression. The help
page for nlregb oddly provides only an example of *linear* regression,
and I don't see just how to use the function for my problem. Here's
what I've tried, with a trial dataset:
tC <- c(rep(0,5),rep(1,5)) # Dummy var for cooling cycle
tH <- c(rep(1,5),rep(0,5)) # Dummy var for warming cycle
restime <- rnorm(10,6,0.5)
fake <- data.frame(tC,tH,restime)
n <- length(fake$restime)
resid.func <- function(x,fake)
{-(1/x[1])*
(fake$tC * log((x[2]-2)/(x[3]-2)) +
fake$tH * log((x[3]-38)/(x[2]-38))) -
fake$restime }
NLLS.constrained <- nlregb(
nres=n,
start=c(0.004,4,36), # parms: k, m, M
residuals=resid.func,
lower=c(0,2+0.1,2+0.1),
upper=c(Inf,38-0.1,38-0.1),
data=fake)
I get this error message:
Problem in .Fortran("n2b0",: subroutine n2b0: Argument 6 has zero length
Use traceback() to see the call stack
I'm guessing that the parameters aren't getting to the residual function
correctly, but I don't see how to get them there. I'll appreciate any
help. Thanks.
David Parkhurst
|