zero.excess: Test for zero-excess in Count Regression Models

View source: R/overglm3.R

zero.excessR Documentation

Test for zero-excess in Count Regression Models

Description

Allows to assess if the observed number of zeros is significantly higher than expected according to the fitted count regression model (poisson or negative binomial).

Usage

zero.excess(object, verbose = TRUE)

Arguments

object

an object of the class glm, for poisson regression models, or an object of the class overglm, for negative binomial regression models.

verbose

an (optional) logical switch indicating if should the report of results be printed. By default, verbose is set to be TRUE.

Details

According to the formulated count regression model, we have that Y_k\sim P(y;\mu_k,\phi) for k=1,\ldots,n are independent random variables. Then, the expected number of zeros is the sum of P(0;\hat{\mu}_k,\hat{\phi}) for k=1,\ldots,n, where \hat{\mu}_k and \hat{\phi} represent the estimates of \mu_k and \phi, respectively, obtained from the fitted model. Thus, the test statistic reduces to the standardized difference between the observed and expected number of zeros. The distribution of that statistic, under the null hypothesis, tends to be the standard normal when the sample size, n, tends to infinity.

Value

A matrix with 1 row and the following columns:

Observed the observed number of zeros,
Expected the expected number of zeros,
z-value the value of the statistical test,
Pr(>z) the p-value of the statistical test.

See Also

overglm, zeroinf

Examples

####### Example 1: Self diagnozed ear infections in swimmers
data(swimmers)
fit1 <- glm(infections ~ frequency + location, family=poisson, data=swimmers)
zero.excess(fit1)
fit2 <- overglm(infections ~ frequency + location, family="nb1", data=swimmers)
zero.excess(fit2)

####### Example 2: Article production by graduate students in biochemistry PhD programs
bioChemists <- pscl::bioChemists
fit1 <- glm(art ~ fem + kid5 + ment, family=poisson, data = bioChemists)
zero.excess(fit1)
fit2 <- overglm(art ~ fem + kid5 + ment, family="nb1", data = bioChemists)
zero.excess(fit2)
####### Example 3: Roots Produced by the Columnar Apple Cultivar Trajan
data(Trajan)
fit1 <- glm(roots ~ photoperiod, family=poisson, data=Trajan)
zero.excess(fit1)
fit2 <- overglm(roots ~ photoperiod, family="nbf", data=Trajan)
zero.excess(fit2)


glmtoolbox documentation built on Oct. 10, 2023, 9:06 a.m.