bbdml: Maximum Likelihood for the Beta-binomial Distribution

View source: R/bbdml.R

bbdmlR Documentation

Maximum Likelihood for the Beta-binomial Distribution

Description

Maximum Likelihood for the Beta-binomial Distribution

Usage

bbdml(
  formula,
  phi.formula,
  data,
  link = "logit",
  phi.link = "logit",
  method = "trust",
  control = list(maxit = 1000, reltol = 1e-14),
  numerical = FALSE,
  nstart = 1,
  inits = NULL,
  ...
)

Arguments

formula

an object of class formula: a symbolic description of the model to be fitted to the abundance

phi.formula

an object of class formula without the response: a symbolic description of the model to be fitted to the dispersion

data

a data frame or phyloseq object containing the variables in the models

link

link function for abundance covariates, defaults to "logit"

phi.link

link function for dispersion covariates, defaults to "logit"

method

optimization method, defaults to "trust", or see optimr for other options

control

optimization control parameters (see optimr)

numerical

Boolean. Defaults to FALSE. Indicator of whether to use the numeric Hessian (not recommended).

nstart

Integer. Defaults to 1. Number of starts for optimization.

inits

Optional initializations as rows of a matrix. Defaults to NULL.

...

Optional additional arguments for optimr or trust

Value

An object of class bbdml.

Examples

# phyloseq example
data(soil_phylum_small)
bbdml(formula = OTU.1 ~ DayAmdmt,
phi.formula = ~ DayAmdmt,
data = soil_phylum_small)

# data frame example
seq_depth <- rpois(20, lambda = 10000)
my_counts <- rbinom(20, size = seq_depth, prob = 0.001) * 10
my_covariate <- cbind(rep(c(0,1), each = 10))
colnames(my_covariate) <- c("X1")
example_data <- data.frame("W" = my_counts, "M" = seq_depth, my_covariate)
bbdml(formula = cbind(W, M - W) ~ X1,
phi.formula = ~ X1,
data = example_data)


corncob documentation built on Aug. 31, 2023, 9:06 a.m.