Learn R Programming

gtx (version 0.0.8)

abf.t: Calculate approximate Bayes factor (ABF) for t distribution prior.

Description

Calculates an approximation to the Bayes Factor for an alternative model where the parameter beta is a priori t distributed, by approximating the likelihood function with a normal distribution.

Usage

abf.t(beta, se, priorscale, df = 1, gridrange = 3, griddensity = 20)

Arguments

beta
Vector of effect size estimates.
se
Vector of associated standard errors.
priorscale
Scalar specifying the scale (standard deviation) of the prior on true effect sizes.
df
Degrees of freedom for t distribution prior.
gridrange
Parameter controlling range of grid for numerical integration.
griddensity
Parameter controlling density of points in grid for numerical integration.

Value

A vector of approximate Bayes factors.

Details

This uses the same normal approximation for the likelihood function as “Bayes factors for genome-wide association studies: comparison with P-values” by John Wakeley, 2009, Genetic Epidemiology 33(1):79-86 at http://dx.doi.org/10.1002/gepi.20359. However, in contrast to that work, a t distribution is used for the prior, which means it is necessary to use a numerical algorithm to calculate the (approximate) Bayes factor.

Examples

Run this code
data(agtstats)
agtstats$pval <- with(agtstats, pchisq((beta/se.GC)^2, df = 1, lower.tail = FALSE))
max1 <- function(bf) return(bf/max(bf, na.rm = TRUE))
agtstats$BF.normal <- with(agtstats, max1(abf.Wakefield(beta, se.GC, 0.05)))
agtstats$BF.t <- with(agtstats, max1(abf.t(beta, se.GC, 0.0208)))
with(agtstats, plot(-log10(pval), log(BF.normal)))
with(agtstats, plot(-log10(pval), log(BF.t)))

Run the code above in your browser using DataLab