mle_negbinomial: mle_negbinomial

Description Usage Arguments Value Examples

View source: R/mle_negbinomial.R

Description

mle_negbinomial

Usage

1
2
3
4
5
6
7
8
mle_negbinomial(
  df,
  eta = 0.001,
  lambda = 0.01,
  tol = 1e-04,
  maxIter = 10000,
  method = c("newton", "gdescent")
)

Arguments

df

data.frame object, containing at least column named 'x' containing non-negative integer values.

eta

positive numeric dampening parameter for Newton's method, gradient descent algorithm.

lambda

non-negative numeric regularization parameter.

tol

non-negative numeric tolerance parameter for exiting optimization algorithm.

maxIter

positive integer setting maximum number of iterations for optimization algorithm.

method

string controlling optimization method; default 'newton'.

Value

list containing MLE of negative binomial distribution parameters r and p, assuming df$x ~ nbinom(r, p).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Generate example data:
set.seed(31)
r = 4
p = 0.3

# Number of experiments, i.e. rows in df:
numexps = 10

# Filling df with pseudo data; note the requisite column 'x':
df = data.frame('x' = rnbinom(numexps, r, p))

# Generating maximum likelihood estimate (MLE) solution for r and p:
rp_fit = mle_negbinomial(df = df)

# Compare fitted values to known values:
cbind(c(r, p), c(rp_fit$r, rp_fit$p))

alexandercoulter/DHBayes documentation built on Dec. 19, 2021, 12:29 a.m.