plot.nmix {Nmix} | R Documentation |
Plotting for Bayesian Inference on Univariate Normal Mixtures
Description
Plotting of various information from nmix
object on current graphics device
Usage
## S3 method for class 'nmix'
plot(x, which=1:5, separate=FALSE, plugin=FALSE, offset=1, nsamp=50,
equi=TRUE, allsort=TRUE, trued=NULL, ...)
Arguments
x |
|
which |
integer vector, specifying which of several available plots are required, see 'Details' below |
separate |
logical, if |
plugin |
logical, should plug-in estimator of density, computed from posterior means of parameters, be superimposed on density plot in darkgreen, in the case |
offset |
t
numeric, vertical displacement between plotted traces, in the case |
nsamp |
integer, number of posterior samples plotted, in the case |
equi |
logical, should thinning of posterior density samples be equi-spaced, rather than random, in the case |
allsort |
logical, should observations be sorted before making posterior clusters plot, in the case |
trued |
vectorised function defining a probability density function to be superimposed in blue on density plots, in the cases |
... |
additional arguments to |
Details
If which
includes 1, a 2-panel plot of which: the first is a histogram of the data, and if z
has a component den
(Nmix
output option D), superimposed plots of the posterior density estimates, conditional on k=1,2,...,6
and unconditionally (in red); and the second a barplot of the estimated posterior distribution of k
.
If which
includes 2, a multiple trace plot of various statistics for a thinned subsample of the MCMC run, after burn-in. The statistics are the (named) components of the list z$traces
that are numerical vectors, some or all of (i) the number of components k
(Nmix
output option k), (ii) the entropy (Nmix
output option e), and (iii) the deviance (Nmix
output option d), of the current sample. The traces may be of different lengths, the horizontal scales in the plot are adjusted to span the length of the (post burn-in) MCMC run, regardless of these differences.
If which
includes 3 (and Nmix
output option p is present), a thinned sample of size nsamp
from the posterior distribution of the density function, computed from a thinned sample of (weight, mean, sd) values generated in the posterior simulation.
If which
includes 4 (and Nmix
output option a is present), an image plot showing the posterior probabilities that the corresponding observations are in the same mixture component. Not recommended for large n
.
If which
includes 5 (and Nmix
output option C is present), a 4-panel plot displaying Bayersian classifications based on the fitted model, analogous to Fig. 10 in the Richardson and Green paper. The 4 panels corresponding to conditioning on the 4 values of k
most probable according to the posterior (among those for which the necessary posterior sample information has been recorded (see argument k1k2
of Nmix
), and excepting k=1
).
Value
NULL, invisibly
; plot method for class nmix
. Function called for its side effect of plotting selected information about the fitted posterior distribution and sampler performance from x
on the current graphics device
Author(s)
Peter J. Green
References
Richardson and Green (J. R. Statist. Soc. B, 1997, 59, 731-792; see also the correction in J. R. Statist. Soc. B, 1998, 60, 661)
Examples
data(galx)
z<-Nmix('galx',nsweep=10000,nburnin=1000,out="d")
plot(z,1:2)