I´m following Pinheiro & Bates 2000 pp.345. I want to fit a nls model, and modified a bitt the logistic model. I want to create a self-start function, but an error shows. When I run "logist3P" the error "parameter ‘scal’ does not occur in the model formula" shows. I think that the problem is because I put a formula for the "scal" parameter. How can I put the formula for "scal" and aboid the error?
logistin3P <- function(mCall, LHS, data)
{
xy <- sortedXyData(mCall[["x"]], LHS, data)
if(nrow(xy)<3) {stop("Too few distinct input values to fit a logistic")}
Asym <- max(abs(xy[,"y"]))
if(Asym !=max(xy[,"y"])) Asym <- -Asym #negative asymptote
xmid <- NLSstClosestX(xy, 0.5 * Asym)
scal <- (((log(Asym)+log(Asym*0.75))/ log(Asym*0.75))/((xmid*1.5)-xmid))
value <- c(Asym, xmid, scal)
names(value) <- mCall[c("Asym","xmid","scal")]
value
}
logist3P <- selfStart(~Asym/(1+exp(- scal(x-xmid))), initial = logistin3P, parameters = c("Asym","xmid","scal"))