Poisson-extensions {countreg} | R Documentation |
Score function, hessian, mean, and variance
for the Poisson distribution
with parameter lambda
.
spois(x, lambda, parameter = "lambda", drop = TRUE) hpois(x, lambda, parameter = "lambda", drop = TRUE) mean_pois(lambda, drop =TRUE) var_pois(lambda, drop =TRUE)
x |
vector of quantiles. |
lambda |
vector of (non-negative) means. |
parameter |
character. Derivatives are computed wrt this
paramter. Note: Only |
drop |
logical. Should the result be a matrix ( |
The Poisson distribution has density
p(x) = λ^x exp(-λ)/x!
for x = 0, 1, 2, … .
The score function is
s(lambda) = x/lambda - 1
The hessian is
h(lambda) = - x/lambda^2
spois
gives the score function, i.e., the 1st
derivative of the log-density wrt lambda and
hpois
gives the hessian, i.e., the 2nd
derivative of the log-density wrt lambda.
mean
and var
give the mean and
variance, respectively.
Poisson encompassing dpois
, ppois
,
qpois
and rpois
.
## Simulate some data set.seed(123) y <- rpois(50, lambda = 3) ## Plot log-likelihood function par(mfrow = c(1,3)) ll <- function(x) {sum(dpois(y, x, log = TRUE))} curve(sapply(x, ll), 1, 5, xlab = expression(lambda), ylab = "", main = "Log-likelihood") abline(v = 3, lty = 3) ## Plot score function curve(sapply(x, function(x) sum(spois(y, x))), 1, 5, xlab = expression(lambda), ylab = "", main = "Score") abline(h = 0, lty = 3) abline(v = 3, lty = 3) ## Plot hessian curve( sapply(x, function(x) sum(hpois(y, x))), 1, 5, xlab = expression(lambda), ylab = "", main = "Hessian") abline(v = 3, lty = 3)