Dear all
i want to fit the self start model in nls. i have two question. i have a
function,
(asfr ~ I(((a*b)/c))+ ((c/age)^3/2)+ exp((-b^2)*(c/age)+(age/c)-2)
i am wondering how to build the selfstart model. there is lost of example,
(i.e. SSgompertz, SSmicman, SSweibull, etc). my question is, how to derive
the function of parameters. and also which model to use for get
the initials values. In the following example's the red color coding
requires the explanation??

thanks

SSgompertz
function (x, Asym, b2, b3)
{
    .expr2 <- b3^x
    .expr4 <- exp(-b2 * .expr2)
    .value <- Asym * .expr4
    .actualArgs <- as.list(match.call()[c("Asym", "b2", "b3")])
    if (all(unlist(lapply(.actualArgs, is.name)))) {
        .grad <- array(0, c(length(.value), 3L), list(NULL, c("Asym",
            "b2", "b3")))
        .grad[, "Asym"] <- .expr4
        .grad[, "b2"] <- -Asym * (.expr4 * .expr2)
        .grad[, "b3"] <- -Asym * (.expr4 * (b2 * (b3^(x - 1) *
            x)))
        dimnames(.grad) <- list(NULL, .actualArgs)
        attr(.value, "gradient") <- .grad
    }
    .value

attr(,"initial")
function (mCall, data, LHS)
{
    xy <- sortedXyData(mCall[["x"]], LHS, data)
    if (nrow(xy) < 4) {
        stop("too few distinct input values to fit the Gompertz model")
    }
    xyL <- xy
    xyL$y <- log(abs(xyL$y))
    pars <- NLSstAsymptotic(xyL)
    pars <- coef(nls(y ~ exp(-b2 * b3^x), data = xy, algorithm = "plinear",
        start = c(b2 = pars[["b1"]], b3 = exp(-exp(pars[["lrc"]])))))
    val <- pars[c(3, 1, 2)]
    names(val) <- mCall[c("Asym", "b2", "b3")]
    val
}

Cheers
-- 
Muhammad Asif Wazir
Ph.D student
Institut für Statistik und Decision Support Systems (ISDS).
University of Vienna, Austria
cell: 00436509092298

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to