bb_mle: Beta binomial maximum likelihood estimation (BB MLE)

View source: R/bb_mle.R

bb_mleR Documentation

Beta binomial maximum likelihood estimation (BB MLE)

Description

Maximum Likelihood Estimate (MLE) of Beta-Binomial (BB) model. Some details about this model can be found on the following tutorial https://rpubs.com/cakapourani/beta-binomial

Usage

bb_mle(x, w = NULL, n_starts = 10, lower_thresh = 0.001)

Arguments

x

An n x 2 data.table or matrix, where 1st column keeps total number of trials and 2nd column number of successes, n is the total number of samples.

w

Vector with initial values of alpha and beta, if NULL the method of moments is used to initialize them.

n_starts

Total number of restarts when optimisation fails.

lower_thresh

Threshold when to stop optimisation.

Value

A list with the following elements:

  • gamma: The overdispersion parameter. This is the most important parameter, since it tells us if and how much overdispersion we observe in the data that cannot be explained by the Binomial model.

  • mu: The mean parameter, i.e. success probability of the beta binomial.

  • alpha: Alpha parameter, when taking the different parametrisation of the BB.

  • beta: Beta parameter, when taking the different parametrisation of the BB.

  • is_conv: Logical, whether or not the optimisation converged.

  • lrt: The likelihood ratio test statistic, for testing whether the Binomial or the Beta-Binomial fit better the data.

  • chi2_test: The p-value from the Chi-squared test obtained from the LRT statistics.

  • Z_score: The Z score statistic proposed by Tarone (1979). Seems more stable than LRT, in test whether we have overdispersion in our data.

  • z_test: The p-value obtain from the Z-score statistic.

  • bb_ll: Beta binomial log likelihood (used internally to compute the LRT statistic and the BIC)

  • BIC_bb: The Bayes Information Criterion for beta binomial model

  • bin_ll: Binomial log likelihood (used internally to compute the LRT statistic and the BIC.)

  • BIC_bin|: The Bayes Information Criterion for binomial model

Author(s)

C.A.Kapourani C.A.Kapourani@ed.ac.uk

See Also

scmet, scmet_differential, scmet_hvf_lvf

Examples

# Extract data from a single Feature
x <- scmet_dt$Y[Feature == "Feature_1", c("total_reads", "met_reads")]
fit_mle <- bb_mle(x)

andreaskapou/scMET documentation built on June 1, 2022, 11:47 p.m.