bootResids: Residual boostrap for linear regression coefficients

Description Usage Arguments Details Value Author(s) References Examples

View source: R/bootResids.R

Description

Residual boostrap for linear regression coefficients (Description)

Usage

1
bootResids(formula, data, lmodObs, B)

Arguments

formula

A string that can be coerced into class 'formula'. Usually of the form response variable \sim predictor variables.A symbolic description of the model to be fitted.

data

data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model.

lmodObs

The observed linear model estimated by least squares. A fitted model object of class inheriting from 'lm'.

B

The number of bootstrap replicates. Usually this will be a single positive integer.

Details

This function simulates the sampling distribution of simple linear regression coefficients by first simulating the distribution of the errors (\mathbf{ε}) by the empirical distribution function of the residuals (i.e. resampling residuals with replacement).

Value

A B x (k+1) data frame containing B samples from the distributions of each of the (k+1) model parameters, where k is the number of predictors in the model.

Author(s)

Natalie DelRocco

References

Davison, A.C. and Hinkley, D.V. (1997) Bootstrap Methods and Their Application. Cambridge University Press.

Examples

1
2
3
4
5
library(faraway)
data(prostate)
lmod <- lm(lpsa ~ lcavol + age + lweight, prostate)
bootsamps <- bootResids(formula='lpsa ~ lcavol + age + lweight', data=prostate,
                        lmodObs=lmod, B=1000)

ndelrocco/lmBootCompare documentation built on Dec. 10, 2019, 12:38 p.m.