plotgrad: Plot the Gradient Function

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/cnm.R

Description

Function plotgrad plots the gradient function or its first derivative of a nonparametric mixture.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
plotgrad(
  x,
  mix,
  beta,
  len = 500,
  order = 0,
  col = "blue",
  col2 = "red",
  add = FALSE,
  main = paste0("Class: ", class(x)),
  xlab = expression(theta),
  ylab = paste0("Gradient (order = ", order, ")"),
  cex = 1,
  pch = 1,
  lwd = 1,
  xlim,
  ylim,
  ...
)

Arguments

x

a data object of a mixture model class.

mix

an object of class 'disc', for a discrete mixing distribution.

beta

the structural parameter.

len

number of points used to plot the smooth curve.

order

the order of the derivative of the gradient function to be plotted. If 0, it is the gradient function itself.

col

color for the curve.

col2

color for the support points.

add

if FALSE, create a new plot; if TRUE, add the curve and points to the current one.

main, xlab, ylab, cex, pch, lwd, xlim, ylim

arguments for graphical parameters (see par).

...

arguments passed on to function plot.

Details

data must belong to a mixture family, as specified by its class.

The support points are shown on the horizontal line of gradient 0. The vertical lines going downwards at the support points are proportional to the mixing proportions at these points.

Author(s)

Yong Wang <yongwang@auckland.ac.nz>

References

Wang, Y. (2007). On fast computation of the non-parametric maximum likelihood estimate of a mixing distribution. Journal of the Royal Statistical Society, Ser. B, 69, 185-198.

Wang, Y. (2010). Maximum likelihood computation for fitting semiparametric mixture models. Statistics and Computing, 20, 75-86

See Also

plot.nspmix, nnls, cnm, cnmms, npnorm, nppois.

Examples

1
2
3
4
5
6
7
8
9
## Poisson mixture
x = rnppois(200, disc(c(1,4), c(0.7,0.3)))
r = cnm(x)
plotgrad(x, r$mix)

## Normal mixture
x = rnpnorm(200, disc(c(0,4), c(0.3,0.7)), sd=1)
r = cnm(x, init=list(beta=0.5))   # sd = 0.5
plotgrad(x, r$mix, r$beta)

nspmix documentation built on Oct. 23, 2020, 6:46 p.m.

Related to plotgrad in nspmix...