View source: R/knn_mixture_test.R
mixture.test | R Documentation |
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
.
mixture.test(X0, Xm, alpha = 1, alternative = "lower", conf.level = 0.95,
k = 1, sub_sample = 1/4, seed_ = 1, calc.CI = TRUE)
X0 |
numeric matrix with rows beeing data points from a sample from |
Xm |
numeric matrix with rows beeing data points from a sample from |
alpha |
numeric value of the fraction of |
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 |
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. |
F_m=\alpha F_0 + (1-\alpha) F_1
thus f_m=\alpha f_0 + (1-\alpha) f_1
,
f_1 >=0
thus f_m >= \alpha f_0
... TODO: finish explaination
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.