Plot Results of Box-Cox Transformations Based on Type I Censored Data
Source:R/plot.boxcoxCensored.R
plot.boxcoxCensored.RdPlot the results of calling the function boxcoxCensored,
which returns an object of class "boxcoxCensored". Three different kinds of plots are available.
The function plot.boxcoxCensored is automatically called by plot
when given an object of class "boxcoxCensored".
Usage
# S3 method for class 'boxcoxCensored'
plot(x, plot.type = "Objective vs. lambda", same.window = TRUE,
ask = same.window & plot.type != "Ojective vs. lambda",
prob.method = "michael-schucany", plot.pos.con = 0.375,
estimate.params = FALSE, equal.axes = qq.line.type == "0-1" || estimate.params,
add.line = TRUE, qq.line.type = "least squares",
duplicate.points.method = "standard", points.col = 1, line.col = 1,
line.lwd = par("cex"), line.lty = 1, digits = .Options$digits,
cex.main = 1.4 * par("cex"), cex.sub = par("cex"),
main = NULL, sub = NULL, xlab = NULL, ylab = NULL, xlim = NULL,
ylim = NULL, ...)Arguments
- x
an object of class
"boxcoxCensored". SeeboxcoxCensored.objectfor details.- plot.type
character string indicating what kind of plot to create. Only one particular plot type will be created, unless
plot.type="All", in which case all plots will be created sequentially. The possible values ofplot.typeare:"Objective vs. lambda"(the default),"Q-Q Plots","Tukey M-D Q-Q Plots", and"All".- same.window
logical scalar indicating whether to produce all plots in the same graphics window (
same.window=TRUE; the default), or to create a new graphics window for each separate plot (same.window=FALSE). The argument is relevant only whenplot.typeproduces more than one plot (i.e., whenplot.typeis not equal to"Objective vs. lambda").- ask
logical scalar supplied to the function
devAskNewPage, indicating whether to prompt the user before creating a new plot within a single graphics window. This argument is ignored whenplot.type="Objective vs. lambda"(since only one plot is produced) or whensame.window=FALSE, otherwise the default value isask=TRUE.- points.col
numeric scalar determining the color of the points in the plot. The default value is
points.col=1. See the entry forcolin the R help file forparfor more information.
The following arguments can be supplied when plot.type="Q-Q Plots", plot.type="Tukey M-D Q-Q Plots", or plot.type="All"
(supplied to qqPlot):
- prob.method
character string indicating what method to use to compute the plotting positions for Q-Q plots or Tukey Mean-Difference Q-Q plots. Possible values are
"kaplan-meier"(product-limit method of Kaplan and Meier (1958)),"nelson"(hazard plotting method of Nelson (1972)),"michael-schucany"(generalization of the product-limit method due to Michael and Schucany (1986)), and"hirsch-stedinger"(generalization of the product-limit method due to Hirsch and Stedinger (1987)). The default value isprob.method="michael-schucany".The
"nelson"method is only available for objects that are the result of callingboxcoxCensoredwith the argumentcensoring.side="right". See the help file forqqPlotCensoredfor more information.This argument is ignored if
plot.type="Objective vs. lambda".- plot.pos.con
numeric scalar between 0 and 1 containing the value of the plotting position constant used to construct the Q-Q plots and/or Tukey Mean-Difference Q-Q plots. The default value is
plot.pos.con=0.375. See the help file forqqPlotCensoredfor more information.- estimate.params
logical scalar indicating whether to compute quantiles based on estimating the distribution parameters (
estimate.params=TRUE) or using the distribution parameters for a standard normal distribution (i.e,mean=0,sd=1). The default value isestimate.params=FALSEbecause a standard normal Q-Q plot will yield roughly a straight line if the observations are from any normal distribution. If you specifyplot.type="Tukey M-D Q-Q Plots", then you need to setestiamte.params=TRUEunless you want to assume the transformed data come from a standard normal distribution.- equal.axes
logical scalar indicating whether to use the same range on the \(x\)- and \(y\)-axes when
plot.type="Q-Q Plots". The default value isTRUEifqq.line.type="0-1"orestimate.params=TRUE, otherwise it isFALSE.- add.line
logical scalar indicating whether to add a line to the plot. If
add.line=TRUEandplot.type="Q-Q Plots", a line determined by the value ofqq.line.typeis added to the plot. Ifadd.line=TRUEandplot.type="Tukey M-D Q-Q Plots", a horizontal line at \(y=0\) is added to the plot. The default value isadd.line=TRUE.- qq.line.type
character string determining what kind of line to add to the plot when
plot.type="Q-Q Plots". Possible values are"least squares"(a least squares line; the default),"0-1"(a line with intercept 0 and slope 1), and"robust"(a line is fit through the first and third quartiles of the \(x\) and \(y\) data). This argument is ignored ifadd.line=FALSE.- duplicate.points.method
a character string denoting how to plot points with duplicate \((x,y)\) values. Possible values are
"standard"(a single plotting symbol is plotted; the default),"jitter"(a separate plotting symbol is plotted for each duplicate point, where the plotting symbols cluster around the true value of \(x\) and \(y\)), and"number"(a single number is plotted at \((x,y)\) that represents how many duplicate points are at that \((x,y)\) coordinate).- line.col
numeric scalar determining the color of the line in the plot. The default value is
line.col=1. See the entry forcolin the R help file forparfor more information. This argument is ignored ifadd.line=FALSE.- line.lwd
numeric scalar determining the width of the line in the plot. The default value is
line.lwd=par("cex"). See the entry forlwdin the R help file forparfor more information. This argument is ignored ifadd.line=FALSE.- line.lty
numeric scalar determining the line type (style) of the line in the plot. The default value is
line.lty=1. See the entry forltyin the R help file forparfor more information. This argument is ignored ifadd.line=FALSE.- digits
scalar indicating how many significant digits to print for the distribution parameters and the value of the objective in the sub-title. The default value is the current setting of
options("digits").
Graphics parameters:
- cex.main, cex.sub, main, sub, xlab, ylab, xlim, ylim, ...
graphics parameters; see
parfor more information. The default value ofcex.mainiscex.main=1.4 * par("cex"). The default value ofcex.subiscex.sub=par("cex").
Details
The function plot.boxcoxCensored is a method for the generic function
plot for the class "boxcoxCensored" (see boxcoxCensored.object).
It can be invoked by calling plot and giving it an object of
class "boxcoxCensored" as the first argument, or by calling
plot.boxcoxCensored directly, regardless of the class of the object given
as the first argument to plot.boxcoxCensored.
Plots associated with Box-Cox transformations are produced on the current graphics device. These can be one or all of the following:
Objective vs. \(\lambda\).
Observed Quantiles vs. Normal Quantiles (Q-Q Plot) for the transformed observations for each of the values of \(\lambda\).
Tukey Mean-Difference Q-Q Plots for the transformed observations for each of the values of \(\lambda\).
See the help files for boxcoxCensored and qqPlotCensored
for more information.
References
Chambers, J. M. and Hastie, T. J. (1992). Statistical Models in S. Wadsworth & Brooks/Cole.
Author
Steven P. Millard (EnvStats@ProbStatInfo.com)
Examples
# Generate 15 observations from a lognormal distribution with
# mean=10 and cv=2 and censor the observations less than 2.
# Then generate 15 more observations from this distribution and
# censor the observations less than 4.
# Then call the function boxcoxCensored, and then plot the results.
# (Note: the call to set.seed simply allows you to reproduce this example.)
set.seed(250)
x.1 <- rlnormAlt(15, mean = 10, cv = 2)
censored.1 <- x.1 < 2
x.1[censored.1] <- 2
x.2 <- rlnormAlt(15, mean = 10, cv = 2)
censored.2 <- x.2 < 4
x.2[censored.2] <- 4
x <- c(x.1, x.2)
censored <- c(censored.1, censored.2)
# Plot the results based on the PPCC objective
#---------------------------------------------
boxcox.list <- boxcoxCensored(x, censored)
if (interactive()) dev.new()
plot(boxcox.list)
# Look at Q-Q Plots for the candidate values of lambda
#-----------------------------------------------------
plot(boxcox.list, plot.type = "Q-Q Plots", same.window = !interactive(), ask = FALSE)
# Look at Tukey Mean-Difference Q-Q Plots
# for the candidate values of lambda
#----------------------------------------
plot(boxcox.list, plot.type = "Tukey M-D Q-Q Plots", same.window = !interactive(), ask = FALSE)
#==========
# Clean up
#---------
rm(x.1, censored.1, x.2, censored.2, x, censored, boxcox.list)
graphics.off()