Finding starting values for the parameters

35 views
Skip to first unread message

gaopinglei

unread,
Oct 8, 2016, 9:24:14 AM10/8/16
to ggplot2
All,
I have some data that i'm trying to fit a double exponential model: data. Frame (Area=c (521.5, 689.78, 1284.71, 2018.8, 2560.46, 524.91, 989.05, 1646.32, 2239.65, 2972.96, 478.54, 875.52, 1432.5, 2144.74, 2629.2),
Retention=c (95.3, 87.18, 44.94, 26.36, 18.12, 84.68, 37.24, 33.04, 23.46, 9.72, 97.92, 71.44, 44.52, 24.44, 15.26) ) and the formula of the double exponential is: exp (b0*exp (b1*x^th)).
I failed to guess the initial parameter values and then I learned a measure to find starting values from Nonlinear Regression with R (pp. 25-27):

> cl<-data.frame(Area =c(521.5, 689.78, 1284.71, 2018.8, 2560.46, 524.91, 989.05, 1646.32, 2239.65, 2972.96, 478.54, 875.52, 1432.5, 2144.74, 2629.2),

+ Retention =c(95.3, 87.18, 44.94, 26.36, 18.12, 84.68, 37.24, 33.04, 23.46, 9.72, 97.92, 71.44, 44.52, 24.44, 15.26) )

> expFct <- function(Area, b0, b1,th) {exp(b0*exp(b1*Area^th))}

> grid.Disperse <- expand.grid(list(b0 = seq(0.01,4, by = 0.01), th = c(0.02),b1 = seq(0.01, 4, by = 0.01)))

> Disperse.m2a <- nls2(Retention ~expFct(Area, b0, b1,th), data = cl, start = grid.Disperse, algorithm = "brute-force")

> Disperse.m2a

Nonlinear regression model

  model: Retention ~ expFct(Area, b0, th, b1)

   data: cl

b0   th   b1

3.82 0.02 0.01

 residual sum-of-squares: 13596

 

Number of iterations to convergence: 160000

Achieved convergence tolerance: NA

I got no error then I use the output as starting values to nls2 ():

> nls.m1<- nls2 (Retention ~ expFct(Area, b0, b1,th), data = cl, start = list(b0 = 3.82, b1 = 0.01, th = 0.02))

Error in (function (formula, data = parent.frame(), start, control = nls.control(),  :

Singular gradient

Why? Did I do something wrong or misunderstand something?

Later, I found another measure from Modern Applied Statistics with S (pp. 216-217): 

> negexp <- selfStart(model = ~ exp(b0*exp(b1*x^th)),initial = negexp.SSival, parameters = c("b0", "b1", "th"),
+ template = function(x, b0, b1, th) {})
> Disperse.ss <- nls(Retention ~ negexp(Area, b0, b1, th),data = cl, trace = T)
         b0          b1          th 
   4.208763  144.205455 1035.324595 
Error in qr.default(.swts * attr(rhs, "gradient")) : 
 NA/NaN/Inf (arg1) can not be called when the external function is called.
Error happened again. How can I fix it? I am desperate.
Maybe it is not suitable for asking these questions in here. I am new to R and I don’t know where to ask such questions. I saw someone asked about using non-linear model before, maybe I can find someone to help me here. Your help will be much appreciated.

Thanks!

Pinglei Gao

Ben Bolker

unread,
Oct 8, 2016, 12:52:09 PM10/8/16
to gaopinglei, ggplot2
You're right, this isn't an appropriate forum. You can ask your
question on the r help list (r-h...@r-project.org) or on Stack
Overflow, but do take some time to search the previous questions asked
in those forums, and review the overview/"how to ask a good question"
information ...

cheers
Ben Bolker
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

gaopinglei

unread,
Oct 8, 2016, 10:23:13 PM10/8/16
to ggplot2
Ok, thanks for your help. 

Pinglei Gao

在 2016年10月8日星期六 UTC+8下午9:24:14,gaopinglei写道:
Reply all
Reply to author
Forward
0 new messages