cnmms: Maximum Likelihood Estimation of a Semiparametric Mixture...

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

View source: R/cnm.R

Description

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.

Usage

1
2
3
4
5
6
7
cnmms(x, init=NULL, maxit=1000, model=c("spmle","npmle"), tol=1e-6,
     grid=100, kmax=Inf, plot=c("null", "gradient", "probability"),
     verbose=0)
cnmpl(x, init=NULL, tol=1e-6, tol.npmle=tol*1e-4, grid=100, maxit=1000,
     plot=c("null", "gradient", "probability"), verbose=0)
cnmap(x, init=NULL, maxit=1000, tol=1e-6, grid=100, plot=c("null",
     "gradient"), verbose=0)

Arguments

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.

Details

Function cnmms can also be used to compute the maximum likelihood estimate of a finite or nonparametric mixture model.

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.

A semiparametric mixture model has a density of the form

f(x; G, beta) = Int f(x; theta, beta) d G(theta),

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.

Value

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

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

nnls, cnm, cvp, cvps, mlogit.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Compute the MLE of a finite mixture
x = rnpnorm(100, disc(c(0,4), c(0.7,0.3)), sd=1)
for(k in 1: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 algorithm
cnmpl(x)              # CNM-PL algorithm
cnmap(x)              # CNM-AP algorithm

# Logistic regression with a random intercept
x = 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 = 136
cnmms(mlogit(toxo))

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

Related to cnmms in nspmix...