estimate_densities_pval: Estimate parameters under the alternative density

Description Usage Arguments Details Value

View source: R/density_estimation.R

Description

Estimate the parameters of the alternative density function using a mixture of chi-squared distributions of -2*log(P)-values.

Usage

1
estimate_densities_pval(pvals, alt_prop, method_moments = FALSE)

Arguments

pvals

vector of P-values.

alt_prop

proportion of P-values from the alternative density.

method_moments

logical, denoting whether to estimate scale and degree of freedom parameters using Method of Moments (TRUE) or optimization (FALSE).

Details

The function estimates densities under the null and under the alternative given a vector of P-values from test statistics and the marginal probability of coming from the alternative distribution. Under the null hypothesis, -2*log() transformed P-values follow a chi-squared distribution with 2 degrees of freedom. Under the alternative, the function assumes that the -2*log() transformed P-values follow a scaled chi-squared distribution with unknown scale parameter and unknown degrees of freedom.

When method_moments=TRUE, the two unknown parameters are estimated by using the first and second moments of the transformed P-values given the known proportion of alternatives (specified in alt_prop). The function solves a theoretical formula of the first and second moments as functions of the scale parameter and degrees of freedom. Note that the alternative density estimation may fail if alt_prop is small and method_moments=TRUE.

When method_moments=FALSE, the two unknown parameters are estimated by minimizing the differences between the P-values given the parameters and the nominal P-values based on each statistic's rank, using optimization algorithms.

Value

A list with the following elements:

chi_mix vector of -2*log(P)-values.
scaler estimated scaling factor for the alternative distribution.
df_alt estimated degrees of freedom for the alternative distribution.

kjgleason/primo documentation built on Sept. 7, 2021, 5:21 p.m.