Skip to content

Streaming Koenker studentized Breusch\–Pagan test

Source: R/performance.R · Help: ?performKoenkerTestStreaming

Evaluates Koenker's studentized variant of the Breusch\–Pagan test (the \(n R^2\) statistic from regressing the squared residuals on the regressors) using streamed cross-products so that large datasets can be processed without allocating the full auxiliary regression matrix.

Usage

performKoenkerTestStreaming(
  model,
  data = NULL,
  chunk_size = 10000,
  progress = interactive()
)

Arguments

model
A fitted stats::lm object supplying residuals and fitted values for the diagnostic.
data
A base::data.frame containing the variables referenced in model. The data must align with the observations used to fit the model. When NULL, the default, the model frame of model is used. It holds the terms of the model rather than its variables (log(x) rather than x), so a model that transforms a variable needs data, as does a model with an offset() term, and so may a fit whose weights or offset argument is a column of the data, which the model frame holds as (weights) or (offset).
chunk_size
Positive integer giving the number of observations processed per streaming chunk.
progress
Logical flag indicating whether a textual progress bar should be shown while processing the chunks. Defaults to interactive().

Value

A htest object equivalent to performKoenkerTest with metadata recording the streaming configuration.

Details

Chunks of the data contribute to the cross-product matrices for the regression of squared residuals on the model regressors. Aggregating these matrices yields the exact Koenker statistic while bounding memory usage. Sparse cross-products from Matrix are used automatically when available for large chunks.

See also

performKoenkerTest for the standard implementation.

Examples

data(mtcars)
mod <- lm(mpg ~ wt + qsec, data = mtcars)
performKoenkerTestStreaming(mod, mtcars, chunk_size = 16, progress = FALSE)