Skip to content

Automatic transformation helper

Source: R/autoTransform.R · Help: ?autoTransform

Chooses between no transformation, log, square root and Box–Cox based on the Breusch-Pagan test statistic.

Usage

autoTransform(model)

Arguments

model
A fitted model of class lm.

Value

A list with elements model (the transformed fit) and method indicating the chosen transformation.

Details

Since 0.18.0 it leaves out a candidate fit whose auxiliary regression the design forces to fit the squared residuals exactly, which performBPTest() refuses (see its Exact fit), and stops with that refusal when every candidate is refused, as on a factor with two observations per level; it chose between them by a statistic of the spread of their squared residuals alone. A candidate drops the rows where its response is not finite, so its design can differ from the others'.

Examples

data(mtcars)
m <- lm(mpg ~ wt + qsec, data = mtcars)
autoTransform(m)