[R] BIG difficulties in Using boot.ci (bot package)

Daniel Nordlund djnordlund at frontier.com
Mon Apr 13 19:26:36 CEST 2015


On 4/13/2015 9:06 AM, varin sacha wrote:
> Hi Michael,
>
> Thanks for your response. About the data frame not necessary. I correct the code according to your comments. I still get the following warnings :
> [1] "All values of t are equal to  5.75620151906917 \n Cannot calculate confidence intervals"
> NULL
>
> I have found this on the Net :
> "Note that boot.ci just gives a warning and returns NA values, if all values are equal. There is no error and if you can work with NAs, there is no need for the if condition.
> The boot package assumes that the bootstrap
> statistic has all ways the same dimension.
> Whenever you have a statistic with less dimensions you get an NA
> or 0 or whatever you want".
>
> The reproducible code :
>
> GDP.LOG <-c(14,12,13,15.5,16,17,16.5,13.5,12.5,12)
> Quality.score <-c(12,11,13,14,15,16,12,10,9,9)
> Competitivness.score=c(8,6,7,5,6.5,7,8,4.5,6,7)
> fit <- lm(formula = GDP.LOG ~ Quality.score + Competitivness.score)
> install.packages("boot")
> library(boot)
> bs=function(formula,data,indices){
> d=data[indices,]
> fit=lm(formula,data=d)
> (coef(fit))
> }
> results=boot(data=Dataset,statistic=bs, R=2000,formula= GDP.LOG ~ Quality.score + Competitivness.score)
> boot.ci(results,type="bca",index=1)
> boot.ci(results,type="bca",index=2)
> boot.ci(results,type="bca",index=3)
>
> How is it possible to avoid that warning ?
>
> Best,
> S
>
>
>

The first problem is that this is not reproducible code.  This is what I 
get when I run your code on my computer:

> GDP.LOG <-c(14,12,13,15.5,16,17,16.5,13.5,12.5,12)
> Quality.score <-c(12,11,13,14,15,16,12,10,9,9)
> Competitivness.score=c(8,6,7,5,6.5,7,8,4.5,6,7)
> fit <- lm(formula = GDP.LOG ~ Quality.score + Competitivness.score)
> #####install.packages("boot")
> library(boot)
> bs=function(formula,data,indices){
+ d=data[indices,]
+ fit=lm(formula,data=d)
+ (coef(fit))
+ }
> results=boot(data=Dataset,statistic=bs, R=2000,formula= GDP.LOG ~ Quality.score + Competitivness.score)
Error in NROW(data) : object 'Dataset' not found
> boot.ci(results,type="bca",index=1)
Error in boot.ci(results, type = "bca", index = 1) :
   object 'results' not found
> boot.ci(results,type="bca",index=2)
Error in boot.ci(results, type = "bca", index = 2) :
   object 'results' not found
> boot.ci(results,type="bca",index=3)
Error in boot.ci(results, type = "bca", index = 3) :
   object 'results' not found
>


A reproducible example means that when I run your code on my machine, I 
get the same results / warnings / errors that you get.  I got something 
different.


Dan

-- 
Daniel Nordlund
Bothell, WA USA



More information about the R-help mailing list