bootstrap_residual_null: Compare nested linear models via (optionally wild) residual...

View source: R/bootstrap_lm_null.R

bootstrap_residual_nullR Documentation

Compare nested linear models via (optionally wild) residual bootstrap.

Description

This is the workhorse for the compare_models() function when a linear model is specified. Given two linear models, one nested within the other, the null distribution of the test statistic comparing the two models is estimated via a residual bootstrap (or wild bootstrap). This is not meant to be called by the user directly.

Usage

bootstrap_residual_null(fit1, fit0, reps, wild, construct)

Arguments

fit1

lm object defining the full model.

fit0

lm object defining the reduced model.

reps

scalar; number of bootstrap replications to perform.

wild

boolean; if TRUE, a wild bootstrap is performed. If FALSE a traditional residual bootstrap is performed.

construct

string defining the type of construct to use when generating from the distribution for the wild bootstrap (see rmammen). If wild = FALSE, this is ignored.

Value

vector of length reps containing the test statistic from each bootstrap replication. It also has an attribute containing an ANOVA table comparing the two models.

Examples

## Not run: 
fit1 <- lm(mpg ~ hp, data = mtcars)
fit0 <- lm(mpg ~ 1, data =  mtcars)

boot_residual_null(fit1, fit0, reps = 4999, wild = FALSE)

## End(Not run)


reyesem/IntroAnalysis documentation built on March 29, 2025, 3:29 p.m.