BEAST.null.simu {BET}R Documentation

BEAST Null Distribution

Description

BEAST.null.simu gives a vector of the null distribution of the BEAST statistic.

Usage

BEAST.null.simu(
  n,
  p,
  dep,
  subsample.percent = 1/2,
  B = 100,
  lambda = NULL,
  index = list(c(1:p)),
  method = "p",
  num = NULL
)

Arguments

n

sample size.

p

dimension.

dep

depth of the binary expansion.

subsample.percent

sample size for subsampling.

B

times of subsampling.

lambda

tuning parameter for soft-thresholding, default to be sqrt(log(2^(p * dep)) / (8*n)).

index

a list of indices. If provided, test the independence among two or more groups of variables. For example, index = list(c(1,2), c(3))) refers to test the independence between (X_1, X_2) and X_3. Default to be list(c(1:p)) to test if the data follow the uniform distribution over [0,1]^p, where p = ncol(X).

method

If "p", then compute null distribution with permutations. If "s", then compute null distribution with simulations.

num

number of permutations if method == "p" (default to be 100), or simulations if method == "s" (default to be 1000).

Value

BEAST.null.simu returns a vector of length num.permutations that simulates the null distribution of the BEAST for given sample size n, dimension p, and depth D

Examples

## Elapsed times 2.4 secs
## Measured in R 4.0.2, 32 bit, on a processor 3.3 GHz 6-Core Intel Core i5 under MacOS, 2021/5/30.
## Not run: BEAST.null.simu(128, 2, 3)

## power study example
## Elapsed times 36.8 secs
## Measured in R 4.0.2, 32 bit, on a processor 3.3 GHz 6-Core Intel Core i5 under MacOS, 2021/5/30.
## Not run: 
nperm = 100
nsim = 1000
BEAST.res = rep(0, nsim)
## simulate null distribution: only need once
BEAST.null.dist = BEAST.null.simu(128, 3, 3, index = list(c(1,2), c(3)), num = nperm)
for(i in 1:nsim){
  x1 = runif(128)
  x2 = runif(128)
  y = sin(4*pi*(x1 + x2)) + 0.8*rnorm(128)
  BEAST.stat = BEAST(cbind(x1, x2, y), 3, index = list(c(1,2), c(3)),
    method = "stat")$BEAST.Statistic
  BEAST.pvalue = sum(BEAST.null.dist >= BEAST.stat) / nperm
  BEAST.res[i] = BEAST.pvalue
}
## compute power
level = 0.1
power = mean(BEAST.res < level)


## End(Not run)



[Package BET version 0.5.3 Index]