Performs the mean distance goodness-of-fit test and the energy goodness-of-fit test of Poisson distribution with unknown parameter.

```
poisson.e(x)
poisson.m(x)
poisson.etest(x, R)
poisson.mtest(x, R)
poisson.tests(x, R, test="all")
```

The functions `poisson.m`

and `poisson.e`

return the test statistics. The function
`poisson.mtest`

or `poisson.etest`

return an `htest`

object containing

- method
Description of test

- statistic
observed value of the test statistic

- p.value
approximate p-value of the test

- data.name
replicates R

- estimate
sample mean

`poisson.tests`

returns "M-CvM test", "M-AD test" and "Energy test" results in a data frame with columns

- estimate
sample mean

- statistic
observed value of the test statistic

- p.value
approximate p-value of the test

- method
Description of test

which can be coerced to a `tibble`

.

- x
vector of nonnegative integers, the sample data

- R
number of bootstrap replicates

- test
name of test(s)

Maria L. Rizzo mrizzo@bgsu.edu and Gabor J. Szekely

Two distance-based tests of Poissonity are applied in `poisson.tests`

, "M" and "E". The default is to
do all tests and return results in a data frame.
Valid choices for `test`

are "M", "E", or "all" with
default "all".

If "all" tests, all tests are performed by a single parametric bootstrap computing all test statistics on each sample.

The "M" choice is two tests, one based on a Cramer-von Mises distance and the other an Anderson-Darling distance. The "E" choice is the energy goodness-of-fit test.

`R`

must be a positive integer for a test. If `R`

is missing or 0, a warning is printed but test statistics are computed (without testing).

The mean distance test of Poissonity (M-test) is based on the result that the sequence
of expected values E|X-j|, j=0,1,2,... characterizes the distribution of
the random variable X. As an application of this characterization one can
get an estimator \(\hat F(j)\) of the CDF. The test statistic
(see `poisson.m`

) is a Cramer-von Mises type of distance, with
M-estimates replacing the usual EDF estimates of the CDF:
$$M_n = n\sum_{j=0}^\infty (\hat F(j) - F(j\;; \hat \lambda))^2
f(j\;; \hat \lambda).$$

In `poisson.tests`

, an Anderson-Darling type of weight is also applied when `test="M"`

or `test="all"`

.

The tests are implemented by parametric bootstrap with
`R`

replicates.

An energy goodness-of-fit test (E) is based on the test statistic $$Q_n = n (\frac{2}{n} \sum_{i=1}^n E|x_i - X| - E|X-X'| - \frac{1}{n^2} \sum_{i,j=1}^n |x_i - x_j|, $$ where X and X' are iid with the hypothesized null distribution. For a test of H: X ~ Poisson(\(\lambda\)), we can express E|X-X'| in terms of Bessel functions, and E|x_i - X| in terms of the CDF of Poisson(\(\lambda\)).

If test=="all" or not specified, all tests are run with a single parametric bootstrap. `poisson.mtest`

implements only the Poisson M-test with Cramer-von Mises type distance. `poisson.etest`

implements only the Poisson energy test.

Szekely, G. J. and Rizzo, M. L. (2004) Mean Distance Test of Poisson Distribution, *Statistics and Probability Letters*,
67/3, 241-247. tools:::Rd_expr_doi("10.1016/j.spl.2004.01.005").

Szekely, G. J. and Rizzo, M. L. (2005) A New Test for
Multivariate Normality, *Journal of Multivariate Analysis*,
93/1, 58-80,
tools:::Rd_expr_doi("10.1016/j.jmva.2003.12.002").

```
x <- rpois(50, 2)
poisson.m(x)
poisson.e(x)
# \donttest{
poisson.etest(x, R=199)
poisson.mtest(x, R=199)
poisson.tests(x, R=199)
# }
```

Run the code above in your browser using DataLab