estimateAB: estimateAB

Description Usage Arguments Details Examples

Description

This function fits the alpha (a) and beta (b) parameters for the inverse gamma distribution of variance by maximum likelihood estimation. The log likelihood is calculated by the flik function.

Usage

1
estimateAB(variance, n)

Arguments

variance

A vector of observed variances

n

A vector of degrees of fredom for each observed variance (number of observations - 1)

Details

Reference: Wright, G. W., & Simon, R. M. (2003). A random variance model for detection of differential gene expression in small microarray experiments. Bioinformatics, 19(18), 2448–2455. doi:10.1093/bioinformatics/btg345

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- data.frame(true.var = 1 / rgamma(100000, 30, 3100))
x$obs.1 <- sapply(x$true.var, function(x) rnorm(1, 0, sqrt(x)))
x$obs.2 <- sapply(x$true.var, function(x) rnorm(1, 0, sqrt(x)))
x$obs.var <- apply(x[, c('obs.1', 'obs.2')], 1, var)
x$degf <- 1
x.ab <- estimateAB(x$obs.var, x$degf)
hist(x$true.var, freq=FALSE)
library(MCMCpack)
prediction <- dinvgamma(50:200, x.ab[1], x.ab[2])
lines(x=50:200, y=prediction)

BenjaminChittick/BenCScore documentation built on May 5, 2019, 2:41 p.m.