Learn R Programming

extRemes (version 2.1-3)

fpois: Fit Homogeneous Poisson to Data and Test Equality of Mean and Variance

Description

Fit a homogeneous Poisson to data and test whether or not the mean and variance are equal.

Usage

fpois(x, na.action = na.fail, ...)

# S3 method for default fpois(x, na.action = na.fail, ...)

# S3 method for data.frame fpois(x, na.action = na.fail, ..., which.col = 1)

# S3 method for matrix fpois(x, na.action = na.fail, ..., which.col = 1)

# S3 method for list fpois(x, na.action = na.fail, ..., which.component = 1)

Value

A list of class “htest” is returned with components:

statistic

The value of the dispersion D

parameter

named numeric vector giving the estimated mean, variance, and degrees of freedom.

alternative

character string with the value “greater” indicating the one-sided alternative hypothesis.

p.value

the p-value for the test.

method

character string stating the name of the test.

data.name

character naming the data used by the test (if a vector is applied).

Arguments

x

numeric, matrix, data frame or list object containing the data to which the Poisson is to be fit.

na.action

function to be called to handle missing values.

...

Not used.

which.col,which.component

column or component (list) number containing the data to which the Poisson is to be fit.

Author

Eric Gilleland

Details

The probability function for the (homogeneous) Poisson distribution is given by:

Pr( N = k ) = exp(-lambda) * lambda^k / k!

for k = 0, 1, 2, ...

The rate parameter, lambda, is both the mean and the variance of the Poisson distribution. To test the adequacy of the Poisson fit, therefore, it makes sense to test whether or not the mean equals the variance. R. A. Fisher showed that under the assumption that X_1, ..., X_n follow a Poisson distribution, the statistic given by:

D = (n - 1) * var(X_1) / mean(X_1)

follows a Chi-square distribution with n - 1 degrees of freedom. Therefore, the p-value for the one-sided alternative (greater) is obtained by finding the probability of being greater than D based on a Chi-square distribution with n - 1 degrees of freedom.

See Also

Examples

Run this code

data(Rsum)
fpois(Rsum$Ct)

if (FALSE) {

# Because 'Rsum' is a data frame object,
# the above can also be carried out as:

fpois(Rsum, which.col = 3)

# Or:

fpois(Rsum, which.col = "Ct")

##
## For a non-homogeneous fit, use glm.
##
## For example, to fit the non-homogeneous Poisson model
## Enso as a covariate:
##

fit <- glm(Ct~EN, data = Rsum, family = poisson())
summary(fit)
}

Run the code above in your browser using DataLab