compare
objectsThis is a plot
method for objects of class compare
. It automates the creation of four summary and diagnostic plots for compare
objects. See the Plotting with the distfreereg
Package vignette for examples.
# S3 method for compare
plot(x, y, ..., which = "cdf", stat = NULL, hlines = NULL, curve_args = NULL,
confband_args = FALSE, density_args = NULL, poly = NULL, legend = NULL,
qqline = NULL)
The values used to create the curves (or points, in the case of a Q--Q plot) are returned invisibly. The details depend on the value of which
:
cdf
: A list with two or four elements, all lists. The first two sub-lists contain the \(x\)- and \(y\)-values cdf curves. If confidence bands are plotted, then two additional elements are included with output from the confidence band calculations, including elements w
, cb_lower
, and cb_upper
, which contain, respectively, the \(x\)-coordinates for both the upper and lower bounds of the band, the \(y\)-coordinates for the lower band, and the \(y\)-coordinates for the upper band.
dens
: A list with two or four elements, all lists. The first two sub-lists contain \(x\)- and \(y\)-values for the density curves. If confidence bands are plotted, then two additional sub-lists are supplied, with contents identical to what is described for "cdf
".
qq
, qqp
: The output of qqplot
.
For "cdf
" and "dens
", the names of the elements of the returned list depend on whether or not a value for the argument y
was supplied.
Object of class compare
.
Optional object of class compare
.
Additional parameters passed to a plotting function depending on the
value of which
: to plot
for "cdf
" and
"dens
"; to qqplot
for "qq
" and "qqp
".
Character string. Acceptable values are "cdf
", "dens
", "qq
", and "qqp
":
"cdf
" produces a plot of the estimated cumulative distribution
functions of the two vectors of statistics being compared.
"dens
" produces a plot of the estimated density functions of
the two vectors of statistics being compared.
"qq
" produces a quantile--quantile plot comparing the two
vectors of statistics.
"qqp
" produces a quantile--quantile plot comparing the p-values
with uniform quantiles. (This is not available when y
is present.)
Character string, specifies the statistic to plot.
An optional list of arguments to pass to abline
, used to create the horizontal dashed lines when which
is "cdf
". Setting equal to FALSE
prevents the call, and no lines are drawn.
An optional list used to pass arguments to lines
(not curve
!), used to create the curves when which
is "cdf
" or "dens
". It can have two special named arguments, obs
and mcsim
, whose values must be lists. Those lists contain arguments passed to the calls to lines
for plotting the curves for the observed and simulated statistics, respectively. Any other elements are passed to both calls.
An optional list of values that control the calculation and plotting of confidence bands when which
is "cdf
" or "dens
". Any of the following named elements are allowed.
w
: Numeric; the sequence of points on which to evaluate the confidence band. By default, the sequence is seq(from = min(x) + buffer, to = max(x) - buffer, length.out = m)
, where x
is the vector of values of the statistic in question, and buffer
is explained below.
m
: Integer; the length of w
, used only when w
is NULL
. The default value is 100.
batch_len
: Integer; the batch length for the algorithm. The default value is 50.
N
: Integer; the number of multivariate \(t\) samples to use in the simulation.
conf.level
: Numeric; the desired confidence level.
buffer
: Numeric; the proportion of either side of the range of data to ignore when defining w
, used only when w
is NULL
.
curve_args
: An optional list of arguments passed to lines
(again, not curve
!), used to create the boundaries of the confidence band. It can have two special named arguments, obs
and mcsim
, which function in the same way as the corresponding elements of the curve_args
argument described above.
polygon_args
: An optional list of arguments passed to polygon
, used to shade the confidence region. Setting equal to FALSE
prevents the call, and no shading is done.
shade_col
: This provides a shortcut to the col
argument of polygon
to change the color of the shaded region.
Setting equal to FALSE
prevents calculation and plotting of the band.
An optional list of arguments passed to density
when which
is "dens
", which calculates the points used to plot the density curves. The list can have two special named elements, obs
and mcsim
, which function in the same way as the corresponding elements of the curve_args
argument described above.
An optional list of arguments passed to polygon
when which
is "dens
", which shades the area under the density curves. The list can have two special named elements, obs
and mcsim
, which modify the shadings for their respective curves, analogous to their behavior in the curve_args
argument. When poly
is equal to FALSE
, no call is made, and therefore no shading is done.
An optional list of arguments passed to legend
when which
is "cdf
" or "dens
". When equal to FALSE
, no call is made, and therefore no legend is created.
An optional list of arguments passed to abline
when which
is "qq
" or "qqp
". By default, this plots the line \(y=x\). When equal to FALSE
, no call is made, and therefore no line is plotted.
Jesse Miller
This function produces a plot of a type specified by which
. The values
plotted depend on whether or not y
is present and the value of
which
. When y
is present, the plots compare the observed
statistics in x
and the observed statistics in y
. When y
is missing, the plots compare the observed and simulated statistics in
x
. (The exception is when which
is "qqp
", which is only
available when y
is missing.)
When which
is "cdf
" or "dens
", the plotting region and
associated labels, tick marks, etc., are created by an initial call to
plot
. The curves themselves are drawn with lines
.
The arguments specified in ...
are passed to the initial call to
plot
.
Flegal, James M. et al. Simultaneous confidence bands for (Markov chain) Monte Carlo simulations, forthcoming.
distfreereg
, compare