boxcox.object: S3 Class "boxcox"

boxcox.objectR Documentation

S3 Class "boxcox"


Objects of S3 class "boxcox" are returned by the EnvStats function boxcox, which computes objective values for user-specified powers, or computes the optimal power for the specified objective.


Objects of class "boxcox" are lists that contain information about the powers that were used, the objective that was used, the values of the objective for the given powers, and whether an optimization was specified.


Required Components
The following components must be included in a legitimate list of class "boxcox".


Numeric vector containing the powers used in the Box-Cox transformations. If the value of the optimize component is FALSE, then lambda contains the values of all of the powers at which the objective was evaluated. If the value of the optimize component is TRUE, then lambda is a scalar containing the value of the power that maximizes the objective.


Numeric vector containing the value(s) of the objective for the given value(s) of \lambda that are stored in the component lambda.

character string indicating the objective that was used. The possible values are "PPCC" (probability plot correlation coefficient; the default), "Shapiro-Wilk" (the Shapiro-Wilk goodness-of-fit statistic), and "Log-Likelihood" (the log-likelihood function).


logical scalar indicating whether the objective was simply evaluted at the given values of lambda (optimize=FALSE), or instead the optimal power transformation was computed within the bounds specified by lambda (optimize=TRUE).


Numeric vector of length 2 with a names attribute indicating the bounds within which the optimization took place. When optimize=FALSE, this contains missing values.


finite, positive numeric scalar indicating what value of eps was used. When the absolute value of lambda is less than eps, lambda is assumed to be 0 for the Box-Cox transformation.


Numeric scalar indicating the number of finite, non-missing observations.

The name of the data object used for the Box-Cox computations.


The number of missing (NA), undefined (NaN) and/or infinite (Inf, -Inf) values that were removed from the data object prior to performing the Box-Cox computations.

Optional Component
The following component may optionally be included in a legitimate list of class "boxcox". It must be included if you want to call the function plot.boxcox and specify Q-Q plots or Tukey Mean-Difference Q-Q plots.


Numeric vector containing the data actually used for the Box-Cox computations (i.e., the original data without any missing or infinite values).


Generic functions that have methods for objects of class "boxcox" include:
plot, print.


Since objects of class "boxcox" are lists, you may extract their components with the $ and [[ operators.


Steven P. Millard (

See Also

boxcox, plot.boxcox, print.boxcox, boxcoxLm.object.


  # Create an object of class "boxcox", then print it out.
  # (Note: the call to set.seed simply allows you to reproduce this example.)

  x <- rlnormAlt(30, mean = 10, cv = 2)
  hist(x, col = "cyan")

  boxcox.list <- boxcox(x)

  #[1] "boxcox"
  # [1] "lambda"          "objective"       "" 
  # [4] "optimize"        "optimize.bounds" "eps"            
  # [7] "data"            "sample.size"     ""      
  #[10] "bad.obs" 

  #Results of Box-Cox Transformation
  #Objective Name:                  PPCC
  #Data:                            x
  #Sample Size:                     30
  # lambda      PPCC
  #   -2.0 0.5423739
  #   -1.5 0.6402782
  #   -1.0 0.7818160
  #   -0.5 0.9272219
  #    0.0 0.9921702
  #    0.5 0.9581178
  #    1.0 0.8749611
  #    1.5 0.7827009
  #    2.0 0.7004547

  boxcox(x, optimize = TRUE) 
  #Results of Box-Cox Transformation
  #Objective Name:                  PPCC
  #Data:                            x
  #Sample Size:                     30
  #Bounds for Optimization:         lower = -2
  #                                 upper =  2
  #Optimal Value:                   lambda = 0.04530789
  #Value of Objective:              PPCC = 0.9925919 


  # Clean up
  rm(x, boxcox.list)

EnvStats documentation built on Aug. 22, 2023, 5:09 p.m.