nullabor (version 0.3.1)

null_lm: Generate null data with null residuals from a model.

Description

Null hypothesis: variable is linear combination of predictors

Usage

null_lm(f, method = "rotate", ...)

Arguments

f

model specification formula, as defined by lm

method

method for generating null residuals. Built in methods 'rotate', 'pboot' and 'boot' are defined by resid_rotate, resid_pboot and resid_boot respectively

...

other arguments passedd onto method.

Value

a function that given data generates a null data set. For use with lineup or rorschach

Examples

Run this code
# NOT RUN {
if (requireNamespace('reshape2', quietly = TRUE)) {
data("tips", package = "reshape2")
x <- lm(tip ~ total_bill, data = tips)
tips.reg <- data.frame(tips, .resid = residuals(x), .fitted = fitted(x))
qplot(total_bill, .resid, data = tips.reg) %+%
  lineup(null_lm(tip ~ total_bill, method = 'rotate'), tips.reg) +
  facet_wrap(~ .sample)
}
# }

Run the code above in your browser using DataLab