<< Click to Display Table of Contents >>
## Bootstrapping |

This sample provides the code used in the resampling section, bootstrapping, for the estimation of the standard error of a ratio of mean values.

R Code

# ordinary bootstrap of the ratio of means using the city data

# load the required library

library(boot)

# define ratio as (optionally weighted) sum of city sizes

ratio <- function(d, w)

+ sum(d$x * w)/sum(d$u * w)

#

# specify the boot with 999 replicates

myratio<-boot(city, ratio, R=999, stype="w")

myratio

# display the mean computed from the boostrap procedure, and the histogram of boostrap results

mean(myratio$t)

hist(myratio$t)