Anders Bjorn
2009-Apr-03 11:10 UTC
[R] Trouble extracting graphic results from a bootstrap
Hi, I'm trying to extract a histogram over the results from a bootstrap. However I keep receiving the error message "Error in hist.default(boot.lrtest$ll, breaks = "scott") : 'x' must be numeric". The bootstrap I'm running looks like:> boot.test <- function(data, indeces, maxit=20) {+ y1 <- fit1+e1[indeces] + mod1 <- glm(y1 ~ X1-1, maxit=maxit) + y2 <- fit2+e2[indeces] + mod2 <- glm(y2~1, maxit=maxit) + ll <- 2*(logLik(mod1)-logLik(mod2)) + ll + }> boot.lrtest <- boot(data=M1, statistic=boot.test, R=2000, maxit=100);> hist(boot.lrtest$ll, breaks="scott") # This results in the error messagestated above So my question is: what am I doing wrong? //Anders [[alternative HTML version deleted]]
David Winsemius
2009-Apr-03 18:24 UTC
[R] Trouble extracting graphic results from a bootstrap
On Apr 3, 2009, at 7:10 AM, Anders Bjorn wrote:> Hi, > > I'm trying to extract a histogram over the results from a bootstrap. > However > I keep receiving the error message "Error in hist.default(boot.lrtest > $ll, > breaks = "scott") : 'x' must be numeric". > The bootstrap I'm running looks like: > >> boot.test <- function(data, indeces, maxit=20) { > + y1 <- fit1+e1[indeces] > + mod1 <- glm(y1 ~ X1-1, maxit=maxit) > + y2 <- fit2+e2[indeces] > + mod2 <- glm(y2~1, maxit=maxit) > + ll <- 2*(logLik(mod1)-logLik(mod2)) > + ll > + } >> boot.lrtest <- boot(data=M1, statistic=boot.test, R=2000, maxit=100); > >> hist(boot.lrtest$ll, breaks="scott") # This results in the error >> message > stated above > > So my question is: what am I doing wrong?At least two things, possibly 3 or 4: 1) not specifying from which package the function "boot" comes from, and .. 2) not offering a reproducible example. and possibly .. 3) assuming that boot.lrtest$ll will have any meaning, with the corollary.. 4) not looking at boot.lrtest$ll with the str function. Regarding 3), when I look at the documentation for boot in package boot, I see no component of the value returned from a boot call that has the name "ll". The name "ll" will be thrown away after the function call and you need to refer to components of the boot object by the names that the developers used. -- David Winsemius, MD Heritage Laboratories West Hartford, CT