Title: | Mixed Poisson Models |
---|---|
Description: | The estimation of the parameters in mixed Poisson models. |
Authors: | Alicja Wolny-Dominiak and Michal Trzesiok |
Maintainer: | Alicja Wolny-Dominiak <[email protected]> |
License: | GPL-2 |
Version: | 2.0 |
Built: | 2024-12-14 06:35:27 UTC |
Source: | CRAN |
The package provides functions, which support to fit parameters of different mixed Poisson models using the Expectation-Maximization (EM) algorithm of estimation, cf. (Ghitany et al., 2012, pp. 6848). In the model the assumptions are: conditional is of distribution
, parameter
is a random variable distributed according to the density function
,
and
– the regression component. The E-step is carried out through the numerical integration using Laquerre quadrature. The M-step estimates the parameters
using GLM Poisson with pseudo values from E-step and mixing parameters using optimize function.
Package: | MixedPoisson |
Type: | Package |
Version: | 1.0 |
Date: | 2015-07-13 |
License: | GPL-2 |
Alicja Wolny-Dominiak and Michal Trzesiok
Maintainer: <[email protected]>
Karlis, D. (2005). EM algorithm for mixed Poisson and other discrete distributions. Astin Bulletin, 35(01), 3-24. Ghitany, M. E., Karlis, D., Al-Mutairi, D. K., & Al-Awadhi, F. A. (2012). An EM algorithm for multivariate mixed Poisson regression models and its application. Applied Mathematical Sciences, 6(137), 6843-6856.
The function estimates the value of the parameter delta using .
est.delta(t)
est.delta(t)
t |
the vector of values |
The form of the distribution is as in the function
nu |
the estimates of |
ll.delta.max |
the value of loglikehood |
Michal Trzesiok
est.delta(t=c(3,8))
est.delta(t=c(3,8))
The function estimates the value of the parameter gamma using .
est.gamma(t)
est.gamma(t)
t |
the vector of values |
The form of the distribution is as in the function
gamma |
the estimates of |
ll.gamma.max |
the value of loglikehood |
Michal Trzesiok
est.gamma(t=c(3,8))
est.gamma(t=c(3,8))
The function estimates the value of the parameter nu using .
est.nu(t)
est.nu(t)
t |
the vector of values |
The form of the distribution is as in the function
nu |
the estimates of |
ll.nu.max |
the value of loglikehood |
Michal Trzesiok
est.nu(t=c(3,8))
est.nu(t=c(3,8))
The function returns the vector of values of density function for of Gamma distribution with one parameter .
Gamma.density(theta, gamma.par)
Gamma.density(theta, gamma.par)
theta |
the vector of values |
gamma.par |
the parameter of Gamma distribution |
The pdf of Gamma is of the form
Gamma.density(theta , nu)
|
the density – the vector of values |
Michal Trzesiok
Gamma.density(c(2,3,5,4,6,7,4), 5)
Gamma.density(c(2,3,5,4,6,7,4), 5)
The function returns the vector of values of density function for of inverse-Gaussian distribution with one parameter .
invGauss.density(theta, delta)
invGauss.density(theta, delta)
theta |
the vector of values |
delta |
the parameter of inverse-Gaussian distribution |
The pdf of inverse-Gaussian is of the form
invGauss.density(theta , delta)
|
the density – the vector of values |
Michal Trzesiok
invGauss.density(c(2,3,5,4,6,7,6), 5)
invGauss.density(c(2,3,5,4,6,7,6), 5)
The function fits the GLM Poisson with given offset.
lambda_m_step(variable, X, offset)
lambda_m_step(variable, X, offset)
variable |
the vector of numbers |
X |
model matrix of the form |
offset |
offset in GLM Poisson |
It fits the GLM Poisson, where and the ofsset is given as the vector of the variable's length.
The results are used in M-step of EM algorithm, cf. [Karlis, 2012] pp. 6850.
lambda |
|
beta |
regressor parameters |
glm |
output of |
Alicja Wolny–Dominiak, Michal Trzesiok
set.seed(1234) variable=rpois(50,4) X=as.matrix(rep(1, length(variable))) t=pseudo_values(variable, mixing=c("invGauss"), lambda=4, delta=1, n=100) lambda_m_step(variable, X, offset=t$pseudo_values)
set.seed(1234) variable=rpois(50,4) X=as.matrix(rep(1, length(variable))) t=pseudo_values(variable, mixing=c("invGauss"), lambda=4, delta=1, n=100) lambda_m_step(variable, X, offset=t$pseudo_values)
The function fits the GLM Poisson without regressors.
lambda_start(variable, X)
lambda_start(variable, X)
variable |
the vector of numbers |
X |
model matrix of the form |
It fits the GLM Poisson, where .
The results are taken as the starting value of EM algorithm.
lambda |
|
beta |
regressor parameters |
glm |
output of |
Alicja Wolny–Dominiak, Michal Trzesiok
set.seed(1234) variable=rpois(50,4) X=as.matrix(rep(1, length(variable))) t=pseudo_values(variable, mixing=c("invGauss"), lambda=4, delta=1, n=100) lambda_m_step(variable, X, offset=t$pseudo_values)
set.seed(1234) variable=rpois(50,4) X=as.matrix(rep(1, length(variable))) t=pseudo_values(variable, mixing=c("invGauss"), lambda=4, delta=1, n=100) lambda_m_step(variable, X, offset=t$pseudo_values)
The function returns the value of log-likelihood function for of Gamma distribution with one parameter .
ll.gamma(gamma.par, t)
ll.gamma(gamma.par, t)
gamma.par |
|
t |
the vector of values |
The pdf of Gamma is of the form
ll.gamma |
the value |
Michal Trzesiok
ll.gamma(1, c(3,8))
ll.gamma(1, c(3,8))
The function returns the value of log-likelihood function for of inverse-Gaussian distribution with one parameter .
ll.invGauss(delta, t)
ll.invGauss(delta, t)
delta |
|
t |
the vector of values |
The pdf of inverse-Gaussian is of the form
ll.invGauss |
the value |
Michal Trzesiok
ll.invGauss(1, c(3,8))
ll.invGauss(1, c(3,8))
The function returns the value of log-likelihood function of log-normal distribution with one parameter .
ll.lognorm(nu, t)
ll.lognorm(nu, t)
nu |
|
t |
the vector of values |
The pdf of log-normal is of the form
ll.lognorm |
the value |
Michal Trzesiok
ll.lognorm(1, c(3,8))
ll.lognorm(1, c(3,8))
The function returns the vector of values of density function for of log-normal distribution with one parameter .
lognorm.density(theta, nu)
lognorm.density(theta, nu)
theta |
the vector of values |
nu |
the parameter of log-normal distribution |
The pdf of log-normal is of the form
lognorm.density(theta , nu)
|
the density – the vector of values |
Michal Trzesiok
lognorm.density(c(2,3,5,4,6,7,6), 5)
lognorm.density(c(2,3,5,4,6,7,6), 5)
The function fits a mixed Poisson distribution, in which the random parameter follows Gamma distribution (the negative-binomial distribution). As teh method of estimation Expectation-maximization algorithm is used. In M-step the analytical formulas taken from [Karlis, 2005] are applied.
pg.dist(variable, alpha.start, beta.start, epsylon)
pg.dist(variable, alpha.start, beta.start, epsylon)
variable |
The count variable. |
alpha.start |
The starting value of the parameter alpha. Default to 1. |
beta.start |
The starting value of the parameter beta. Default to 0.3 |
epsylon |
Default to epsylon = 10^(-8) |
This function provides estimated parameters of the model
where
parameter is also a random
variable follows Gamma distribution with hiperparameters
. The
pdf of Gamma is of the form
.
alpha |
the parameter of mixing Gamma distribution |
beta |
the parameter of mixing Gamma distribution |
theta |
the value 1/beta |
n.iter |
the number of steps in EM algorithm |
Karlis, D. (2005). EM algorithm for mixed Poisson and other discrete distributions. Astin bulletin, 35(01), 3-24.
library(MASS) pGamma1 = pg.dist(variable=quine$Days) print(pGamma1)
library(MASS) pGamma1 = pg.dist(variable=quine$Days) print(pGamma1)
The function fits a mixed Poisson distribution, in which the random parameter follows Lindley distribution. As teh method of estimation Expectation-maximization algorithm is used.
pl.dist(variable, p.start, epsylon)
pl.dist(variable, p.start, epsylon)
variable |
The count variable. |
p.start |
The starting value of p parameter. Default to 0.1. |
epsylon |
Default to epsylon = 10^(-8) |
This function provides estimated parameters of the model
where
parameter is also a random
variable follows Lindley distribution with hiperparameter
. The
pdf of Lindley is of the form
.
p |
the parameter of mixing Lindley distribution |
n.iter |
the number of steps in EM algorithm |
Karlis, D. (2005). EM algorithm for mixed Poisson and other discrete distributions. Astin bulletin, 35(01), 3-24.
library(MASS) pLindley = pl.dist(variable=quine$Days) print(pLindley)
library(MASS) pLindley = pl.dist(variable=quine$Days) print(pLindley)
The function returns the pseudo values defined as the conditional expectation
,
where
are realizations of the count variable N.
pseudo_values(variable, mixing, lambda, gamma.par, nu, delta, n)
pseudo_values(variable, mixing, lambda, gamma.par, nu, delta, n)
variable |
the vector of numbers |
mixing |
the name of mixing distribution – "Gamma", "lognorm", "invGauss" |
lambda |
|
gamma.par |
|
nu |
|
delta |
|
n |
The integer value for the Laguerre quadrature. Default to 100 |
The function calculates the vector of pseudo values in E-step of EM algorithm. It applies the numerical integration using
in the nominator and the denominator of the formula
The proper parameter ,
,
should be chosen according to the mixing distribution.
pseudo_values |
pseudo values |
nominator |
nominator in the formula |
denominator |
denominator in the formula |
Alicja Wolny–Dominiak, Michal Trzesiok
variable=rpois(30,4) pseudo_values(variable, mixing="Gamma", lambda=4, gamma.par=0.7, n=100)
variable=rpois(30,4) pseudo_values(variable, mixing="Gamma", lambda=4, gamma.par=0.7, n=100)