boxcoxLm.object  R Documentation 
Objects of S3 class "boxcoxLm"
are returned by the EnvStats
function boxcox
when the argument x
is an object
of class "lm"
. In this case, boxcox
computes
values of an objective function for userspecified powers, or computes the
optimal power for the specified objective, based on residuals from the linear model.
Objects of class "boxcoxLm"
are lists that contain
information about the "lm"
object that was suplied,
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.
The following components must be included in a legitimate list of
class "boxcoxLm"
.
lambda 
Numeric vector containing the powers used in the BoxCox transformations.
If the value of the 
objective 
Numeric vector containing the value(s) of the objective for the given value(s)
of 
objective.name 
character string indicating the objective that was used. The possible values are

optimize 
logical scalar indicating whether the objective was simply evaluted at the
given values of 
optimize.bounds 
Numeric vector of length 2 with a names attribute indicating the bounds within
which the optimization took place. When 
eps 
finite, positive numeric scalar indicating what value of 
lm.obj 
the value of the argument 
sample.size 
Numeric scalar indicating the number of finite, nonmissing observations. 
data.name 
The name of the data object used for the BoxCox computations. 
Generic functions that have methods for objects of class
"boxcoxLm"
include:
plot
, print
.
Since objects of class "boxcoxLm"
are lists, you may extract
their components with the $
and [[
operators.
Steven P. Millard (EnvStats@ProbStatInfo.com)
boxcox
, plot.boxcoxLm
, print.boxcoxLm
,
boxcox.object
.
# Create an object of class "boxcoxLm", then print it out.
# The data frame Environmental.df contains daily measurements of
# ozone concentration, wind speed, temperature, and solar radiation
# in New York City for 153 consecutive days between May 1 and
# September 30, 1973. In this example, we'll plot ozone vs.
# temperature and look at the QQ plot of the residuals. Then
# we'll look at possible BoxCox transformations. The "optimal" one
# based on the PPCC looks close to a logtransformation
# (i.e., lambda=0). The power that produces the largest PPCC is
# about 0.2, so a cube root (lambda=1/3) transformation might work too.
# Fit the model with the raw Ozone data
#
ozone.fit < lm(ozone ~ temperature, data = Environmental.df)
# Plot Ozone vs. Temperature, with fitted line
#
dev.new()
with(Environmental.df,
plot(temperature, ozone, xlab = "Temperature (degrees F)",
ylab = "Ozone (ppb)", main = "Ozone vs. Temperature"))
abline(ozone.fit)
# Look at the QQ Plot for the residuals
#
dev.new()
qqPlot(ozone.fit$residuals, add.line = TRUE)
# Look at BoxCox transformations of Ozone
#
boxcox.list < boxcox(ozone.fit)
boxcox.list
#Results of BoxCox Transformation
#
#
#Objective Name: PPCC
#
#Linear Model: ozone.fit
#
#Sample Size: 116
#
# lambda PPCC
# 2.0 0.4286781
# 1.5 0.4673544
# 1.0 0.5896132
# 0.5 0.8301458
# 0.0 0.9871519
# 0.5 0.9819825
# 1.0 0.9408694
# 1.5 0.8840770
# 2.0 0.8213675
#
# Clean up
#
rm(ozone.fit, boxcox.list)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.