Learn R Programming

CarletonStats (version 2.0)

bootCor: Bootstrap the correlation

Description

Bootstrap the correlation of two numeric variables.

Usage

bootCor(x, ...)

# S3 method for default bootCor(x, y, conf.level = 0.95, B = 10000, plot.hist = TRUE, hist.title = NULL, plot.qq = FALSE, legend.loc = "topright", x.name = deparse(substitute(x)), y.name = deparse(substitute(y)), ...)

# S3 method for formula bootCor(formula, data, subset, ...)

Value

The command invisibly returns the correlations of the resampled observations.

Arguments

x

a numeric vector.

...

further arguments to be passed to or from methods.

y

a numeric vector.

conf.level

confidence level for the bootstrap ercentile interval.

B

number of times to resample (positive integer greater than 2).

plot.hist

a logical value. If TRUE, plot the bootstrap distribution of the resampled correlation.

hist.title

a user supplied title for the histogram.

plot.qq

a logical value. If TRUE a normal quantile-quantile plot of the bootstraped values is created.

legend.loc

location to place the legend. Options include "topright", "topleft", "bottomright", "bottomleft".

x.name

Label for variable x

y.name

Label for variable y

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.

data

an optional data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

Methods (by class)

  • default: Bootstrap the correlation of two numeric variables.

  • formula: Bootstrap the correlation of two numeric variables.

Author

Laura Chihara

Details

Bootstrap the correlation of two numeric variables. The bootstrap mean and standard error are printed as well as a bootstrap percentile confidence interval.

Observations with missing values are removed.

References

Tim Hesterberg's website http://www.timhesterberg.net/bootstrap

Examples

Run this code


plot(states03$ColGrad, states03$InfMortality)
bootCor(InfMortality ~ ColGrad, data = states03)
bootCor(states03$ColGrad, states03$InfMortality)

Run the code above in your browser using DataLab