Hi, In the third edition of the MASS book, Chapter 8, Page 252 ~ 253. I tried applying the same technique on using a negative exponential model (as suggested in Exercise 1), and trying to get a confidence interval. What I have changed is follows: expn <- function(b0, b1, th, x) { temp <- exp(-x/th) model.func <- b0 + b1 * temp # Differentiate temp derive.negexp <- (x * temp) / th^2 Z <- cbind(1, temp, derive.negexp) dimnames(Z) <- list(NULL, c("b0","b1","th")) attr(model.func, "gradient") <- Z model.func } wtloss.gr <- nls(Weight ~ expn(b0, b1, th, Days), data = wtloss, start = wtloss.st, trace = F) expn2 <- deriv(~b0 + b1*((w0 - b0)/b1)^(x/d0), c("b0","b1","d0"), function(b0, b1, d0, x, w0) {}) wtloss.init <- function(obj, w0) { p <- coef(obj) # Modified d0 for neg exp model d0 <- - log((w0 - p["b0"])/p["b1"]) * p["th"] c(p[c("b0", "b1")], d0 = as.vector(d0)) } However when running the above codes in R, it stopped at wtloss.gr with the error: Error in nls(Weight ~ expn(b0, b1, th, Days), data = wtloss, start wtloss.st, : step factor 0.000488281 reduced below `minFactor' of 0.000976562 Execution halted Any hints on where I did wrong would be greatly appreciated, Ko-Kang Wang ------------------------------------------------------------------------------ Ko-Kang Kevin Wang Postgraduate PGDipSci Student Department of Statistics University of Auckland New Zealand -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._