R: Plot Nonparametric or Semiparametric EM Output

plot.npEM {mixtools} | R Documentation

## Plot Nonparametric or Semiparametric EM Output

### Description

Takes 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 `npEM` such as the output of the `npEM` function
`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 `hist` function
`ylim` | `ylim` parameter 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 `hist` and `lines` functions.

### Value

`plot.npEM` returns a list with two elements:

`x` | List of matrices. The jth column of the ith matrix is the vector of x-values for the jth density in the ith plot.
`y` | y-values, given in the same form as the x-values.

### See Also

`npEM`, `density.npEM`, `spEMsymloc`, `plotseq.npEM`

### 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)
    ## Not run:
    a <- npEM(Waterdata[,3:10], 3, bw=4)
    par(mfrow=c(2,4))
    plot(a) # This produces 8 plots, one for each coordinate

    ## End(Not run)

    ## Not run:
    ## 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

    ## End(Not run)

[Package mixtools version 1.2.0 Index]