Load the dataset.
Create a bootstrap object for 1000 resamples.
Calculate the correlation statistic for each sample.
library(UsingR)
library(boot)
# Load the dataset
data = father.son
# Create a boot object
boot_obj = boot(data, corr, R=1000)
# Plot the output of the bootstrap method
plot(boot_obj)
# Printing out the summary of the bootstrap object which contains standard error
print(boot_obj)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = data, statistic = corr, R = 1000)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 0.498953 0.002260723 0.01268245
Standard error = 0.0127
# Calculate 95% confidence limitis for teh bootstrap object
boot_obj_conf_int = boot.ci(boot_obj, conf = 0.95, type = 'norm')
print(boot_obj_conf_int)
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = boot_obj, conf = 0.95, type = "norm")
##
## Intervals :
## Level Normal
## 95% ( 0.4718, 0.5215 )
## Calculations and Intervals on Original Scale