Score function, hessian, mean, and variance for the binomial distribution with parameters prob and size.
Usage
sbinom(x, prob, size, parameter = "prob", drop = TRUE)
hbinom(x, prob, size, parameter = "prob", drop = TRUE)
mean_binom(prob, size, drop = TRUE)
var_binom(prob, size, drop = TRUE)
Arguments
x
vector of quantiles.
prob
probability of success on each trial.
size
number of trials (zero or more).
parameter
character. Derivatives are computed wrt this paramter. Note: Only “prob” is implemented.
drop
logical. Should the result be a matrix (drop = FALSE) or should the dimension be dropped (drop = TRUE, the default)?
Details
The binomial distribution with size\(= n\) and prob\(= p\) has density
\(p(x) = {n \choose x} {p}^{x} {(1-p)}^{n-x}\)
for \(x = 0, \ldots, n\).
The score function is
\(s(p) = \frac{x}{p} - \frac{n-x}{1-p}\)
The hessian is
\(h(p) = - \frac{x}{p^2} - \frac{n-x}{(1-p)^2}\)
Value
sbinom gives the score function, i.e., the 1st derivative of the log-density wrt prob and hbinom gives the hessian, i.e., the 2nd derivative of the log-density wrt prob. mean and var give the mean and variance, respectively.
See Also
Binomial encompassing dbinom, pbinom, qbinom and rbinom.