我跟随Pinheiro& Bates 2000 pp.345。我想适应一个nls模型,并修改了一个逻辑模型。我想创建一个自启动功能,但错误显示。当我运行“logist3P”时,模型公式中没有出现错误“参数'标尺'”。我认为问题是因为我为“scal”参数设置了一个公式。如何将“scal”的公式放入并避免错误?
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"))
答案 0 :(得分:0)
我相信您在模型参数中的*
之后缺少scal
:
logist3P <- selfStart(~Asym/(1+exp(- scal*(x-xmid))), initial = logistin3P, parameters = c("Asym","xmid","scal"))