Description Usage Arguments Value Examples
View source: R/mle_negbinomial.R
mle_negbinomial
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")
)
|
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'. |
list containing MLE of negative binomial distribution parameters r and p, assuming df$x ~ nbinom(r, p).
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.