Maximum Likelihood Estimation of a Semiparametric Mixture Model
Maximum Likelihood Estimation of a Semiparametric Mixture Model
Functions cnmms, cnmpl and cnmap can be used to compute the maximum likelihood estimate of a semiparametric mixture model that has a one-dimensional mixing parameter. The types of mixture models that can be computed include finite, nonparametric and semiparametric ones.
x: a data object of some class that can be defined fully by the user
init: list of user-provided initial values for the mixing distribution mix and the structural parameter beta
maxit: maximum number of iterations
model: the type of model that is to estimated: non-parametric MLE (npmle) or semi-parametric MLE (spmle).
tol: a tolerance value that is used to terminate an algorithm. Specifically, the algorithm is terminated, if the relative increase of the log-likelihood value after an iteration is less than tol. If an algorithm converges rapidly enough, then -log10(tol) is roughly the number of accurate digits in log-likelihood.
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 gridpoints provided by each individual mixture family, and they do not have to be equally spaced. If needed, an individual gridpoints function may return a different number of grid points than specified by grid.
kmax: upper bound on the number of support points. This is particularly useful for fitting a finite mixture model.
plot: whether a plot is produced at each iteration. Useful for monitoring the convergence of the algorithm. If null, no plot is produced. If gradient, it plots the gradient curves and if probability, the plot function defined by the user of the class is used.
verbose: verbosity level for printing intermediate results in each iteration, including none (= 0), the log-likelihood 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).
tol.npmle: a tolerance value that is used to terminate the computing of the NPMLE internally.
Returns
family: the class of the mixture family that is used to fit to the data.
num.iterations: Number of iterations required by the algorithm
grad: For cnmms, it contains the values of the gradient function at the support points and the first derivatives of the log-likelihood with respect to theta and beta. For cnmpl, it contains only the first derivatives of the log-likelihood with respect to beta. For cnmap, it contains only the gradient of beta.
max.gradient: Maximum value of the gradient function, evaluated at the beginning of the final iteration. It is only given by function cnmap.
convergence: convergence code. =0 means a success, and =1 reaching the maximum number of iterations
ll: log-likelihood value at convergence
mix: MLE of the mixing distribution, being an object of the class disc for discrete distributions
beta: MLE of the structural parameter
Details
Function cnmms can also be used to compute the maximum likelihood estimate of a finite or nonparametric mixture model.
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.
A semiparametric mixture model has a density of the form
where G is a mixing distribution that is completely unspecified and beta is the structural parameter.
Of the three functions, cnmms is recommended for most problems; see Wang (2010).
Functions cnmms, cnmpl and cnmap implement the algorithms CNM-MS, CNM-PL and CNM-AP that are described in Wang (2010). Their implementations are generic using S3 object-oriented programming, in the sense that they can work for an arbitrary family of mixture models that is defined by the user. The user, however, needs to supply the implementations of the following functions for their self-defined family of mixture models, as they are needed internally by the functions above:
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 algorithms, one may also implement
plot(x, mix, beta, ...)
so that the fitted model can be shown graphically in a way that the user desires.
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., cvp and mlogit.
Examples
## Compute the MLE of a finite mixturex = rnpnorm(100, disc(c(0,4), c(0.7,0.3)), sd=1)for(k in1:6) plot(cnmms(x, kmax=k), x, add=(k>1), comp="null", col=k+1, main="Finite Normal Mixtures")legend("topright",0.3, leg=paste0("k = ",1:6), lty=1, lwd=2, col=2:7)## Compute a semiparametric MLE# Common variance problem x = rcvps(k=50, ni=5:10, mu=c(0,4), pr=c(0.7,0.3), sd=3)cnmms(x)# CNM-MS algorithmcnmpl(x)# CNM-PL algorithmcnmap(x)# CNM-AP algorithm# Logistic regression with a random interceptx = rmlogit(k=30, gi=3:5, ni=6:10, pt=c(0,4), pr=c(0.7,0.3), beta=c(0,3))cnmms(x)data(toxo)# k = 136cnmms(mlogit(toxo))
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