## 3 Statistical Inference: The EM-Type Algorithm  
Let \((k_{i},\mathbf{x}_{1,\mathbf{i}},\mathbf{x}_{2,\mathbf{i}})\), \(i=1,\ldots,n\), be a sample of independent observations, where \(k_{i}\) is the response variable, and \(\mathbf{x}_{1,\mathbf{i}}\) and \(\mathbf{x}_{2,\mathbf{i}}\) are the vectors of explanatory variables with dimensions \(p_{1}\times 1\) and \(p_{2}\times 1\), respectively. In addition, suppose that the data are produced according to the mixed Poisson model with varying dispersion. Then, the log-likelihood of the model can be written as  
\[l(\boldsymbol{\theta})=\sum_{i=1}^{n}\text{log}(P(k_{i})), \tag{11}\]  
where \(\boldsymbol{\theta}=\left(\boldsymbol{\beta}_{1}^{\top},\boldsymbol{\beta}_{ 2}^{\top}\right)^{\top}\) is the vector of the parameters, and where \(P(k_{i})\) is the pmf of the model which is given by Equation (2). It should be noted that the likelihood given by Equation (11) is cumbersome to maximize since it is not usually tractable. Moreover, when the mean and dispersion parameters are modelled in terms of risk factors, additional computational challenges can be encountered. However, ML estimation can be accomplished relatively easily via an EM-type algorithm. In particular, if the unobserved data \(z_{i}\) are augmented to the observed data \((k_{i},\mathbf{x}_{1,\mathbf{i}},\mathbf{x}_{2,\mathbf{i}})\), for \(i=1,\ldots,n\), then the complete data log-likelihood factorizes into two parts  
\[l_{c}(\boldsymbol{\theta})=\sum_{i=1}^{n}\Big{[}-\mu_{i}z_{i}+k_{i}\log(\mu_{i })+k_{i}\log(z_{i})-\log(k_{i}!)\Big{]}+\sum_{i=1}^{n}\text{log}(g(z_{i}; \phi_{i})) \tag{12}\]  
where \(g(z_{i};\phi_{i})\) is the pdf of the mixing distribution which is not conjugate to the Poisson, and where \(\mu_{i}\) and \(\phi_{i}\) are given by Equations (5) and (6) respectively. The EM-type algorithm for the mixed Poisson regression model with varying dispersion can be described as follows  
* **E-Step**: The Q-function, which is the conditional expectation of the complete data log-likelihood, is given by \[Q(\boldsymbol{\theta};\boldsymbol{\theta}^{(r)}) =E_{z_{i}}\Big{(}l_{c}(\boldsymbol{\theta})|\boldsymbol{K}, \boldsymbol{\theta}^{(r)}\Big{)}\propto\] (13) \[\sum_{i=1}^{n}[-\mu_{i}^{(r)}E_{z_{i}}(z_{i}|k_{i};\boldsymbol{ \theta}^{(r)})+k_{i}\log(\mu_{i}^{(r)})]\] (14) \[\quad+\sum_{i=1}^{n}E_{z_{i}}[\text{log}(g(z_{i};\phi_{i}^{(r)}))]\] (15) where \(\boldsymbol{\theta}^{(r)}\) is the estimate of \(\boldsymbol{\theta}\) at the rth iteration in the E-step of our EM algorithm. Then, using the estimates \(\boldsymbol{\theta}^{(r)}\), calculate the pseudo-values \(w_{1_{i}}=E_{z_{i}}(z_{i}|k_{i};\boldsymbol{\theta}^{(r)})\) and \(w_{k_{i}}=E_{z_{i}}(s_{k}(Z_{i})|k_{i};\boldsymbol{\theta}^{(r)})\) for \(i=1,\ldots,n\) and \(k=1,\ldots,\
u\), where \(s_{k}(. )\) are certain functions which are involved in the terms needed for maximizing the part of the Q-function which corresponds to the conditional expectation of the log-likelihood of the mixing distribution \(g(z_{i};\phi_{i})\). * **M-Step**: Using the pseudo-values \(w_{1_{i}}\) and \(w_{k_{i}}\) from the E-Step and the Newton-Raphson algorithm twice, find the maximum global point \(\boldsymbol{\theta}^{(r+1)}\) of the Q-function, that is, obtain the updated estimates \(\boldsymbol{\beta}_{1}^{(r+1)}\) and \(\boldsymbol{\beta}_{2}^{(r+1)}\).