Manoel Pacheco wrote:
>I wrote the following code to generate confidence intervals for bootstraps
>of ratios between two variables.
>
>BAFp <- rlnorm(100, meanlog=0, sdlog=1)
>BAFm <- rlnorm(100, meanlog=0, sdlog=1)
>BAFdat <- data.frame(BAFp, BAFm)
>
># Bootstraps the distribution of ratios between two group means
>ratios <- bootstrap(BAFdat, mean(BAFdat[,1])/mean(BAFdat[,2]))
>ratios.ci <- limits.tilt(ratios)
>
>plot(ratios)
>qqnorm(ratios)
>summary(ratios)
>
>The script ran ok, but the output of plot(ratios) was unexpected. It was a
>histogram of the frequency distribution of bootstrapped mean(BAFdat[,1])
>values.
Are you sure? Your variables have mean near 1, so it is hard to tell
at a glance the difference between the distribution of the first mean
and the distribution of the ratio.
You can check by
(1) extracting the indices that were used
(using resampGetIndices if using library(resample); I don't
remember how if you're using the old bootstrap code built into S+),
(2) compute the two means and ratio for the first bootstrap sample, and
(3) compare to ratios$replicates[1]
>How can I get a plot of the frequency distribution of bootstrapped
>ratios?
>
>As I am interested in examining changes in the confidence interval of
>bootstrapped ratios along a series of increasing sample sizes, I attempted
>to add a vector of block.sizes
>
>ratios <- bootstrap(BAFdat, mean(BAFdat[,1]) / mean(BAFdat[,2]),
> block.size = c(5, 10, 20, 40, 80))
The block sizes is for how many bootstrap samples to do at once.
You're looking for something different.
You need library(resample) (see bottom), then do e.g.
ratios <- bootstrap(BAFdat, mean(BAFdat[,1]) / mean(BAFdat[,2]),
sampler.args = list(size = 5))
>All I got was a huge error message. Do I have to create a loop for such
>analysis?
You will need a loop to handle the different sizes.
>
> Thanks,
> Manolo
>
>PS S+ Version 6.2, Windows 2000
You're welcome.
========================================================
| Tim Hesterberg Research Scientist |
| timh@insightful.com Insightful Corp. |
| (206)283-8691 1700 Westlake Ave. N, Suite 500 |
| (206)802-2500 (fax) Seattle, WA 98109-3044, U.S.A. |
| www.insightful.com/Hesterberg |
========================================================
Download the S+Resample library from www.insightful.com/downloads/libraries
|