empirical_fdr: Calculate Empirical False Discovery Rate (FDR)

View source: R/pwutilityfunctions.R

empirical_fdrR Documentation

Calculate Empirical False Discovery Rate (FDR)

Description

This function computes the empirical false discovery rate (FDR) for a given set of p-values or similar scores, assuming a subset of indices represent true null hypotheses.

Usage

empirical_fdr(val, true_null_indices, ...)

Arguments

val

A numeric vector of p-values or test statistics.

true_null_indices

A numeric vector of indices indicating the positions in val that correspond to true null hypotheses.

...

Further arguments to order(); typically use decreasing = TRUE if supplying test statistics.

Details

The FDR is computed as the cumulative count of true nulls up to a given rank, divided by the rank itself. The function returns values sorted in ascending order.

Value

A numeric vector of FDR values corresponding to each threshold in the sorted val.

Examples

set.seed(123)
val <- runif(10)  # Generate 10 random uniform values
true_null_indices <- c(3, 6, 8)  # Indices of true nulls
empirical_fdr(val, true_null_indices)


powestermark/pwrutilities documentation built on Dec. 28, 2024, 4:44 a.m.