Title: | An Empirical Model for Underdispersed Count Data |
---|---|
Description: | Count regression models for underdispersed small counts (lambda < 20) based on the three-parameter exponentially weighted Poisson distribution of Ridout & Besbeas (2004) <DOI:10.1191/1471082X04st064oa>. |
Authors: | Philipp Boersch-Supan [aut, cre]
|
Maintainer: | Philipp Boersch-Supan <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-20 04:46:06 UTC |
Source: | https://github.com/pboesu/ewp |
Extract coefficients
## S3 method for class 'ewp' coef(object, ...)
## S3 method for class 'ewp' coef(object, ...)
object |
an object of class ewp |
... |
ignored |
a vector of coefficient values. Beware that the lambda parameters are on the log-link scale, whereas the betas are estimated using an identity link.
Probability mass function of the three-parameter EWP
dewp3(x, lambda, beta1, beta2, sum_limit = max(x) * 3)
dewp3(x, lambda, beta1, beta2, sum_limit = max(x) * 3)
x |
vector of (positive integer) quantiles. |
lambda |
centrality parameter |
beta1 |
lower-tail dispersion parameter |
beta2 |
upper tail dispersion parameter |
sum_limit |
summation limit for the normalizing factor |
a vector of probabilities
Probability mass function of the three-parameter EWP
dewp3_cpp(x, lambda, beta1, beta2, sum_limit)
dewp3_cpp(x, lambda, beta1, beta2, sum_limit)
x |
vector of (positive integer) quantiles. |
lambda |
centrality parameter |
beta1 |
lower-tail dispersion parameter |
beta2 |
upper tail dispersion parameter |
sum_limit |
summation limit for the normalizing factor |
a probability mass
Exponentially weighted Poisson regression model
ewp_reg( formula, family = "ewp3", data, verbose = TRUE, method = "Nelder-Mead", hessian = TRUE, autoscale = TRUE, maxiter = 5000, sum_limit = round(max(Y) * 3) )
ewp_reg( formula, family = "ewp3", data, verbose = TRUE, method = "Nelder-Mead", hessian = TRUE, autoscale = TRUE, maxiter = 5000, sum_limit = round(max(Y) * 3) )
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
family |
choice of "ewp2" or "ewp3" |
data |
a data frame containing the variables in the model. |
verbose |
logical, defaults to TRUE; print model fitting progress |
method |
string, passed to optim, defaults to 'BFGS' |
hessian |
logical, defaults to TRUE; calculate Hessian? |
autoscale |
logical, defaults to TRUE; automatically scale model parameters inside the optimisation routine based on initial estimates from a Poisson regression. |
maxiter |
numeric, maximum number of iterations for optim |
sum_limit |
numeric, defaults to 3*maximum count; upper limit for the sum used for the normalizing factor. |
an ewp model
Extract fitted values
## S3 method for class 'ewp' fitted(object, ...)
## S3 method for class 'ewp' fitted(object, ...)
object |
an object of class ewp |
... |
ignored |
a vector of fitted values on the response scale
A dataset containing the clutch sizes for linnet, recreated from Ridout & Besbeas 2004
linnet
linnet
A data frame with 5414 rows and 3 variables:
clutch size
a synthetic random noise covariate
a synthetic covariate that is positively correlated with the outcome
Ridout & Besbeas 2004, P. Boersch-Supan
Extract log likelihood
## S3 method for class 'ewp' logLik(object, ...)
## S3 method for class 'ewp' logLik(object, ...)
object |
an object of class ewp |
... |
ignored |
a numeric
Predict from fitted model
## S3 method for class 'ewp' predict(object, newdata, type = c("response"), na.action = na.pass, ...)
## S3 method for class 'ewp' predict(object, newdata, type = c("response"), na.action = na.pass, ...)
object |
ewp model object |
newdata |
optional data.frame |
type |
character; default="response", no other type implemented |
na.action |
defaults to na.pass() |
... |
ignored |
a vector of predictions
Print ewp model object
## S3 method for class 'ewp' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'ewp' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
ewp model object |
digits |
digits to print |
... |
ignored |
a summary printout of the ewp model call and fitted coefficients.
Print ewp model summary
## S3 method for class 'summary.ewp' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'summary.ewp' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
ewp model summary |
digits |
number of digits to print |
... |
additional arguments to printCoefmat() |
printout of the summary object
Random samples from the three-parameter EWP
rewp3(n, lambda, beta1, beta2, sum_limit = 30)
rewp3(n, lambda, beta1, beta2, sum_limit = 30)
n |
number of observations |
lambda |
centrality parameter |
beta1 |
lower-tail dispersion parameter |
beta2 |
upper tail dispersion parameter |
sum_limit |
summation limit for the normalizing factor |
random deviates from the EWP_3 distribution
simulate from fitted model
## S3 method for class 'ewp' simulate(object, nsim = 1, ...)
## S3 method for class 'ewp' simulate(object, nsim = 1, ...)
object |
ewp model object |
nsim |
number of response vectors to simulate. Defaults to 1. |
... |
ignored |
a data frame with 'nsim' columns.
Model summary
## S3 method for class 'ewp' summary(object, ...)
## S3 method for class 'ewp' summary(object, ...)
object |
ewp model fit |
... |
ignored |
The function 'summary.ewp' computes and returns a list of summary statistics of the fitted ewp model.
Extract estimated variance-covariance matrix
## S3 method for class 'ewp' vcov(object, ...)
## S3 method for class 'ewp' vcov(object, ...)
object |
an object of class ewp |
... |
ignored |
a matrix