fpois | R Documentation |
Fit a homogeneous Poisson to data and test whether or not the mean and variance are equal.
fpois(x, na.action = na.fail, ...)
## Default S3 method:
fpois(x, na.action = na.fail, ...)
## S3 method for class 'data.frame'
fpois(x, na.action = na.fail, ..., which.col = 1)
## S3 method for class 'matrix'
fpois(x, na.action = na.fail, ..., which.col = 1)
## S3 method for class 'list'
fpois(x, na.action = na.fail, ..., which.component = 1)
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. |
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.
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). |
Eric Gilleland
glm
data(Rsum)
fpois(Rsum$Ct)
## Not run:
# 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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.