bbEstDisp {apeglm} | R Documentation |
Uses R's optimize
function to find the maximum likelihood
estimate of dispersion for a beta binomial distribution
(theta
for the dbetabinom
function in the
emdbook package). The counts, size, and beta are matrices,
such that each row could be treated as a beta-binomial GLM
problem.
bbEstDisp(success, size, x, beta, minDisp, maxDisp)
success |
the observed successes (a matrix) |
size |
the total trials (a matrix) |
x |
the design matrix, as many rows as columns of |
beta |
a matrix of MLE coefficients, as many rows as |
minDisp |
the minimum dispersion value |
maxDisp |
the maximum dispersion value |
a vector of estimated dispersions
library(emdbook) n <- 100 m <- 100 size <- matrix(rnbinom(n*m, mu=100, size=10),ncol=m) success <- matrix(rbetabinom(n*m, prob=.5, size=size, theta=100),ncol=m) x <- matrix(rep(1,m),ncol=1) beta <- matrix(rep(0,n),ncol=1) theta <- bbEstDisp(success, size, x, beta, 1, 500) summary(theta)