[R] Help use try function with boot

ctu at bigred.unl.edu ctu at bigred.unl.edu
Sat Sep 6 20:41:15 CEST 2008


Hi Jinsong,
I try to put the "try" in the c1.fun but it still does not work. Do  
you mean this?

> c1.fun<-try(function(data,i){
+  d<-data
+  d$density<-d$fitted+d$res[i]
+  coef(update(c1.nmf,data=d))
+  } ,silent=T)
> c1.try<-boot(c1data, statistic = c1.fun, R=5000)
Error in nls(formula = density ~ nmf(time, alpha, delta, psi, tau, gamma),  :
   Convergence failure: false convergence (8)

Thanks
Chunhao


Quoting Jinsong Zhao <jszhao at mail.hzau.edu.cn>:

> ctu at bigred.unl.edu wrote:
>> Hi R users,
>> Is is possible for me to use the try function with boot? I would to  
>>  do the bootstraping with a nonlinear model(it works well when R <   
>> 1000). But it does not work very well (when R is large) thus I try   
>> to use "try" to resolve. I  put the try function in two cases:
>>
>> case1: put the try in front of the boot
>>
>>> c1.try<-try(boot(c1data, statistic = c1.fun, R=3999),silent=T)
>>> c1.try
>> [1] "Error in nls(formula = density ~ nmf(time, alpha, delta, psi,   
>> tau, gamma),  : \n  Convergence failure: false convergence (8)\n"
>> attr(,"class")
>> [1] "try-error"
>>
>> case2: put the try in front of the nls
>> c1.nmf<-try(nls(density~nmf(time, alpha, delta, psi, tau, gamma),
>> +            algorithm="port",data=c1,
>> +            lower=c(alpha=0.1, delta=0, psi=0.2, tau=1, gamma=-5),
>> +            upper=c(alpha=0.6, delta=0.1, psi=3, tau=7, gamma=2),
>> +            start=c(alpha=0.35, delta=0,  psi=0.99, tau=4.5,   
>> gamma=-1.2)),silent=T)
>>> c1.try<-boot(c1data, statistic = c1.fun, R=3999)
>>  Error in nls(formula = density ~ nmf(time, alpha, delta, psi, tau,  
>>  gamma),  :
>>  Convergence failure: iteration limit reached without convergence
>>
>> Any suggestion will be helpful.
>> Many thanks in advance
>> Chunhao
>>
>
> put try() in your statistic function. in your case, it may be inside
> the c1.fun function.
>
> HTH,
> Jinsong



More information about the R-help mailing list