| Type: | Package | 
| Title: | Mixed Poisson Models | 
| Version: | 2.0 | 
| Date: | 2016-11-24 | 
| Author: | Alicja Wolny-Dominiak and Michal Trzesiok | 
| Maintainer: | Alicja Wolny-Dominiak <alicja.wolny-dominiak@ue.katowice.pl> | 
| Depends: | gaussquad, Rmpfr, MASS | 
| Description: | The estimation of the parameters in mixed Poisson models. | 
| License: | GPL-2 | 
| NeedsCompilation: | no | 
| Packaged: | 2016-12-08 21:36:11 UTC; Micha<c5><82> | 
| Repository: | CRAN | 
| Date/Publication: | 2016-12-09 08:58:43 | 
Mixed Poisson Models
Description
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 N|\theta is of distribution N|\theta \sim POIS(\lambda\theta), parameter \theta is a random variable distributed according to the density function f_{\theta}(\cdot), E[\theta]=1 and \lambda=\exp(\mathbf{x}_{i}'\mathbf{\boldsymbol \beta}) – the regression component. The E-step is carried out through the numerical integration using Laquerre quadrature. The M-step estimates the parameters \beta using GLM Poisson with pseudo values from E-step and mixing parameters using optimize function.
Details
| Package: | MixedPoisson | 
| Type: | Package | 
| Version: | 1.0 | 
| Date: | 2015-07-13 | 
| License: | GPL-2 | 
Author(s)
Alicja Wolny-Dominiak and Michal Trzesiok
Maintainer: <alicja.wolny-dominiak@ue.katowice.pl>
References
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.
Gamma density
Description
The function returns the vector of values of density function for of Gamma distribution with one parameter \gamma.
Usage
Gamma.density(theta, gamma.par)
Arguments
| theta | the vector of values | 
| gamma.par | the parameter of Gamma distribution | 
Details
The pdf of Gamma is of the form 
f_\theta(\theta)=\frac{\gamma^\gamma}{\Gamma(\gamma)}\theta^{\gamma-1}\exp(-\gamma\theta) 
Value
| Gamma.density(theta,nu) | the density – the vector of values | 
Author(s)
Michal Trzesiok
Examples
Gamma.density(c(2,3,5,4,6,7,4), 5)Estimation of delta parameter of inverse-Gaussian distribution
Description
The function estimates the value of the parameter delta using \texttt{optimize}.
Usage
est.delta(t)
Arguments
| t | the vector of values | 
Details
The form of the distribution is as in the function \texttt{ll.invGauss}
Value
| nu | the estimates of  | 
| ll.delta.max | the value of loglikehood | 
Author(s)
Michal Trzesiok
Examples
est.delta(t=c(3,8))Estimation of gamma parameter of Gamma distribution
Description
The function estimates the value of the parameter gamma using \texttt{optimize}.
Usage
est.gamma(t)
Arguments
| t | the vector of values | 
Details
The form of the distribution is as in the function \texttt{ll.gamma}
Value
| gamma | the estimates of  | 
| ll.gamma.max | the value of loglikehood | 
Author(s)
Michal Trzesiok
Examples
est.gamma(t=c(3,8))Estimation of nu parameter of log-normal distribution
Description
The function estimates the value of the parameter nu using \texttt{optimize}.
Usage
est.nu(t)
Arguments
| t | the vector of values | 
Details
The form of the distribution is as in the function \texttt{ll.lognorm}
Value
| nu | the estimates of  | 
| ll.nu.max | the value of loglikehood | 
Author(s)
Michal Trzesiok
Examples
est.nu(t=c(3,8))inverse-Gaussian Density
Description
The function returns the vector of values of density  function for of inverse-Gaussian distribution with one parameter \delta.
Usage
invGauss.density(theta, delta)
Arguments
| theta | the vector of values | 
| delta | the parameter of inverse-Gaussian distribution | 
Details
The pdf of inverse-Gaussian is of the form 
f_\theta(\theta)=\frac{\delta}{2\pi}\exp(\delta^2)\theta^{-\frac{3}{2}} \exp(-\frac{\delta^2}{2}(\frac{1}{\theta}+\theta))  
Value
| invGauss.density(theta,delta) | the density – the vector of values | 
Author(s)
Michal Trzesiok
Examples
invGauss.density(c(2,3,5,4,6,7,6), 5)Estimation of Lambda in M-step – Expectation-Maximization (EM) algorithm
Description
The function fits the GLM Poisson with given offset.
Usage
lambda_m_step(variable, X, offset)
Arguments
| variable | the vector of numbers | 
| X | model matrix of the form  | 
| offset | offset in GLM Poisson | 
Details
It fits the GLM Poisson, where variable \sim 1 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.
Value
| lambda | 
 | 
| beta | regressor parameters | 
| glm | output of  | 
Author(s)
Alicja Wolny–Dominiak, Michal Trzesiok
Examples
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)
Estimation of starting lambda in Expectation-Maximization (EM) algorithm
Description
The function fits the GLM Poisson without regressors.
Usage
lambda_start(variable, X)
Arguments
| variable | the vector of numbers | 
| X | model matrix of the form  | 
Details
It fits the GLM Poisson, where variable \sim 1. 
The results are taken as the starting value of EM algorithm.
Value
| lambda | 
 | 
| beta | regressor parameters | 
| glm | output of  | 
Author(s)
Alicja Wolny–Dominiak, Michal Trzesiok
Examples
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)
Gamma Log-likelihood
Description
The function returns the value of log-likelihood function for of Gamma distribution with one parameter \gamma.
Usage
ll.gamma(gamma.par, t)
Arguments
| gamma.par | 
 | 
| t | the vector of values | 
Details
The pdf of Gamma is of the form 
f_\theta(\theta)=\frac{\gamma^\gamma}{\Gamma(\gamma)}\theta^{\gamma-1}\exp(-\gamma\theta) 
Value
| ll.gamma | the value | 
Author(s)
Michal Trzesiok
Examples
ll.gamma(1, c(3,8))Inverse-Gaussian Log-likelihood
Description
The function returns the value of log-likelihood function for of inverse-Gaussian distribution with one parameter \delta.
Usage
ll.invGauss(delta, t)
Arguments
| delta | 
 | 
| t | the vector of values | 
Details
The pdf of inverse-Gaussian is of the form 
f_\theta(\theta)=\frac{\delta}{2\pi}\exp(\delta^2)\theta^{-\frac{3}{2}} \exp(-\frac{\delta^2}{2}(\frac{1}{\theta}+\theta))  
Value
| ll.invGauss | the value | 
Author(s)
Michal Trzesiok
Examples
ll.invGauss(1, c(3,8))Log-normal Log-likelihood
Description
The function returns the value of log-likelihood function of log-normal distribution with one parameter \nu.
Usage
ll.lognorm(nu, t)
Arguments
| nu | 
 | 
| t | the vector of values | 
Details
The pdf of log-normal is of the form f_\theta(\theta)=\frac{1}{\sqrt{2\pi\nu\theta}}\exp[-\frac{(\log(\theta)+\frac{\nu^2}{2})^2}{2\nu^2}] 
Value
| ll.lognorm | the value | 
Author(s)
Michal Trzesiok
Examples
ll.lognorm(1, c(3,8))Log-normal Density
Description
The function returns the vector of values of density  function for of log-normal distribution with one parameter \nu.
Usage
lognorm.density(theta, nu)
Arguments
| theta | the vector of values | 
| nu | the parameter of log-normal distribution | 
Details
The pdf of log-normal is of the form f_\theta(\theta)=\frac{1}{\sqrt{2\pi\nu\theta}}\exp[-\frac{(\log(\theta)+\frac{\nu^2}{2})^2}{2\nu^2}] 
Value
| lognorm.density(theta,nu) | the density – the vector of values | 
Author(s)
Michal Trzesiok
Examples
lognorm.density(c(2,3,5,4,6,7,6), 5)Poisson-Gamma Distribution (Negative-Binomial)
Description
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.
Usage
pg.dist(variable, alpha.start, beta.start, epsylon)
Arguments
| 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) | 
Details
This function provides estimated parameters of the model 
N|\lambda \sim Poisson(\lambda) where \lambda parameter is also a random
variable follows Gamma distribution with hiperparameters \alpha, \beta. The 
pdf of Gamma is of the form 
f_\lambda(\lambda)=\frac{\lambda^{\alpha-1}\exp(-\beta\lambda)\beta^\lambda}{\Gamma(\alpha)}
 . 
Value
| 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 | 
References
Karlis, D. (2005). EM algorithm for mixed Poisson and other discrete distributions. Astin bulletin, 35(01), 3-24.
Examples
library(MASS)
pGamma1 = pg.dist(variable=quine$Days)
print(pGamma1)
Poisson-Lindley Distribution
Description
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.
Usage
pl.dist(variable, p.start, epsylon)
Arguments
| variable | The count variable. | 
| p.start | The starting value of p parameter. Default to 0.1. | 
| epsylon | Default to epsylon = 10^(-8) | 
Details
This function provides estimated parameters of the model 
N|\lambda \sim Poisson(\lambda) where \lambda parameter is also a random
variable follows Lindley distribution with hiperparameter p. The 
pdf of Lindley is of the form 
f_\lambda(\lambda)=\frac{p^2}{p+1}(\lambda+1)\exp(-\lambda p)
 . 
Value
| p | the parameter of mixing Lindley distribution | 
| n.iter | the number of steps in EM algorithm | 
References
Karlis, D. (2005). EM algorithm for mixed Poisson and other discrete distributions. Astin bulletin, 35(01), 3-24.
Examples
library(MASS)
pLindley = pl.dist(variable=quine$Days)
print(pLindley)
Pseudo values – Expectation-Maximization (EM) algorithm
Description
The function returns the pseudo values t_i defined as the conditional expectation E[\theta_i|k_1,...,k_n], 
where k_1,...,k_n are realizations of the count variable N.
Usage
pseudo_values(variable, mixing, lambda, gamma.par, nu, delta, n)
Arguments
| 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 | 
Details
The function calculates the vector of pseudo values t_i=E[\theta_i|k_1,...,k_n] in E-step of EM algorithm. It applies the numerical integration using laguerre.quadrature 
in the nominator and the denominator of the formula
The proper parameter \gamma, \nu, \delta should be chosen according to the mixing distribution.
Value
| pseudo_values | pseudo values  | 
| nominator | nominator in the formula | 
| denominator | denominator in the formula | 
Author(s)
Alicja Wolny–Dominiak, Michal Trzesiok
Examples
variable=rpois(30,4)
pseudo_values(variable, mixing="Gamma", lambda=4, gamma.par=0.7, n=100)