[R] Non-linear Regression best-fit line

Dennis Murphy djmuser at gmail.com
Sat Jun 18 08:51:55 CEST 2011


Hi:

Perhaps the self-starting functions may be helpful. See ?selfStart.
There are self-starting functions for both the logistic and Gompertz
models (SSlogis and SSgompertz, respectively). Go through the examples
to see how they work.

HTH,
Dennis

On Fri, Jun 17, 2011 at 2:14 PM, Sean Bignami <bignami83 at gmail.com> wrote:
> I am trying to fit a curve to a cumulative mortality curve (logistic) where y is the cumulative proportion of mortalities, and t is the time in hours (see below). Asym. at 0 and 1
>> y
>  [1] 0.00000000 0.04853859 0.08303777 0.15201970 0.40995074 0.46444992 0.62862069 0.95885057 1.00000000
> [10] 1.00000000 1.00000000
>> t
>  [1]  0 13 20 24 37 42 48 61 72 86 90
>
> I tried to find starting values for a Gompertz non-linear regression by converting the equation (y~1*exp(-beta*exp(-gamma*t)) to a linear form per Dalgaard "Introductory Statistics with R" pg.279-280. But got this Error message:
>
>> lm(log(0-log(y))~t)
> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
>  NA/NaN/Inf in foreign function call (arg 4)
>
> I tried to change all by 0 and 1 values to non-zero and non-one values (yy and tt below), and was able to get starting estimates.
>
>> yy<-c(0.000000001,0.04853859, 0.08303777, 0.15201970, 0.40995074, 0.46444992, 0.62862069, 0.95885057, 0.9999999999,0.999999999999,0.999999999999)
>> tt<-c(0.0000000001,13,20,24,37,42,48,61,72,86,90)
>
>> lm(log(0-log(yy))~tt)
>
> Call:
> lm(formula = log(0 - log(yy)) ~ tt)
>
> Coefficients:
> (Intercept)           tt
>     9.5029      -0.3681
>
> However, when I plug those values into the nls function, I get an error message about the "getInitial" method
>
>> nlsout<-nls(y~1*exp(-beta*exp(-gamma*t),start=c(beta=exp(9.5),gamma=.368)));summary(nlsout)
> Error in getInitial.default(func, data, mCall = as.list(match.call(func,  :
>  no 'getInitial' method found for "function" objects
>
> Can anyone help clarify how I can find the parameters for a best-fit curve for this data? Thanks!!
>
> Sean
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list