# bayes_weights: Bayes p-value weights In dobriban/pweight: P-Value Weighting

## Description

Computes the optimal Bayes p-value weights for multiple testing. Given estimated means `mu` and standard errors `sigma` of test statistics `T`, the weighting scheme optimizes the expected number of discoveries using `T` as test statistics in multiple testing at some specific level q.

## Usage

 `1` ```bayes_weights(mu, sigma, q) ```

## Arguments

 `mu` the estimated means, a vector of length J. `sigma` the standard errors, a positive vector of length J `q` level at which tests will be performed

## Details

Specifically, it is assumed that `T` are Gaussian with mean `eta`. One-sided tests of `eta>=0` against `eta<0` are conducted using the test statistics `T`. To optimize power, different levels are allocated to different tests. This is based on the prior information about `eta` in `mu,sigma`

For more details, see the paper "Optimal Multiple Testing Under a Gaussian Prior on the Effect Sizes", by Dobriban, Fortney, Kim and Owen, http://arxiv.org/abs/1504.02935

## Value

A list containing:

`w` - the optimal Bayes weights;

`lambda` - the dual certificate, normalizing constant produced by solving the optimization problem;

`q_star` - true value of q solved for;

`q_threshold` - maximal value of q for which problem can be solve exactly;

Other p.value.weighting: `exp_weights`; `iGWAS`; `spjotvoll_weights`
 ```1 2 3 4 5``` ```J <- 100 mu <- rnorm(J) sigma <- 1 * rep(1, J) q <- 0.05 / J res <- bayes_weights(mu, sigma, q) ```