mixture.test: mixture.test

Description Usage Arguments Details Examples

View source: R/knn_mixture_test.R

Description

Tests against the true mixing coefficient of F_0 in the mixture F_m to be smaller than alpha using a knn statistic calculated from one sample from F0 and one sample from the mixture F_m.

Usage

1
2
mixture.test(X0, Xm, alpha = 1, alternative = "lower", conf.level = 0.95,
  k = 1, sub_sample = 1/4, seed_ = 1, calc.CI = TRUE)

Arguments

X0

numeric matrix with rows beeing data points from a sample from F_0. Vector inputs are coerced to nx1 matrices.

Xm

numeric matrix with rows beeing data points from a sample from F_m. Vector inputs are coerced to nx1 matrices.

alpha

numeric value of the fraction of F_0 in F_m that is tested against

alternative

a character string specifying the alternative hypothesis - only 'lower' is allowed and only lower makes sense

conf.level

confidence level of the interval.

k

integer value indicating the which nearest neighbour is used for the testing density ratios.

sub_sample

numeric value specifing factor subsamplamping – only n*sub_sample_exp of all n pvalues will be used in order to reduce their depency

seed_

seed to be used for subsampling. Set to NULL if want reduce variance by averaging several subsamplings.

calc.CI

logical value indicating if confidence intervals for alpha schould be computed. Can be turend of to save computation time in case it is not needed.

Details

F_m=α F_0 + (1-α) F_1 thus f_m=α f_0 + (1-α) f_1, f_1 >=0 thus f_m >= α f_0 ... TODO: finish explaination

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
n0 <- 100 # 100 sample points from \eqn{F_0}
nm <- 100 # 100 sample points from \eqn{F_0}
n1 <- 50  # of which 50 are from \eqn{F_1}
p <- 2    # two dimensions
X0 <- matrix(rnorm(n0*p), ncol=p) # \eqn{F_0} is standard normal, \eqn{F_1} has mean c(10,10):
Xm <- matrix(c(rnorm((nm-n1)*p), rnorm(n1*p)+10), ncol=p, byrow = TRUE)

mixture.test(X0, Xm, alpha=0.5, calc.CI=FALSE)$p.value #should not be significant
mixture.test(X0, Xm, alpha=1, calc.CI=FALSE)$p.value #should be significant
mixture.test(X0, Xm) # computes confidence intervals

jan-glx/knnDemix documentation built on Dec. 17, 2020, 1:24 p.m.