0

I am trying to bootstrap the standard errors of the parameter estimates in a glm, and I'm having a little trouble with the bootstrap step. I have defined my function as follows...

boot.fn=function(data,index){
          return(eval(substitute(coef(glm(glm.formula,
                      family = tweedie(var.power=1.5,link.power=0),
                      data=data,
                      subset=index,
                      weights=EXPOSURE_COLL
                      )))))  
}

...and this function runs without error on its own. However, when I run the bootstrap...

set.seed(1977)
boot(coll.train,boot.fn,1000)

...I get the following error message:

Error in eval(expr, envir, enclos) : object 'original' not found 

Any help anyone can provide is greatly appreciated!

www
  • 38,575
  • 12
  • 48
  • 84
user42719
  • 41
  • 1
  • 3
  • You need to pass the formula in the boot function, and yu could also make life easy and pass the index to subset the data using `[`. You also dont need the `eval(substitute(` in this setting. So the function is `boot.fn <- function(data, index, glm.formula){ coef(glm(glm.formula, family = tweedie(var.power=1.5,link.power=0), data=data[index,] )) }` and call it with `boot(coll.train, boot.fn, 1000, glm.formula=yourFormula)` – user20650 Feb 09 '16 at 21:21
  • Also please have a wee read of http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-exampleIt is really helpful if you can provide an example that people can paste into their R session, and also provide all library calls. Cheers – user20650 Feb 09 '16 at 21:22

0 Answers0