transChooser {NCStats}R Documentation

A dynamic graphic used to select transformations for simple linear models.


A dynamic graphic used to select a response transformation for an ANOVA (one- or two-way) model or a response or explanatory transformation for a simple linear (SLR) or indicator variable regression (IVR) model. The function produces a histogram of residuals and a residual plot, optionally with assumption checking method p-values, that are linked to slider bars that allow the user to choose different values of lambda (the power in a power transformation). This allows the user to dynamically select a power transformation that is likely to produce a model that meets the model assumptions.


transChooser(object, shifty = 0, shiftx = 0, show.stats = FALSE,
  boxplot = FALSE, alpha = 0.05, col.hist = "gray90")



An lm object or formula depicting a one-way or two-way ANOVA model or a simple linear or indicator variable regression model.


A numeric shift value for the transformation of the response variable (see details).


A numeric shift value for the transformation of the explanatory variable (see details).


A logical indicating if the assumption test p-values should (=TRUE (default)) be printed on the graphics (see details).


A logical indicating if the residual plot should be constructed as a boxplot (=TRUE; default) or as a traditional residual plot (=FALSE). Only effective if a one- or two-way ANOVA model is being examined.


A numeric used to decide the significance cutoff when choosing the color to print the assumption test p-values. Only has an effect if show.stats=TRUE.


A string used to depict the color of bars in the histogram.


Other arguments to the generic function.


This function only works for one- and two-way ANOVAs and simple and indicator variable regressions. The indicator variable regression must be either one- or two-way. More complicated models can not be considered with transChooser.

Each graphic consists of a histogram of raw residuals on the left and a residual plot on the right (constructed with residPlot from the FSA package). P-values from assumption tests will be shown if a check box is selected when using RStudio or if show.stats=TRUE when not using RStduio. The p-value from the Anderson-Darling normality test (as constructed with adTest) will be shown above the histogram. If an ANOVA model is being explored then the p-value from the the outlier test (as constructed with outlierTest in the car package) will be shown above the histogram. If a regression model is being explored then the outlier test results will be shown above the residual plot. If an ANOVA model is being explored then the p-value from a Levene's Test of equality of variances (as constructed from LeveneTest in the car package) will be shown above the residual plot.

If boxplot=TRUE then the residual plot for the ANOVA models will be a boxplot of residuals for each group rather than a scatterplot of residuals versus group. This function does not apply to exploration of regression models.

The shifty and shiftx arguments are used to provide a constant value to shift the variable being transformed either left (negative value) or right (positive value) along the respective axis. These values are useful if the original data contains negative numbers as the power transformations generally require non-negative values. Note that shiftx is only used if a regression (SLR or IVR) model is being considered.


None. However, a dynamic graphic is produced.


This function is designed to allow ‘newbie’ students a method that can be used to interactively choose appropriate transformations for the response or explanatory variables in one-way ANOVA, two-way ANOVA, simple linear regression, and indicator variable regressions. This function allows students to choose possible transformations based on an intuitive analysis of diagnostic plots, in contrast, to depending on a non-intuitive method such as the Box-Cox method. While this function can be used for research purposes that was not its intent and that is why it is limited to use with only these four simple models.

See Also

leveneTest, outlierTest, and ncvTest in car; adTest; and boxcox in MASS.


## Not run: 
if (require(FSA)) {
Mirex$year <- factor(Mirex$year)

## example with one-way ANOVA
lm1 <- lm(mirex~year,data=Mirex)

## example with two-way ANOVA
lm2 <- lm(mirex~species*year,data=Mirex)

## example with SLR
lm3 <- lm(mirex~weight,data=Mirex)

## example with IVR
lm4 <- lm(mirex~weight*year,data=Mirex)

## example with IVR (explanatory variables reversed)
lm4 <- lm(mirex~year*weight,data=Mirex)

## End(Not run)

[Package NCStats version 0.4.7 Index]