EnvStats (version 2.4.0)

# boxcox.object: S3 Class "boxcox"

## Description

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.

## Value

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

lambda

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.

objective

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

objective.name

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).

optimize

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).

optimize.bounds

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.

eps

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.

sample.size

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

data.name

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.

data

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

## Methods

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

## Details

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.

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

## Examples

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

set.seed(250)
x <- rlnormAlt(30, mean = 10, cv = 2)

dev.new()
hist(x, col = "cyan")

boxcox.list <- boxcox(x)

data.class(boxcox.list)
#[1] "boxcox"

names(boxcox.list)
# [1] "lambda"          "objective"       "objective.name"
# [4] "optimize"        "optimize.bounds" "eps"
# [7] "data"            "sample.size"     "data.name"

boxcox.list
#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)
# }


Run the code above in your browser using DataCamp Workspace