mle_binomial: mle_binomial

Description Usage Arguments Value Examples

View source: R/mle_binomial.R

Description

mle_binomial

Usage

1

Arguments

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)

Value

MLE of binomial distribution parameter p, assuming df$x ~ binom(p, df$n).

Examples

 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)

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