Description Usage Arguments Details Value Author(s) References See Also Examples
Function cnm
can be used to compute the maximum likelihood estimate
of a nonparametric mixing distribution (NPMLE) that has a onedimensional
mixing parameter. or simply the mixing proportions with support points held
fixed.
1 2 3 4 5 6 7 8 9 10 
x 
a data object of some class that is fully defined by the user. The user needs to supply certain functions as described below. 
init 
list of userprovided initial values for the mixing distribution

model 
the type of model that is to estimated: the nonparametric MLE
(if 
maxit 
maximum number of iterations. 
tol 
a tolerance value needed to terminate an algorithm. Specifically,
the algorithm is terminated, if the increase of the loglikelihood value
after an iteration is less than 
grid 
number of grid points that are used by the algorithm to locate
all the local maxima of the gradient function. A larger number increases the
chance of locating all local maxima, at the expense of an increased
computational cost. The locations of the grid points are determined by the
function 
plot 
whether a plot is produced at each iteration. Useful for
monitoring the convergence of the algorithm. If 
verbose 
verbosity level for printing intermediate results in each iteration, including none (= 0), the loglikelihood value (= 1), the maximum gradient (= 2), the support points of the mixing distribution (= 3), the mixing proportions (= 4), and if available, the value of the structural parameter beta (= 5). 
A finite mixture model has a density of the form
f(x; pi, theta, beta) = sum_{j=1}^k pi_j f(x; theta_j, beta),
where pi_j >= 0 and sum_{j=1}^k pi_j =1sum_{j=1}^k pi_j =1.
A nonparametric mixture model has a density of the form
f(x; G) = Integral f(x; theta) d G(theta),
where G is a mixing distribution that is completely unspecified. The maximum likelihood estimate of the nonparametric G, or the NPMLE of G, is known to be a discrete distribution function.
Function cnm
implements the CNM algorithm that is proposed in Wang
(2007) and the hierarchical CNM algorithm of Wang and Taylor (2013). The
implementation is generic using S3 objectoriented programming, in the sense
that it works for an arbitrary family of mixture models defined by the user.
The user, however, needs to supply the implementations of the following
functions for their selfdefined family of mixture models, as they are
needed internally by function cnm
:
initial(x, beta, mix, kmax)
valid(x, beta)
logd(x, beta, pt, which)
gridpoints(x, beta, grid)
suppspace(x, beta)
length(x)
print(x, ...)
weight(x, ...)
While not needed by the algorithm for finding the solution, one may also implement
plot(x, mix, beta, ...)
so that the fitted model can be shown graphically in a userdefined way.
Inside cnm
, it is used when plot="probability"
so that the
convergence of the algorithm can be graphically monitored.
For creating a new class, the user may consult the implementations of these
functions for the families of mixture models included in the package, e.g.,
npnorm
and nppois
.
family 
the name of the mixture family that is used to fit to the data. 
num.iterations 
number of iterations required by the algorithm 
max.gradient 
maximum value of the gradient function, evaluated at the beginning of the final iteration 
convergence 
convergence code. 
ll 
loglikelihood value at convergence 
mix 
MLE of the mixing distribution, being an object of the class

beta 
value of the structural parameter, that is held fixed throughout the computation. 
Yong Wang <yongwang@auckland.ac.nz>
Wang, Y. (2007). On fast computation of the nonparametric maximum likelihood estimate of a mixing distribution. Journal of the Royal Statistical Society, Ser. B, 69, 185198.
Wang, Y. (2010). Maximum likelihood computation for fitting semiparametric mixture models. Statistics and Computing, 20, 7586
Wang, Y. and Taylor, S. M. (2013). Efficient computation of nonparametric survival functions via a hierarchical mixture formulation. Statistics and Computing, 23, 713725.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  ## Simulated data
x = rnppois(1000, disc(c(1,4), c(0.7,0.3))) # Poisson mixture
(r = cnm(x))
plot(r, x)
x = rnpnorm(1000, disc(c(0,4), c(0.3,0.7)), sd=1) # Normal mixture
plot(cnm(x), x) # sd = 1
plot(cnm(x, init=list(beta=0.5)), x) # sd = 0.5
mix0 = disc(seq(min(x$v),max(x$v), len=100)) # over a finite grid
plot(cnm(x, init=list(beta=0.5, mix=mix0), model="p"),
x, add=TRUE, col="blue") # An approximate NPMLE
## Realworld data
data(thai)
plot(cnm(x < nppois(thai)), x) # Poisson mixture
data(brca)
plot(cnm(x < npnorm(brca)), x) # Normal mixture

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.