Description Usage Arguments Details Value Author(s) References Examples
View source: R/mode_testing_lin.R
This function tests the number of modes.
1 2 3 |
data |
Sample to be tested. |
mod0 |
The maximum number of modes in the null hypothesis. Default |
method |
The method employed for testing the number of modes. Available methods are: SI (Silverman, 1981), HY (Hall and York, 2001), FM (Fisher and Marron, 2001), HH (Hartigan and Hartigan, 1985), CH (Cheng and Hall,1998), ACR (Ameijeiras-Alonso et al., 2019). Default |
B |
Number of replicates used in the test. Default |
lowsup |
Lower limit for the random variable support in the computation of the critical bandwidth. Default is |
uppsup |
Upper limit for the random variable support in the computation of the critical bandwidth. Default is |
submethod |
Different approaches when using |
n |
The number of equally spaced points at which the density is to be estimated. When n > 512, it is rounded up to a power of 2 as for |
tol |
Accuracy for computing the critical bandwidth. Default |
tol2 |
Accuracy for integration of the calibration function in the |
gridsize |
When the approximated version of the excess mass is employed in |
alpha |
Significance level employed for testing unimodality when method 1 of Hall and York (2001) is used. Default |
nMC |
Number of Monte Carlo replicates used to approximate the p-value in the method 2 of Hall and York (2001). Default |
BMC |
Number of bootstrap replicas used for computing the p-value in each Monte Carlo replicate of the Hall and York (2001) method 2. Default |
The number of modes for the underlying density of a sample given by data
can be tested with modetest
. The null hypothesis states that the sample has mod0
modes, and the alternative hypothesis is if it has more modes. The test used for calculating the p-value is specified in method
. All the available proposals require bootstrap or Monte Carlo resamples (number specified in B
).
Except when the support is employed, the typical usages are
1 2 |
Since a dichotomy algorithm is employed for computing the critical bandwidth (methods SI, HY, FM, ACR), the parameter tol
is used to determine a stopping time in such a way that the error committed in the computation of the critical bandwidth is less than tol
.
The sample data can be perturbed in the methods using the excess mass or the dip statistic (HH, CH and ACR) in order to avoid important effects on the computation of the test statistic. In general, the exact excess mass/dip value is employed, but also its approximated version can be used by setting submethod=2
in method
ACR. See excessmass
Details for more information.
Typical usages are
1 2 3 |
When employing SI method, two ways of computing the resamples are available. If submethod=1
, the resamples are generated from the rescaled bootstrap resamples as proposed by Silverman (1981). If submethod=2
, as in method
HY, the resamples are generated from the distribution that is associated to the kernel density estimation with the critical bandwidth.
Typical usage is
1 |
If a compact support containing a mode is known, it can be used to compute the Hall and York (2001) critical bandwidth. Note that in the case of the test proposed by Hall and York (2001), this support should be known, unless the support of the density function is bounded. For their proposal, two methods are implemented. submethod
1 is an asymptotic correction of Silverman (1981) test based on the limiting distribution of the test statistic. When submethod=1
, the significance level must be previously determined with alpha
. submethod
2 is based on Monte Carlo techniques. For this reason, when submethod=2
, the number of replicates (nMC
) and the number of bootstrap replicates (BMC
) used for computing the p-value in each Monte Carlo replicate are needed.
Typical usages are
1 2 3 4 5 |
A modification of the proposal of Ameijeiras-Alonso et al. (2019) can be also applied, by setting method=ACR
and including a known compact support for detecting the modes. The parameter tol2
is the accuracy required in the integration of the calibration function. For more information, see Ameijeiras-Alonso et al. (2019), the default approach, when the support is unknown, is given in Section 2.3 and, when it is provided, the approach shown in the Appendix B is employed.
Typical usage is
1 2 |
The NAs will be automatically removed.
A list with class "htest"
containing the following components:
p.value |
P-value obtained after applying the test. |
statistic |
Value of the test statistic. Critical bandwidth if the |
null.value |
The specified hypothesized value of the number of modes. |
alternative |
A character string describing the alternative hypothesis, which is always |
method |
A character string indicating what type of multimodality test was performed. |
sample.size |
The number of non-missing observations in the sample used for the hypothesis test. |
data.name |
A character string giving the name of the data. |
bad.obs |
The number of missing values that were removed from the data object prior to performing the hypothesis test. |
Jose Ameijeiras-Alonso, Rosa M. Crujeiras and Alberto Rodríguez-Casal
Ameijeiras-Alonso, J., Crujeiras, R.M. and Rodríguez-Casal, A. (2019). Mode testing, critical bandwidth and excess mass, Test, 28, 900–919.
Ameijeiras-Alonso, J., Crujeiras, R.M. and Rodríguez-Casal, A. (2021). multimode: An R Package for Mode Assessment, Journal of Statistical Software, 97, 1–32.
Cheng, M. Y. and Hall, P. (1998). Calibrating the excess mass and dip tests of modality, Journal of the Royal Statistical Society. Series B, 60, 579–589.
Fisher, N.I. and Marron, J. S. (2001). Mode testing via the excess mass estimate, Biometrika, 88, 419–517.
Hall, P. and York, M. (2001). On the calibration of Silverman's test for multimodality, Statistica Sinica, 11, 515–536.
Hartigan, J. A. and Hartigan, P. M. (1985). The Dip Test of Unimodality, Journal of the American Statistical Association, 86, 738–746.
Silverman, B. W. (1981). Using kernel density estimates to investigate multimodality, Journal of the Royal Statistical Society. Series B, 43, 97–99.
1 2 3 4 5 6 7 8 9 10 11 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.