Hi There, Just a question regarding the function that is specified to boot (I have read the help, the manual and online examples.........). The description of boot says that the second argument of "statistic" (non parametric bootstrap) must be a vector of indices, frequencies or weights which define the bootstrap sample. If what I will be bootstrapping is e.g., the mean of a vector of length N and I want each observation in the vector to be given equal weight, should the second argument be a vector containing "N" 1's? Thanks beforehand for your help. Best, A -- View this message in context: http://r.789695.n4.nabble.com/statistic-term-in-boot-function-tp2550629p2550629.html Sent from the R help mailing list archive at Nabble.com.
Hi Alfredo, Short answer is no. As en example, consider the following: # example require(boot) x <- c(4, 4, 4, 3, 2, 4, 4, 3, 6, 2) res <- boot(x, function(v, index) mean(v[index]), R = 1000) res str(res) More information can be found under ?boot (after loaging the boot package) as well as in [1] and [2]. Best, Jorge [1] http://www.ats.ucla.edu/stat/r/library/bootstrap.htm [2] http://www.statmethods.net/advstats/bootstrapping.html * * On Wed, Sep 22, 2010 at 12:24 PM, alfredo <> wrote:> > Hi There, > > Just a question regarding the function that is specified to boot (I have > read the help, the manual and online examples.........). The description of > boot says that the second argument of "statistic" (non parametric > bootstrap) > must be a vector of indices, frequencies or weights which define the > bootstrap sample. If what I will be bootstrapping is e.g., the mean of a > vector of length N and I want each observation in the vector to be given > equal weight, should the second argument be a vector containing "N" 1's? > > Thanks beforehand for your help. > > Best, > > A > -- > View this message in context: > http://r.789695.n4.nabble.com/statistic-term-in-boot-function-tp2550629p2550629.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On Sep 22, 2010, at 12:24 PM, alfredo wrote:> > Hi There, > > Just a question regarding the function that is specified to boot (I > have > read the help, the manual and online examples.........). The > description of > boot says that the second argument of "statistic" (non parametric > bootstrap) > must be a vector of indices, frequencies or weights which define the > bootstrap sample. If what I will be bootstrapping is e.g., the mean > of a > vector of length N and I want each observation in the vector to be > given > equal weight, should the second argument be a vector containing "N" > 1's?In the simple case (sample of size N done with replacement) the vector will be indices, N in number, and a table operation on that set of indices lined up against the original 1:N will show some 0 counts, mostly 1's, a few 2's and progressively fewer 3's, 4's, etc. You do not need to construct that vector. That is the task for which boot was constructed. The ran.gen function is given that responsibility. Your responsibility is to create a function that can accept data and the vector of indices. You can get a "look" at the process by instead tabulating the indices from the $t value on one replication. # The normal call. > table(boot(1:100, function(x,i){mean(x[i])}, R=1)$t) # just one value per replication 49.82 1 #The non-statistical illustration: > table(boot(1:100, function(x,i){I(i)}, R=1)$t) 1 3 4 5 7 8 9 10 11 12 13 14 15 16 20 22 23 25 26 28 32 33 3 1 1 3 2 2 1 1 1 2 1 1 3 1 3 2 1 3 1 2 1 2 35 39 40 41 42 45 49 50 51 52 53 54 55 56 57 58 59 60 62 63 64 65 1 3 1 1 2 2 2 1 1 1 1 1 2 1 1 2 1 1 1 2 1 1 68 70 71 72 73 77 79 80 81 82 83 86 87 89 92 94 95 96 97 98 99 100 1 1 2 1 2 1 2 1 2 1 1 2 2 3 1 2 1 1 1 1 2 1 -- David.> > Thanks beforehand for your help. > > Best, > > A > -- > View this message in context: http://r.789695.n4.nabble.com/statistic-term-in-boot-function-tp2550629p2550629.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.