Description Usage Arguments Value References Examples
Performs a permutation test of independence between two univariate continuous random variables, using the Fourier basis to construct the test statistic, as described in \insertCiteBKS2020USP.
1 | USPFourier(x, y, M, B = 999, ties.method = "standard", nullstats = FALSE)
|
x |
A vector containing the first sample, with each entry in [0,1]. |
y |
A vector containing the second sample, with each entry in [0,1]. |
M |
The maximum frequency to use in the Fourier basis. |
B |
The number of permutation to use when calibrating the test. |
ties.method |
If "standard" then calculate the p-value as in (5) of \insertCiteBKS2020USP, which is slightly conservative. If "random" then break ties randomly. This preserves Type I error control. |
nullstats |
If TRUE, returns a vector of the null statistic values. |
Returns the p-value for this independence test and the value of the test statistic, D_n, as defined in \insertCiteBKS2020USP. If nullstats=TRUE is used, then the function also returns a vector of the null statistics.
BKS2020USP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | x=runif(10); y=x^2
USPFourier(x,y,1,999)
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)
USPFourier(x,y,2,999)
x=runif(100); y=runif(100)
test=USPFourier(x,y,3,999,nullstats=TRUE)
plot(density(test$NullStats,from=min(test$NullStats),to=max(max(test$NullStats),test$TestStat)),
xlim=c(min(test$NullStats),max(max(test$NullStats),test$TestStat)),main="Test Statistics")
abline(v=test$TestStat,col=2); TestStats=c(test$TestStat,test$NullStats)
abline(v=quantile(TestStats,probs=0.95),lty=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.