Learn R Programming

logcondens (version 2.1.8)

logconTwoSample: Compute p-values for two-sample test based on log-concave CDF estimates

Description

Compute \(p\)-values for a test for the null hypothesis of equal CDFs of two samples. The test statistic is reminiscient of Kolmogorv-Smirnov's, but instead of computing it for the empirical CDFs, this function computes it based on log-concave estimates for the CDFs.

Usage

logconTwoSample(x, y, which = c("MLE", "smooth"), M = 999, 
    n.grid = 500, display = TRUE, seed0 = 1977)

Value

p.value

A two dimensional vector containing the \(p\)-values.

test.stat.orig

The test statistics for the original samples.

test.stats

A \(M \times 2\) matrix containing the test statistics for all the permutations.

Arguments

x

First data sample.

y

Second data sample.

which

Indicate for which type of estimate the test statistic should be computed.

M

Number of permutations.

n.grid

Number of grid points in computation of maximal difference between smoothed log-concave CDFs. See maxDiffCDF for details.

display

If TRUE progress of computations is shown.

seed0

Set seed to reproduce results.

Warning

Note that the algorithm that finds the maximal difference for the smoothed estimate is of approximative nature only. It may fail for very large sample sizes.

Details

Given two i.i.d. samples \(x_1, \ldots, x_{n_1}\) and \(y_1, \ldots, y_{n_2}\) this function computes a permutation test \(p\)-value that provides evidence against the null hypothesis

$$H_0 : F_1 = F_2$$

where \(F_1, F_2\) are the CDFs of the samples, respectively. A test either based on the log-concave MLE or on its smoothed version (see Duembgen and Rufibach, 2009, Section 3) are provided. Note that computation of the smoothed version takes considerably more time.

References

Duembgen, L. and Rufibach, K. (2009) Maximum likelihood estimation of a log--concave density and its distribution function: basic properties and uniform consistency. Bernoulli, 15(1), 40--68.

Duembgen, L. and Rufibach, K. (2011) logcondens: Computations Related to Univariate Log-Concave Density Estimation. Journal of Statistical Software, 39(6), 1--28. tools:::Rd_expr_doi("https://doi.org/10.18637/jss.v039.i06")

Examples

Run this code
if (FALSE) {
n1 <- 30
n2 <- 25
x <- rgamma(n1, 2, 1)
y <- rgamma(n2, 2, 1) + 1
twosample <- logconTwoSample(x, y, which = c("MLE", "smooth")[1], M = 999)
}

Run the code above in your browser using DataLab