Last chance! 50% off unlimited learning
Sale ends in
gofGroupTest
,
which returns an object of class "gofGroup"
when performing a
goodness-of-fit test to determine whether data in a set of
groups appear to all come from the same probability distribution
(with possibly different parameters for each group).
Five different kinds of plots are available.
The function plot.gofGroup
is automatically called by plot
when given an object of class "gofGroup"
. The names of other functions
associated with goodness-of-fit test are listed under Goodness-of-Fit Tests.## S3 method for class 'gofGroup':
plot(x, plot.type = "Summary",
captions = list(QQ = NULL, MDQQ = NULL, ScoresQQ = NULL, ScoresMDQQ = NULL,
Results = NULL),
x.labels = list(QQ = NULL, MDQQ = NULL, ScoresQQ = NULL, ScoresMDQQ = NULL),
y.labels = list(QQ = NULL, MDQQ = NULL, ScoresQQ = NULL, ScoresMDQQ = NULL),
same.window = FALSE, ask = same.window & plot.type == "All", 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, individual.p.values = FALSE,
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, 5, 0) else c(0, 0, 0, 0),
om.title = NULL, om.font = 2, om.cex.main = 1.5 * par("cex"), om.line = 1, ...)
"gofGroup"
. See gofGroup.object
for details.plot.type="All"
, in which case all plots
will be created sequentially. The possible values of plot.type
are:"QQ"
, "MDQQ"
,
"ScoresQQ"
, "ScoresMDQQ"
, and/or "Results"
.
Each component either has
the value NULL
or else it is a char"QQ"
, "MDQQ"
,
"ScoresQQ"
, and/or "ScoresMDQQ"
.
Each component either has the value
NULL
or else it is a character string containing th"QQ"
, "MDQQ"
,
"ScoresQQ"
, and/or "ScoresMDQQ"
. Each component either has the value
NULL
or else it is a character string containing the labsame.window=TRUE
), or to create a new graphics
window for each separate plot (same.window=FALSE
; the default).
The argument is relevdevAskNewPage
, indicating
whether to prompt the user before creating a new plot within a single graphics
window. The default value is FALSE
add.line=TRUE
and plot.type="Q-Q Plot"
or plot.type="Scores Q-Q Plot"
,
a 0-1 line is added to the plot.
If add.line=TRUE
and plot.type="Summary"
or plot.type="Test Results"
.
If plot.type == "Summary"
, the default value is
digits=2
, otindividual.p.values=FALSE
.test.result.font=1
. See the description of the
font
argument in the help file for par
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 descriptionmar
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
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.5 * par("cex")
.om.line=1
.par
.plot.gofGroup
invisibly returns the first argument, x
.plot.gofGroup
is a method for the generic function
plot
for the class "gofGroup"
(see
gofGroup.object
).
It can be invoked by calling plot
and giving it an object of
class "gofGroup"
as the first argument, or by calling
plot.gofGroup
directly, regardless of the class of the object given
as the first argument to plot.gofGroup
.
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="Q-Q Plot"
.
Q-Q Plot of observed p-values vs. quantiles from aUniform [0,1] distribution.
See the help file forqqPlot
.plot.type="Tukey M-D Q-Q Plot"
.
Tukey mean-difference Q-Q plot for observed p-values and
quantiles from aUniform [0,1] distribution.
See the help file forqqPlot
.plot.type="Scores Q-Q Plot"
.
Q-Q Plot of Normal scores vs. quantiles from aNormal(0,1) distributionor
Q-Q Plot of Chisquare scores vs. quantiles from aChisquare distributionwith 2 degrees of freedom.
See the help file forqqPlot
.plot.type="Scores Tukey M-D Q-Q Plot"
.
Tukey mean-difference Q-Q plot based on Normal scores or
Chisquare scores.
See the help file forqqPlot
.plot.type="Test Results"
).
See the help file forprint.gofGroup
.gofGroupTest
for more information.gofGroupTest
, gofGroup.object
,
print.gofGroup
,
Goodness-of-Fit Tests, plot
.# Create an object of class "gofGroup" then plot it.
# Example 10-4 of USEPA (2009, page 10-20) gives an example of
# simultaneously testing the assumption of normality for nickel
# concentrations (ppb) in groundwater collected at 4 monitoring
# wells over 5 months. The data for this example are stored in
# EPA.09.Ex.10.1.nickel.df.
EPA.09.Ex.10.1.nickel.df
# Month Well Nickel.ppb
#1 1 Well.1 58.8
#2 3 Well.1 1.0
#3 6 Well.1 262.0
#...
#18 6 Well.4 85.6
#19 8 Well.4 10.0
#20 10 Well.4 637.0
# Test for a normal distribution at each well:
#--------------------------------------------
gofGroup.obj <- gofGroupTest(Nickel.ppb ~ Well,
data = EPA.09.Ex.10.1.nickel.df)
dev.new()
plot(gofGroup.obj)
# Make your own titles for the summary plot
#------------------------------------------
dev.new()
plot(gofGroup.obj, captions = list(QQ = "Q-Q Plot",
ScoresQQ = "Scores Q-Q Plot", Results = "Results"),
om.title = "Summary Plot")
# Just the Q-Q Plot
#------------------
dev.new()
plot(gofGroup.obj, plot.type="Q-Q")
# Make your own title for the Q-Q Plot
#-------------------------------------
dev.new()
plot(gofGroup.obj, plot.type="Q-Q", main = "Q-Q Plot")
#==========
# Clean up
#---------
rm(gofGroup.obj)
graphics.off()
Run the code above in your browser using DataLab