[R] S.O.S "try" doesnot work in boot?

ctu at bigred.unl.edu ctu at bigred.unl.edu
Tue Sep 9 09:22:33 CEST 2008


First thanks for Jinsong's suggestions
I would like to do a bootstrap in a nonlinear model. But it fails to  
converge in most of time. (it did converge if I just use nls without  
boot). Thus, I use "try" function to resolve my problem. This  
following code is from Jinsong's suggestion.

h1a.nls<-nls(density~nmf(time, alpha, delta, psi, tau, gamma),data=h1a,
         start=c(alpha=0.3, delta=0.08869, psi=1.26523, tau=3.93919,    
    gamma=-1.41927))

h1a.data<-data.frame(h1a,res=resid(h1a.nls),fitted=fitted(h1a.nls))
h1a.fun<-function(data,i){
  d<-data
  d$density<-d$fitted+d$res[i]
  try(update(h1a.nls,data=d),silent=T)
  if(!inherits(h1a.nls,"try-error")) h1a.coef<-coef(h1a.nls)
  else h1a.coef<-NA
  h1a.coef
  }
h1a.boot<-boot(h1a.data, statistic = h1a.fun, R=1000)
> h1a.boot

ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot(data = h1a.data, statistic = h1a.fun, R = 1000)
Bootstrap Statistics :
        original  bias    std. error
t1*  0.27892590       0           0
t2*  0.08869433       0           0
t3*  1.26523275       0           0
t4*  3.93919567       0           0
t5* -1.41926966       0           0
all of the values of each column in h1a.boot$t are the same.
Is anyone know to how I can solve this problem?
Appreciate in advance

Chunhao



More information about the R-help mailing list