bs.test {mixR} | R Documentation |
Bootstrap Likelihood Ratio Test for Finite Mixture Models
Description
This function performs the likelihood ratio test by parametric bootstrapping for two mixture models with different number of components.
Usage
bs.test(
x,
ncomp = c(1, 2),
family = c("normal", "weibull", "gamma", "lnorm"),
B = 100,
ev = FALSE,
mstep.method = c("bisection", "newton"),
init.method = c("kmeans", "hclust"),
tol = 1e-06,
max_iter = 500
)
Arguments
x |
a numeric vector for the raw data or a three-column matrix for the binned data. |
ncomp |
a vector of two positive integers specifying the number of components of the
mixture model under the null and alternative hypothesis.
The first integer should be smaller than the second one. The default value is
|
family |
a character string specifying the family of the mixture model, which can be one
of |
B |
the number of bootstrap iterations (default 100). |
ev |
a logical value indicating whether the variance of each component should be the same
or not (default |
mstep.method |
the method used in M-step of EM algorithm for |
init.method |
a character string specifying the method used for providing the initial values
for the parameters for the EM algorithm. It can be one of |
tol |
the tolerance for the stopping rule of EM algorithm. It is the value to stop
EM algorithm when the two consecutive iterations produces log-likelihood with difference
less than |
max_iter |
the maximum number of iterations for the EM algorithm (default 500). |
Details
For the given data x
and the specified family, the function bs.test
conducts
a bootstrap likelihood ratio test for two mixture models with the number of components
under the null and the alternative hypothesis specified in ncomp
.
Value
The function bs.test
returns an object of class bootEM
which
contains the following three items.
pvalue |
The p-value of the bootstrap likelihood ratio test |
w0 |
the observed likelihood ratio test statistic |
w1 |
a vector of simulated likelihood ratio test statistics |
See Also
Examples
## testing normal mixture models with 2 and 3 components
set.seed(100)
x <- rmixnormal(200, c(0.5, 0.5), c(2, 5), c(1, 0.7))
ret <- bs.test(x, ncomp = c(2, 3), B = 30)
ret
## (not run) testing Weibull mixture models with 2 and 3 components
## set.seed(101)
## x <- rmixweibull(200, c(0.3, 0.4, 0.3), c(2, 5, 8), c(1, 0.6, 0.8))
## ret <- bs.test(x, ncomp = c(2, 3), family = "weibull", B = 30)
## ret
## (not run) testing Gamma mixture models with 1 and 2 components
## set.seed(102)
## x <- rgamma(200, 2, 1)
## ret <- bs.test(x, ncomp = c(1, 2), family = "gamma", B = 30)
## ret