Learn R Programming

USP (version 0.1.2)

USPFourierAdapt: Adaptive permutation test of independence for continuous data.

Description

We implement the adaptive version of the independence test for univariate continuous data using the Fourier basis, as described in Section 4 of BKS2020USP. This applies USPFourier with a range of values of \(M\), and a properly corrected significance level.

Usage

USPFourierAdapt(x, y, alpha, B = 999, ties.method = "standard")

Arguments

x

The vector of data points from the first sample, each entry belonging to \([0,1]\).

y

The vector of data points from the second sample, each entry belonging to \([0,1]\).

alpha

The desired significance level of the test.

B

Controls the number of permutations to be used. With a sample size of \(n\) each test uses \(B \log_2 n\) permutations. If \(B+1 < 1/\alpha\) then it is not possible to reject the null hypothesis.

ties.method

If "standard" then calculate the p-value as in (5) of BKS2020USP, which is slightly conservative. If "random" then break ties randomly. This preserves Type I error control.

Value

Returns an indicator with value 1 if the null hypothesis of independence is rejected and 0 otherwise. If the null hypothesis is rejected, the function also outputs the value of \(M\) at the which the null was rejected and the value of the test statistic.

References

BKS2020USP

Examples

Run this code
# NOT RUN {
n=100; w=2; x=integer(n); y=integer(n); m=300
unifdata=matrix(runif(2*m,min=0,max=1),ncol=2); x1=unifdata[,1]; y1=unifdata[,2]
unif=runif(m); prob=0.5*(1+sin(2*pi*w*x1)*sin(2*pi*w*y1)); accept=(unif<prob);
Data1=unifdata[accept,]; x=Data1[1:n,1]; y=Data1[1:n,2]
plot(x,y)
USPFourierAdapt(x,y,0.05,999)
# }

Run the code above in your browser using DataLab