Description Usage Arguments Value Examples
mle_binomial
1 |
df |
data.frame object, containing at least columns named 'x' containing non-negative integer values (number of successes), and 'n' containing non-negative integer values (number of trials) |
MLE of binomial distribution parameter p, assuming df$x ~ binom(p, df$n).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Generate example data:
set.seed(31)
p = 0.3
# Number of experiments, i.e. rows in df:
numexps = 10
# Filling df with pseudo data; note the requisite columns 'n' and 'x':
n = 5 + rpois(numexps, 10)
x = rbinom(numexps, n, p)
df = data.frame('n' = n, 'x' = x)
# Generating maximum likelihood estimate (MLE) solution for p:
p_fit = mle_binomial(df = df)
# Compare fitted values to known values:
cbind(p, p_fit)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.