Title: | Bivariate Poisson Distribution |
---|---|
Description: | Maximum likelihood estimation, random values generation, density computation and other functions for the bivariate Poisson distribution. References include: Kawamura K. (1984). "Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution". Kodai Mathematical Journal, 7(2): 211--221. <doi:10.2996/kmj/1138036908>. Kocherlakota S. and Kocherlakota K. (1992). "Bivariate discrete distributions". CRC Press. <doi:10.1201/9781315138480>. Karlis D. and Ntzoufras I. (2003). "Analysis of sports data by using bivariate Poisson models". Journal of the Royal Statistical Society: Series D (The Statistician), 52(3): 381--393. <doi:10.1111/1467-9884.00366>. |
Authors: | Michail Tsagris [aut, cre] |
Maintainer: | Michail Tsagris <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-12-12 06:45:24 UTC |
Source: | CRAN |
The Bivariate Poisson Distribution.
Package: | bivpois |
Type: | Package |
Version: | 1.0 |
Date: | 2023-10-18 |
License: | GPL-2 |
Michail Tsagris [email protected].
Michail Tsagris [email protected].
Kawamura K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai Mathematical Journal, 7(2): 211–221.
Kocherlakota S. and Kocherlakota K. (1998). Bivariate discrete distributions. Wiley Online Library.
Karlis D. and Ntzoufras I. (2003). Analysis of sports data by using bivariate poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3): 381–393.
Density computation of the bivariate Poisson distribution.
dbp(x1, x2 = NULL, lambda, logged = TRUE)
dbp(x1, x2 = NULL, lambda, logged = TRUE)
x1 |
Either a numerical vector with the values of the first variable or a matrix with 2 columns containing both variables. In the latter case, x2 must be NULL. |
x2 |
A numerical vector with the values of the second. If x1 is a matrix with 2 columns containing both variables, x2 must be NULL. |
lambda |
A vector with three numbers, the estimates of the |
logged |
Should the logarithm of the density values be computed? The default value is TRUE. |
The density of the bivariate Poisson distribution is computed.
A vector with the logged density values.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Kawamura K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai Mathematical Journal, 7(2): 211–221.
Kocherlakota S. and Kocherlakota K. (1992). Bivariate discrete distributions. CRC Press.
Karlis D. and Ntzoufras I. (2003). Analysis of sports data by using bivariate poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3): 381–393.
x <- rbp( 300, c(3, 5, 2) ) a <- bp.mle(x) f <- dbp(x, lambda = a$lambda) sum(f)
x <- rbp( 300, c(3, 5, 2) ) a <- bp.mle(x) f <- dbp(x, lambda = a$lambda) sum(f)
Goodness of fit test for the bivariate Poisson distribution.
bp.gof(x1, x2 = NULL, R = 999) bp.gof2(x1, x2 = NULL, R = 999)
bp.gof(x1, x2 = NULL, R = 999) bp.gof2(x1, x2 = NULL, R = 999)
x1 |
Either a numerical vector with the values of the first variable or a matrix with 2 columns containing both variables. In the latter case, x2 must be NULL. |
x2 |
A numerical vector with the values of the second. If x1 is a matrix with 2 columns containing both variables, x2 must be NULL. |
R |
The number of Monte Carlo replicates to use. |
Kocherlakota and Kocherlakota (1992) mention the following a goodness of fit test for the bivariate Poisson distribution, the index of dispersion test. They mention that Loukas and Kemp (1986) developed this test as an extension of the univariate dispersion test. They test for departures from the bivariate Poisson againsta alternatives which involve an increase in the generalised variance, the determinant of the covariance matrix of the two variables.
Rayner, Thas and Best (2009) mentions a revised version of this test whose test statistic is now given by
where is the sample size,
is the sample Pearson correlation coefficient,
and
are the two sample variances and
and
are the two sample means. Under the null hypothesis the
follows asymptotically a
with
degrees of freedom. However, I did some simulations and I saw that
it does not perform very well in terms of the type I error. If you see the simulations in their book
(page 132) you will see this. For this reason, the function calculates the p-value of the
using Monte Carlo (or parametric bootstrap).
The second function, bp.gof2(), is a vectorised version of the first, and much faster. I put both of them here to show how one can vectorize a function and make it faster.
A list including:
runtime |
The duration of the algorithm. |
tab |
The contingency table of the two variables. |
pvalue |
The Monte-Carlo based estimated p-value. |
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Kocherlakota S. and Kocherlakota K. (1992). Bivariate discrete distributions. CRC Press.
Loukas S. and Kemp C. (1986). The index of dispersion test for the bivariate Poisson distribution. Biometrics, 42(4): 941–948.
Rayner J. C., Thas O. and Best D. J. (2009). Smooth Tests of Goodness of Fit: Using R. John Wiley & Sons.
x <- rbp( 300, c(3, 5, 2) ) bp.gof(x) bp.gof2(x)
x <- rbp( 300, c(3, 5, 2) ) bp.gof(x) bp.gof2(x)
Maximum likelihood estimation of the bivariate Poisson distribution.
bp.mle(x1, x2 = NULL) bp.mle2(x1, x2 = NULL)
bp.mle(x1, x2 = NULL) bp.mle2(x1, x2 = NULL)
x1 |
Either a numerical vector with the values of the first variable or a matrix with 2 columns containing both variables. In the latter case, x2 must be NULL. |
x2 |
A numerical vector with the values of the second. If x1 is a matrix with 2 columns containing both variables, x2 must be NULL. |
Using the addition method (see function rbp
) to simulate random values from the bivariate Poisson, its representation is given by
The above form is found in Karlis and Ntzoufras (2003). This bivariate distribution allows for dependence between the two random variables. Marginally each random variable follows a Poisson distribution with and
. In addition,
. If
, the above expression becomes a product of two Poisson distributions. Hence,
is a measure of dependence between the two random variables.
The function bp.mle() returns a lot of information and is slower than bp.mle2(), which returns fewer information, but is faster.
For the function bp.mle() a list including:
lambda |
A vector with the estimated values of |
rho |
The estimated correlation coefficient, that is: |
ci |
The 95% Confidence intervals using the observed and the asymptotic information matrix. |
loglik |
The log-likelihood values assuming independence ( |
pvalue |
Three p-values for testing |
For the function bp.mle2() a list including:
lambda |
A vector with the estimated values of |
loglik |
The log-likelihood values assuming independence ( |
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Kawamura K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai Mathematical Journal, 7(2): 211–221.
Kocherlakota S. and Kocherlakota K. (1992). Bivariate discrete distributions. CRC Press.
Karlis D. and Ntzoufras I. (2003). Analysis of sports data by using bivariate poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3): 381–393.
x <- rbp( 300, c(3, 5, 2) ) bp.mle(x)
x <- rbp( 300, c(3, 5, 2) ) bp.mle(x)
) of the bivariate Poisson distribution
Profile likelihood of the covariance parameter () of the bivariate Poisson distribution.
lambda3.profile(x1, x2 = NULL)
lambda3.profile(x1, x2 = NULL)
x1 |
Either a numerical vector with the values of the first variable or a matrix with 2 columns containing both variables. In the latter case, x2 must be NULL. |
x2 |
A numerical vector with the values of the second. If x1 is a matrix with 2 columns containing both variables, x2 must be NULL. |
The function plots the profile log-likelihood of and computes the relevant 95% confidence interval for the parameter.
A plot with the profile log-likelihood of and a vector with the 95% confidence interval for the parameter.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Kawamura K. (1984). Direct calculation of maximum likelihood estimator for the bivariate Poisson distribution. Kodai Mathematical Journal, 7(2): 211–221.
Kocherlakota S. and Kocherlakota K. (1992). Bivariate discrete distributions. CRC Press.
Karlis D. and Ntzoufras I. (2003). Analysis of sports data by using bivariate poisson models. Journal of the Royal Statistical Society: Series D (The Statistician), 52(3): 381–393.
x <- rbp( 300, c(3, 5, 2) ) lambda3.profile(x)
x <- rbp( 300, c(3, 5, 2) ) lambda3.profile(x)
Random values generation from the bivariate Poisson distribution.
rbp(n, lambda)
rbp(n, lambda)
n |
The sample size. |
lambda |
A vector with the three parameters, |
In order to generate values from this distribution one needs three independent Poisson variables, ,
and
. Then,
.
A matrix with n rows and 2 columns.
Michail Tsagris.
R implementation and documentation: Michail Tsagris [email protected].
Kocherlakota S. and Kocherlakota K. (1992). Bivariate discrete distributions. CRC PRess.
x <- rbp( 300, c(3, 5, 2) ) bp.mle(x)
x <- rbp( 300, c(3, 5, 2) ) bp.mle(x)