Plot Nonparametric or Semiparametric EM Output
plot.npEM.RdTakes an object of class npEM and returns a set of plots of the
density estimates for each block and each component. There is one plot
per block, with all the components displayed on each block so it is possible
to see the mixture structure for each block.
Usage
# S3 method for class 'npEM'
plot(x, blocks = NULL, hist=TRUE, addlegend = TRUE,
scale=TRUE, title=NULL, breaks="Sturges", ylim=NULL, dens.col,
newplot = TRUE, pos.legend = "topright", cex.legend = 1, ...)
# S3 method for class 'spEM'
plot(x, blocks = NULL, hist=TRUE, addlegend = TRUE,
scale=TRUE, title=NULL, breaks="Sturges", ylim=NULL, dens.col,
newplot = TRUE, pos.legend = "topright", cex.legend = 1, ...)Arguments
- x
An object of class
npEMsuch as the output of thenpEMfunction- blocks
Blocks (of repeated measures coordinates) to plot; not relevant for univariate case. Default is to plot all blocks.
- hist
If TRUE, superimpose density estimate plots on a histogram of the data
- addlegend
If TRUE, adds legend to the plot.
- scale
If TRUE, scale each density estimate by its corresponding estimated mixing proportion, so that the total area under all densities equals 1 and the densities plotted may be added to produce an estimate of the mixture density. When FALSE, each density curve has area 1 in the plot.
- title
Alternative vector of main titles for plots (recycled as many times as needed)
- breaks
Passed directly to the
histfunction- ylim
ylimparameter to use for all plots, if desired. If not given, each plot uses its own ylim that ensures that no part of the plot will go past the top of the plotting area.- dens.col
Color values to use for the individual component density functions, repeated as necessary. Default value is
2:(m+1).- newplot
If TRUE, creates a new plot.
- pos.legend
Single argument specifying the position of the legend. See `Details' section of
legend.- cex.legend
Character expansion factor for
legend.- ...
Any remaining arguments are passed to the
histandlinesfunctions.
Value
plot.npEM returns a list with two elements:
- x
List of matrices. The \(j\)th column of the \(i\)th matrix is the vector of \(x\)-values for the \(j\)th density in the \(i\)th plot.
- y
\(y\)-values, given in the same form as the \(x\)-values.
Examples
## Examine and plot water-level task data set.
## First, try a 3-component solution where no two coordinates are
## assumed i.d.
data(Waterdata)
set.seed(100)
if (FALSE) { # \dontrun{
a <- npEM(Waterdata[,3:10], 3, bw=4)
par(mfrow=c(2,4))
plot(a) # This produces 8 plots, one for each coordinate
} # }
if (FALSE) { # \dontrun{
## Next, same thing but pairing clock angles that are directly opposite one
## another (1:00 with 7:00, 2:00 with 8:00, etc.)
b <- npEM(Waterdata[,3:10], 3, blockid=c(4,3,2,1,3,4,1,2), bw=4)
par(mfrow=c(2,2))
plot(b) # Now only 4 plots, one for each block
} # }