Access the data values by the "boot" function

Asked

Viewed 145 times

3

I’m having a problem getting some values given by the function boot in R:

My data

dados<- c(16483.82, 16463.06, 15649.35, 15615.27, 20034.44, 16254.43, 16946.72)
meanFunc <- function(x,i){mean(x[i])}
 bootMean <-(boot(data=x,statistic=meanFunc,R=1000))

After this, I do > bootMean and the result is this:

ORDINARY NONPARAMETRIC BOOTSTRAP

Call:
boot(data = x, statistic = meanFunc, R = 1000)

Bootstrap Statistics :

    original        bias     std. error
t1* 16778.16  -0.9335903     540.371

I took some of these codes at this link

I tried to convert to a data frame but it didn’t work.

2 answers

1

I found a possible solution here, then if someone has the same problem a way to solve and this.

bias<- mean(bootMean$t) - bootMean$t0    
desviopadrao<- sd(bootMean$t)

original<-bootMean$t0
  • You can mark your answer as accepted in this case.

0

1) if you want to know the content of an object (and therefore the fields) the solution is to use the str

> str(bootMean)
List of 11
 $ t0       : num 16778
 $ t        : num [1:1000, 1] 16692 17501 16776 17648 16184 ...
 $ R        : num 1000
 $ data     : num [1:7] 16484 16463 15649 15615 20034 ...
 $ seed     : int [1:626] 403 1 235491040 177295907 312278337 450969648 1593694798 259661497 1711303371 -2124436614 ...
 $ statistic:function (x, i)  
  ..- attr(*, "srcref")=Class 'srcref'  atomic [1:8] 1 13 1 37 13 37 1 1
  .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment:0x102c7ce28> 
 $ sim      : chr "ordinary"
 $ call     : language boot(data = dados, statistic = meanFunc, R = 1000)
 $ stype    : chr "i"
 $ strata   : num [1:7] 1 1 1 1 1 1 1
 $ weights  : num [1:7] 0.143 0.143 0.143 0.143 0.143 ...
 - attr(*, "class")= chr "boot"

2) I use the boot together with the boot.ci to obtain the confidence interval (the tchans of a method such as bootstrap is not to obtain the media - which must be very similar to the media obtained with the mean, but the confidence interval).

But get the results of boot.ci is not direct need to read the manual value section http://www.rdocumentation.org/packages/boot/functions/boot.ci

> bci<-boot.ci(bootMean)
Warning message:
In boot.ci(bootMean) : bootstrap variances needed for studentized intervals
> bci$bca[4:5]
[1] 16074.65 18516.44

Browser other questions tagged

You are not signed in. Login or sign up in order to post.