Plot Results of Goodness-of-Fit Test
Plot the results of calling the function 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.
## S3 method for class 'gof' 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, ...)
x |
an object of class |
plot.type |
character string indicating what kind of plot to create. Only one particular
plot type will be created, unless |
captions |
a list with 1 to 5 components with the names |
x.labels |
a list of 1 to 4 components with the names |
y.labels |
a list of 1 to 4 components with the names |
same.window |
logical scalar indicating whether to produce all plots in the same graphics
window ( |
ask |
logical scalar supplied to the function |
digits |
scalar indicating how many significant digits to print for the distribution
parameters. If |
Arguments associated with plot.type="PDFs: Observed and Fitted"
:
hist.col |
a character string or numeric scalar determining the color of the histogram
used to display the distribution of the observed values. The default value is
|
fitted.pdf.col |
a character string or numeric scalar determining the color of the fitted PDF
(which is displayed as a line for continuous distributions and a histogram for
discrete distributions). The default value is |
fitted.pdf.lwd |
numeric scalar determining the width of the line used to display the fitted PDF.
The default value is |
fitted.pdf.lty |
numeric scalar determining the line type used to display the fitted PDF.
The default value is |
Arguments associated with plot.type="CDFs: Observed and Fitted"
:
plot.pos.con |
numeric scalar between 0 and 1 containing the value of the plotting position
constant used to construct the observed (empirical) CDF. The default value of
NOTE: This argument is also used to determine the value of the
plotting position constant for the Q-Q plot ( |
ecdf.col |
a character string or numeric scalar determining the color of the line
used to display the empirical CDF. The default value is
|
fitted.cdf.col |
a character string or numeric scalar determining the color of the line used
to display the fitted CDF. The default value is |
ecdf.lwd |
numeric scalar determining the width of the line used to display the empirical CDF.
The default value is |
fitted.cdf.lwd |
numeric scalar determining the width of the line used to display the fitted CDF.
The default value is |
ecdf.lty |
numeric scalar determining the line type used to display the empirical CDF.
The default value is |
fitted.cdf.lty |
numeric scalar determining the line type used to display the fitted CDF.
The default value is |
Arguments associated with plot.type="Q-Q Plot"
or plot.type="Tukey M-D Q-Q Plot"
:
As explained above, plot.pos.con
is used for these plot types. Also:
add.line |
logical scalar indicating whether to add a line to the plot. If |
Arguments associated with plot.type="Test Results"
test.result.font |
numeric scalar indicating which font to use to print out the test results.
The default value is |
test.result.cex |
numeric scalar indicating the value of |
test.result.mar |
numeric vector indicating the value of |
Arguments associated with plot.type="Summary"
add.om.title |
logical scalar indicating whether to add a title in the outer margin when |
om.title |
character string containing the outer margin title. The default value is |
om.font |
numeric scalar indicating the font to use for the outer margin. The default
value is |
om.cex.main |
numeric scalar indicating the value of |
om.line |
numeric scalar indicating the line to place the outer margin title on. The
default value is |
Graphics parameters:
cex.main, cex.axis, cex.lab, main, xlab, ylab, xlim, ylim, oma, ... |
additional graphics parameters. See the help file for |
The function 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:
Observed distribution overlaid with fitted distribution
(plot.type="PDFs: Observed and Fitted"
). See the help files for
hist
and pdfPlot
.
Observed empirical distribution overlaid with fitted cumulative distribution
(plot.type="CDFs: Observed and Fitted"
). See the help file for
cdfCompare
.
Observed quantiles vs. fitted quantiles (Q-Q Plot)
(plot.type="Q-Q Plot"
). See the help file for qqPlot
.
Tukey mean-difference Q-Q plot (plot.type="Tukey M-D Q-Q Plot"
).
See the help file for qqPlot
.
Results of the goodness-of-fit test (plot.type="Test Results"
).
See the help file for print.gof
.
See the help file for gofTest
for more information.
plot.gof
invisibly returns the first argument, x
.
Steven P. Millard (EnvStats@ProbStatInfo.com)
Chambers, J. M. and Hastie, T. J. (1992). Statistical Models in S. Wadsworth & Brooks/Cole.
# 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()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.