Adam Carr
2010-Jan-06 13:25 UTC
[R] Boot() Package Question: Multiple Confidence Interval Output
Good Morning: I posted an initial question a few days ago and I received some good advice from two R experts. I have re-examined the Davison-Hinkley text paying close attention to the examples of the boot() and boot.ci() in that text and the single example of a similar process in the MASS book (not the MASS package manual as I initially misunderstood). I think I understand how the stratified sampling works and how the index plays a role in the boot() object created prior to running the boot.ci() function. The example in Davison-Hinkley on page 528 and continued on page 536 also uses an interesting additional argument to select subsamples from the data set for input to the boot() and boot.ci() functions. I admit I may be missing the connection between these examples and what I am trying to accomplish so I apologize for the disconnect. Here is example code from Kerby Shedden at the University of Michigan that generates multiple bootstrapped confidence intervals from a normal data set and then examines the multiple confidence intervals to determine how many contain the characteristic calculated from the source data set: ## Sample sizes. N = c(10,20,40,60) nrep = 1000 ## Number of simulation replications per sample size value. nboot = 1000 ## The number of bootstrap data sets. ## Coverage probabilities. CP = NULL for (j in 1:length(N)) { ## Keep track of how many times the interval covers the true value. nc = 0 n = N[j] for (k in 1:nrep) { ## Simulate a data set. X = rnorm(n) ## Generate bootstrap data sets from X. ii = ceiling(n*runif(n*nboot)) B = X[ii] B = array(B, c(nboot,n)) ## Get the sample mean for each bootstrap data set. M = apply(B, 1, mean) M = sort(M) ## Get the confidence interval lower and upper bound. C = c(M[25], M[975]) ## Check for coverage. if ( (C[1] < 0) & (C[2] > 0) ) { nc = nc+1 } } CP[j] = nc/nrep Viewing CP provides four ratios representing the percentage of confidence intervals that contain the value of interest. What I cannot determine how to do with boot() and boot.ci() is this: 1. Generate multiple bootstrap samples of univariate data using boot(). For example, five distinct sets of five hundred bootstrapped means. 2. Calculate one confidence interval for each distinct set of bootstrapped means using boot.ci(). If I restricted the type= to "norm" and "basic" the output would be five sets of norm and basic upper and lower confidence bounds based on the five bootstrapped data sets generated by boot(). I am running R version 2.9.2 on an IBM T61 laptop. My OS is Win XP professional SP 3, and the machine has a 1.99 GHz processor with 2.99 GB of RAM. The version of the boot() package I am running is 1.2-41. I wish I had better programming intuition because I realize that the path to obtain this kind of analysis may be obvious to many of you. I do very much appreciate any help I receive. Thanks again, Adam [[alternative HTML version deleted]]