gofTest
, which returns an
object of class "gof"
when testing the goodness-of-fit of a set of data
to a distribution (i.e., when supplied with the y
argument but not
the x
argument). Five different kinds of plots are available. The function plot.gof
is automatically called by plot
when given an object of class "gof"
. The names of other functions
associated with goodness-of-fit test are listed under Goodness-of-Fit Tests.
"plot"(x, plot.type = "Summary", captions = list(PDFs = NULL, CDFs = NULL, QQ = NULL, MDQQ = NULL, Results = NULL), x.labels = list(PDFs = NULL, CDFs = NULL, QQ = NULL, MDQQ = NULL), y.labels = list(PDFs = NULL, CDFs = NULL, QQ = NULL, MDQQ = NULL), same.window = FALSE, ask = same.window & plot.type == "All", hist.col = "cyan", fitted.pdf.col = "black", fitted.pdf.lwd = 3 * par("cex"), fitted.pdf.lty = 1, plot.pos.con = switch(dist.abb, norm = , lnorm = , lnormAlt = , lnorm3 = 0.375, evd = 0.44, 0.4), ecdf.col = "cyan", fitted.cdf.col = "black", ecdf.lwd = 3 * par("cex"), fitted.cdf.lwd = 3 * par("cex"), ecdf.lty = 1, fitted.cdf.lty = 2, add.line = TRUE, digits = ifelse(plot.type == "Summary", 2, .Options$digits), test.result.font = 1, test.result.cex = ifelse(plot.type == "Summary", 0.9, 1) * par("cex"), test.result.mar = c(0, 0, 3, 0) + 0.1, cex.main = ifelse(plot.type == "Summary", 1.2, 1.5) * par("cex"), cex.axis = ifelse(plot.type == "Summary", 0.9, 1) * par("cex"), cex.lab = ifelse(plot.type == "Summary", 0.9, 1) * par("cex"), main = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, add.om.title = TRUE, oma = if (plot.type == "Summary" & add.om.title) c(0, 0, 2.5, 0) else c(0, 0, 0, 0), om.title = NULL, om.font = 2, om.cex.main = 1.75 * par("cex"), om.line = 0.5, ...)
"gof"
. See gof.object
for details.
plot.type="All"
, in which case all plots
will be created sequentially. The possible values of plot.type
are:
"Summary"
(the default), "PDFs: Observed and Fitted"
,
"CDFs: Observed and Fitted"
, "Q-Q Plot"
, "Tukey M-D Q-Q Plot"
,
"Test Results"
, and "All"
. See the DETAILS section for more information.
"PDFs"
, "CDFs"
,
"QQ"
, "MDQQ"
, and/or "Results"
. Each component either has
the value NULL
or else it is a character string containing the title for that
particular kind of plot. When the component has the value NULL
(the default),
a default title is used. This argument is useful when you are creating more than
one kind of plot with a single call to plot.gof
(i.e., when
plot.type="Summary"
or plot.type="All"
) and you want to specify titles
different from the default ones. If you are creating only one kind of plot,
then you can just use the main
argument to specify a title different
from the default one.
"PDFs"
, "CDFs"
, "QQ"
,
and/or "MDQQ"
. Each component either has the value
NULL
or else it is a character string containing the label for the
$x$-axis for that particular kind of plot. When the component has the value
NULL
(the default), a default $x$-axis label is used.
This argument is useful when you are creating more than
one kind of plot with a single call to plot.gof
(i.e., when
plot.type="Summary"
or plot.type="All"
)
and you want to specify $x$-axis
labels different from the default ones. If you are creating only one plot,
then you can just use the xlab
argument to
specify an $x$-axis label different from the default one.
"PDFs"
, "CDFs"
, "QQ"
,
and/or "MDQQ"
. Each component either has the value
NULL
or else it is a character string containing the label for the
$y$-axis for that particular kind of plot. When the component has the value
NULL
(the default), a default $y$-axis label is used.
This argument is useful when you are creating more than
one kind of plot with a single call to plot.gof
(i.e., when
plot.type="Summary"
or plot.type="All"
)
and you want to specify $y$-axis
labels different from the default ones. If you are creating only one plot,
then you can just use the ylab
argument to
specify a $y$-axis label different from the default one.
same.window=TRUE
), or to create a new graphics
window for each separate plot (same.window=FALSE
; the default).
The argument is relevant only when plot.type="All"
.
devAskNewPage
, indicating
whether to prompt the user before creating a new plot within a single graphics
window. The default value is FALSE
unless same.window=TRUE
and
plot.type == "All"
.
plot.type == "Summary"
, the default value is
digits=2
, otherwise it is .Options$digits
(i.e., the current
setting of options("digits")
).
This argument is ignored when plot.type="PDFs: Observed and Fitted"
.
hist.col="cyan"
. See the entry for col
in the R help file for
par
for more information.
fitted.pdf.col="black"
.
See the entry for col
in the R help file for par
for more information.
fitted.pdf.lwd=3*par("cex")
.
See the entry for lwd
in the R help file for par
for more information.
fitted.pdf.lty=1
.
See the entry for lty
in the R help file for par
for more information.
plot.pos.con
depends on the value of gof.obj$distribution
(i.e., the distribution assumed for the goodness-of-fit test).
For the normal, lognormal, and
three-parameter lognormal distributions,
the default value is
plot.pos.con=0.375
. For the Type I extreme value (Gumbel) distribution,
the default value is plot.pos.con=0.44
. For all other distributions,
the default value is plot.pos.con=0.4
. See the help files for
ecdfPlot
and qqPlot
for more information and the
motivation for these choices of values. NOTE: This argument is also used to determine the value of the
plotting position constant for the Q-Q plot (plot.type="Q-Q Plot"
), or the
Tukey Mean-Difference Q-Q plot (plot.type="Tukey M-D Q-Q Plot"
).
ecdf.col="cyan"
. See the entry for col
in the R help file for
par
for more information.
fitted.cdf.col="black"
.
See the entry for col
in the R help file for par
for more information.
ecdf.lwd=3*par("cex")
.
See the entry for lwd
in the R help file for par
for more information.
fitted.cdf.lwd=3*par("cex")
.
See the entry for lwd
in the R help file for par
for more information.
ecdf.lty=1
.
See the entry for lty
in the R help file for par
for more information.
fitted.cdf.lty=2
.
See the entry for lty
in the R help file for par
for more information.
add.line=TRUE
and plot.type="Q-Q Plot"
, a 0-1 line is added to the plot.
If add.line=TRUE
and plot.type="Tukey M-D Q-Q Plot"
, a horizontal
line at $y=0$ is added to the plot. The default value is add.line=TRUE
.
test.result.font=1
. See the description of the
font
argument in the help file for par
for more information.
You may get better results if you use a font number that corresponds to a fixed
font (e.g., courier).
cex
to use to print out the
test results. The default value is 0.9*par("cex")
when
plot.type="Summary"
, otherwise it is par("cex")
.
See the description of the cex
argument in the help file for
par
for more information.
mar
to use to print out the
test results. The default value is test.result.mar=c(0, 0, 3, 0)+0.1
.
See the description of the mar
argument in the help file for
par
for more information.
plot.type="Summary"
. The default value is add.om.title=TRUE
.
om.title=NULL
, which will result in a default title.
om.font=2
.
cex
for the outer margin title.
The default value is 1.75 * par("cex")
.
om.line=0.5
.
par
.
plot.gof
invisibly returns the first argument, x
.
plot.gof
is a method for the generic function
plot
for objects that inherit from class "gof"
(see gof.object
).
It can be invoked by calling plot
and giving it an object of
class "gof"
as the first argument, or by calling plot.gof
directly, regardless of the class of the object given as the first argument
to plot.gof
.Plots associated with the goodness-of-fit test are produced on the current graphics device. These can be one or all of the following:
plot.type="PDFs: Observed and Fitted"
). See the help files for
hist
and pdfPlot
.
plot.type="CDFs: Observed and Fitted"
). See the help file for
cdfCompare
.
plot.type="Q-Q Plot"
). See the help file for qqPlot
.
plot.type="Tukey M-D Q-Q Plot"
).
See the help file for qqPlot
.
plot.type="Test Results"
).
See the help file for print.gof
.
See the help file for gofTest
for more information.
gofTest
, gof.object
, print.gof
,
Goodness-of-Fit Tests, plot
.
# Create an object of class "gof" then plot the results.
# (Note: the call to set.seed simply allows you to reproduce
# this example.)
set.seed(250)
dat <- rnorm(20, mean = 3, sd = 2)
gof.obj <- gofTest(dat)
# Summary plot (the default)
#---------------------------
dev.new()
plot(gof.obj)
# Make your own titles for the summary plot
#------------------------------------------
dev.new()
plot(gof.obj, captions = list(PDFs = "Compare PDFs",
CDFs = "Compare CDFs", QQ = "Q-Q Plot", Results = "Results"),
om.title = "Summary")
# Just the Q-Q Plot
#------------------
dev.new()
plot(gof.obj, plot.type="Q-Q")
# Make your own title for the Q-Q Plot
#-------------------------------------
dev.new()
plot(gof.obj, plot.type="Q-Q", main = "Q-Q Plot")
#==========
# Clean up
#---------
rm(dat, gof.obj)
graphics.off()
Run the code above in your browser using DataLab