DiscreteFDR (version 1.1)

kernel.DBR: Kernel functions for DBR

Description

Kernel functions that transform observed p-values or their support according to [DBR-lambda]. The output is used by DBR. Additionally, kernel.DBR.crit computes and returns the critical constants. The end user should not use them.

Usage

kernel.DBR.crit(msg = "", stepf, pv.numer, lambda, alpha, sorted.pv,
  bigMem = FALSE, verbose = TRUE)

kernel.DBR.fast(msg = "", stepf, pv.numer, lambda, bigMem = FALSE, verbose = TRUE)

Arguments

msg

a character string to be displayed if verbose=TRUE.

stepf

a list of the CDFs under the null hypothesis of each p-value.

pv.numer

a numeric vector. Contains all values of the p-values supports if we search for the critical constants. If not, contains only the observed p-values. Must be in increasing order.

lambda

a number strictly between 0 and 1. If lambda=NULL (by default), then lambda is chosen equal to alpha.

alpha

the target FDR level, a number strictly between 0 and 1.

sorted.pv

a vector of observed p-values, in increasing order.

bigMem

a boolean. If TRUE, the code uses matrixes and functions of the apply family as far as possible (faster for small number of hypotheses and support size, but slower otherwise due to memory management overhead). If FALSE, computations are done with for loops and chunks to conserve memory.

verbose

a boolean indicating if msg must be printed. Used when bigMem=TRUE, to print messages informing if in-memory computation was successful or if loops and chunks were used as fallback.

Value

For kernel.DBR.crit, a list which elements are:

crit.consts

critical constants

pval.transf

transformed p-values

m.lambda

last index of observed p-values such that max_i F_i(p) <= lambda, this needs to be passed to DBR to compute adjusted p-values).

For kernel.DBR.fast, a vector of transformed p-values.

Details

When computing critical constants, that is, when using kernel.DBR.crit, we still need to get transformed p-values to compute the adjusted p-values. Also, note that here the critical constants are computed by the kernel function and not by the principal function DBR, contrary to what happens with DBH. This is why sorted.pv is needed.

This version: 2018-02-20.

See Also

DBR, DiscreteFDR, kernel.DBH, DBH

Examples

Run this code
# NOT RUN {
X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1)
X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2)
N1 <- rep(148, 9)
N2 <- rep(132, 9)
Y1 <- N1-X1
Y2 <- N2-X2
df <- data.frame(X1,Y1,X2,Y2)
df
#Construction of the p-values and their support
df.formatted <- fisher.pvalues.support(counts = df, input = "noassoc")
raw.pvalues <- df.formatted$raw
pCDFlist <- df.formatted$support

m <- length(raw.pvalues)
alpha <- 0.05
lambda <- 0.05

#Compute the step functions from the supports
stepf <- build.stepfuns(pCDFlist)

#If not searching for critical constants, we use only the observed p-values
sorted.pvals <- sort(raw.pvalues)
y <- kernel.DBR.fast("", stepf, sorted.pvals, lambda)

#If searching for critical constants, we use (almost) the complete support
pv.list.all <- unique(sort(as.numeric(unlist(pCDFlist))))
# apply the shortcut drawn from Corollary 3, that is
# c.1 >= the effective critical value associated to min((1 - lambda) * alpha/m , lambda)
pv.list<-short.eff(pv.list.all, min((1 - lambda) * alpha/m , lambda) )
# then re-add the observed p-values (needed to compute the adjusted p-values),
# because we may have removed some of them the shortcut
pv.list <- sort(unique(c(pv.list, sorted.pvals)))
# compute transformed support
y <- kernel.DBR.crit("", stepf, pv.list, lambda, alpha, sorted.pvals)
crit.constants <- y$crit.consts
transformed.pvalues <- y$pval.transf
last.index <- y$m.lambda

# }

Run the code above in your browser using DataCamp Workspace