```{r}
#| label: loadlibrary
#| echo: false
library(dplyr)
library(flextable)
library(magrittr)
library(ggplot2)
library(cowplot)
library(RColorBrewer)
```
# Introduction
The Fisher information matrix (FIM) is a key quantity in statistics as it is required for examples for evaluating asymptotic precisions of parameter estimates, for building optimality criteria in experimental designs, for computing Wald test statistics or classical asymptotic distributions in statistical testing [@VanderVaart2000]. It also appears more recently in post model selection inference [@charkhi2018asymptotic], in asymptotic distribution of the likelihood ratio test statistics when testing variance component in mixed models [@baey2019asymptotic] or as a particular Riemannian metric on complex manifold [@le2021fisher]. However its exact computation is often not trivial. This is in particular the case in many latent variables models, also called incomplete data models, due to the presence of the unobserved variables. Though these models are increasingly used in many fields of application, such as in ecophysiology [@Technow2015], in genomic [@Picard2007] or in ecology [@Gloaguen2014]. They especially allow a better consideration of the different variability sources and when appropriate, a more precise characterization of the known mechanisms at the origin of the data. When the FIM can not be exactly computed, people either approximate it numerically, for example by using Monte Carlo technics like developed in the R package MIXFIM [@mixfim2018] or focus on an estimate of the FIM. The probably most widely used is the observed FIM [@efron1978assessing]. When it can not be directly computed in latent variable models, several methods have been proposed to approximate it. Among the most frequently used approaches are Monte-Carlo methods or iterative algorithms derived from the missing information principle [@Woodbury1972]. Indeed according to this principle, the observed Fisher information matrix can be expressed as the difference between two matrices corresponding to the complete information and the missing information due to the unobserved variables (see *e.g.* [@McLachlan2008] chapter 4). It enables the development of alternative methods to compute the observed FIM: the Louis's method [@Louis1982], combined with a Monte Carlo method or a stochastic approximation algorithm by [@Delyon1999], the Oakes method [@Oakes1999] or the supplemented Expectation Maximization algorithm [@Meng1991]. However as the observed FIM involves the second derivatives of the observed log-likelihood, all these methods require to compute second derivatives of the complete data log-likelihood which leads to some disadvantages from a computational point of view. More recently, [@Meng2017] proposed an accelerated algorithm based on numerical first order derivatives of the conditional expectation of the log-likelihood. Another estimate is the empirical Fisher information matrix. This estimator of the FIM is defined as the moment estimate of the covariance matrix of the score. It is much less used than the observed Fisher information matrix. However it has a nice property since it is positive definite, which is not systematically the case for the latter and it is numerically more interesting because it only requires the calculation of the first derivatives of the log-likelihood.
In this paper, our contribution consists in presenting a new numerical method to evaluate the empirical FIM in latent variables model.
Indeed, when the proposed estimate can not be directly analytically evaluated, we propose a stochastic approximation estimation algorithm to compute it, which provides this estimate of the FIM as a by-product of model parameter estimates.
The paper is organized as follows. In Section 2, we recall the three main FIM estimates and discuss their immediate properties. In Section 3, we give practical tools for the computation of the empirical Fisher information matrix in incomplete data models. In particular, we introduce a new stochastic approximation procedure based on the first derivatives of the complete log-likelihood only and state its asymptotic properties. In Section 4, we illustrate the finite sample size properties of both estimators and the convergence properties of the computation algorithm through simulations. The paper ends by a discussion.
# Moment estimates of the Fisher information matrix
Let us consider a random vector $Y$ taking value in $\mathcal{Y}$. Assume $Y$ admits a density $g(\cdot;\theta)$ with respect to a given common measure $\mu$, depending on some parameter $\theta$ taking values in an open subset $\Theta$ of $\mathbb{R}^{d}$, such that the log-likelihood function $\log g$ is differentiable on $\Theta$ and $\|\partial_\theta \log g(y;\theta) (\partial_\theta \log g(y;\theta))^t\|$ is integrable with respect to $g$, where $x^t$ stands for the transpose of a vector or a matrix $x$. Then, by definition (see [@lehmann2006theory]), the Fisher information matrix is given for all $\theta\in\Theta$ by:
$$
I(\theta) = E_\theta\left[\partial_\theta \log g(Y;\theta) (\partial_\theta \log g(Y;\theta))^t \right].
$$ {#eq-fisher_der1}
When this expression can not be analytically evaluated, people are interested in computing an estimate of the Fisher information matrix.
Considering this expression, one can derive a first moment estimator of the Fisher information matrix based on a $n$-sample $y=(y_1, \ldots, y_{n})$ of independent observations:
$$
I_{n,sco}(\theta,y) = \frac{1}{n} \sum_{i=1}^n I_{sco}(\theta,y_i) = \frac{1}{n} \sum_{i=1}^n \partial_\theta \log g(y_i;\theta) (\partial_\theta \log g(y_i;\theta))^t.
$$
This estimate is indeed equal to the mean of the Gram matrices of the scores.
Moreover, we can get another expression for the Fisher information (see [@lehmann2006theory]). If we assume that the set $A=\{y, g(y;\theta)>0\}$ is independent of $\theta$, that for $\mu$-almost all $y$, $g(y;\cdot)$ is differentiable on $\Theta$, and that the derivative with respect to $\theta$ on the left side of
$$\int g(y;\theta)d\mu(y)=1$$ {#eq-density}
can be obtained by differentiating under the integral sign, then
the Fisher information matrix is given for all $\theta\in\Theta$ by:
$$
I(\theta) = V_\theta\left[\partial_\theta \log g(Y;\theta) \right].
$$ {#eq-fisher_der2}
One can also derive a second estimate from this expression defined as
$$
I_{n,cov}(\theta,y) = \frac{1}{n} \sum_{i=1}^n \partial_\theta \log g(y_i;\theta) (\partial_\theta \log g(y_i;\theta))^t-\bar{s}(\theta,y)\bar{s}(\theta,y)^t,
$$
where $\bar{s}(\theta,y)=\frac{1}{n}\sum_{i=1}^n \partial_\theta \log g(y_i;\theta)$ (see *e.g.* [@Scott2002]). We emphasize here that the terminology "empirical Fisher information matrix" is used in the literature for both estimates (see *e.g.* [@kunstner2019limitations]).
Moreover if additionally the second derivative with respect to $\theta$ of $\log g(y;\theta)$ exists for all $y$ and $\theta$ and the second derivative with respect to $\theta$ of the left side of @eq-density can be obtained by differentiating twice under the integral sign (see [@lehmann2006theory]), we have
$$
I(\theta) = - E_\theta\left[\partial_\theta^2 \log g(Y;\theta) \right].
$$ {#eq-fisher_der2}
Considering this third expression, we can derive another moment estimator of the Fisher information matrix based on a $n$-sample $(y_1, \ldots, y_{n})$ of observations, called the observed Fisher information matrix defined as:
$$
I_{n,obs}(\theta,y) = \frac{1}{n}\sum_{i=1}^n I_{obs}(\theta,y_i) = - \frac{1}{n} \sum_{i=1}^n \partial_\theta^2 \log g(y_i;\theta).
$$
Some detailed discussion about the three estimators above can be found in [@Scott2002].
::: {.remark}
We emphasize that the estimate $I_{n,sco}(\theta,y)$ is always positive semi-definite, since it is a mean of Gram matrices, contrary to the other estimates $I_{n,obs}(\theta,y)$ and $I_{n,cov}(\theta,y)$. Moreover assuming $n$ sufficiently large allows to prove positive definiteness of $I_{n,sco}(\theta,y)$. Consider for any nonzero vector $x$ the quantity $x^t I_{n,sco}(\theta,y) x$. We have that $x^t I_{n,sco}(\theta,y) x = ( \sum_{i=1}^n x^t \partial_{\theta} \log g(y_i;\theta) \partial_{\theta} \log g(y_i;\theta)^t x )/n= \sum_{i=1}^n (x^t \partial_{\theta} \log g(y_i;\theta))^2/n$. Thus, $x^t I_{n,sco}(\theta,y) x=0$ implies that $x^t \partial_{\theta} \log g(y_i;\theta)=0$ for all $1 \leq i \leq n$. If $n$ is sufficiently large, there exist $d$ indexes $i_1, ..., i_d$ such that the family of vectors $\{\partial_{\theta} \log g(y_{i_l};\theta), 1 \leq l \leq d\}$ is linearly independent. Thus this implies that $x=0$ leading to the results.
:::
::: {.remark}
The asymptotical properties of the estimates $I_{n,sco}(\theta,y)$ and $I_{n,obs}(\theta,y)$ are straighforward when considering independent and identically distributed sample $(y_1, \ldots, y_{n})$. In particular, assuming standard regularity conditions on $g$, it follows directly from the central limit theorem that $I_{n,sco}(\theta,y)$ and $I_{n,obs}(\theta,y)$ are asymptotically normal.
If the variables $Y_1, \ldots, Y_{n}$ are independent not identically distributed, for example if their distributions depend on some individual covariates which is often the case in practice, we can also get asymptotic properties for the estimates assuming more
strengthed reguarity conditions by applying for example the Kolmogorov criterion (see *e.g.* [@feller1968]) for the consistency and the Lindeberg theorem for the normality result (see theorem 27.2 of [@billingsley2013convergence]).
:::
::: {.remark}
Since both estimators $I_{n,sco}(\theta,y)$ and $I_{n,obs}(\theta,y)$ are moment estimates of $I(\theta)$, they are unbiased for all $\theta \in \Theta$. This is not the case for $I_{n,cov}(\theta,y)$. Regarding the variance, none of both estimators is better than the other one. This can be highlighted through the following examples. First consider a Gaussian sample with unknown expectation and fixed variance. Then, the variance of the estimator $I_{n,obs}(\theta,y)$ is zero whereas the variance of the estimator $I_{n,sco}(\theta,y)$ is positive. Second consider a centered Gaussian sample with unknown variance. Then, the variance of $I_{n,sco}(\theta,y)$ is smaller than the variance of $I_{n,obs}(\theta,y)$. Therefore, none of both estimators is more suitable than the other in general from this point of view.
:::
# Computing the estimator $I_{n,sco}(\theta)$ in latent variable model
Let us consider independent random variables $Y_1, \ldots, Y_{n}$. Assume in the sequel that there exist independent random variables $Z_1, \ldots, Z_{n}$ taking values in $\mathcal{Z}$ and a measure $\lambda$ on $\mathcal{Z}$ such that for each $1 \leq i \leq n$, the random vector $(Y_i,Z_i)$ admits a parametric probability density function denoted by $f$ parametrized by $\theta \in \Theta$ with respect to $\mu \times \lambda$ on $\mathcal{Y}\times\mathcal{Z}$. We present in this section dedicated tools to compute the estimator $I_{n,sco}(\theta)$ in latent variable model when it can not be evaluated analytically.
## Analytical expressions in latent variable models
In latent variable models, the estimator $I_{n,sco}(\theta,y)$ can be expressed using the conditional expectation as stated in the following proposition.
:::{#prp-fisherequality}
Assume that for all $y$ and all $\theta \in \Theta$ the function $f(y,.;\theta)$ is integrable with respect to $\lambda$, that for all $y$ and for $\lambda$-almost all $z$ the function $f(y,z;\cdot)$ is differentiable on $\Theta$, that there exists a mesurable function $m$ such that $\int m(z) \lambda(dz)< \infty$ and for all $\theta \in \Theta$ and for $\lambda$-almost all $z$ $|\partial_\theta f(y,z;\theta)|\leq m(z)$. Then for all $\theta \in \Theta$ and all $n \in \mathbb{N}^*$:
$$
I_{n,sco}(\theta) = \frac{1}{n} \sum_{i=1}^n \mathrm{E}_{Z_i|Y_i;\theta} (\partial_\theta \log f(Y_i,Z_i;\theta) ) \mathrm{E}_{Z_i|Y_i;\theta} (\partial_\theta \log f(Y_i,Z_i;\theta) )^t,
$$ {#eq-vnmis}
where $\mathrm{E}_{Z|Y;\theta}$ denotes the expectation under the law of $Z$ conditionally to $Y$.
:::
We apply the classical Fisher identity [@fisher1925] to establish the equality stated in @prp-fisherequality. We refer to Proposition 100 of [@cappe2005] for the statement of the Fisher identity. This statement is indeed in the same spirit as the well-known Louis formulae for the observed Fisher information matrix estimate [@Louis1982]. The result follows directly.
::: {.remark}
In some specific cases the conditional expectations involved in the previous proposition admit exact analytical expressions for example in mixture models which are developed in @sec-simul in some simulation studies.
:::
## Computing $I_{n,sco}(\theta)$ using stochastic approximation algorithm
When exact computation of the estimator $I_{n,sco}(\theta)$ is not possible for all $\theta\in\Theta$, we propose to evaluate its value by using a new stochastic algorithm which provides the estimate $I_{n,sco}(\bar{\theta}_{ML})$ as a by-product of the maximum likelihood estimate $\bar{\theta}_{ML}$. More precisely we provide three algorithms: a first one in the curved exponential family context which requires to simulate the latent variable from a transition kernel of an ergodic Markov chain and assumes less strong assumptions to get theoretical convergence result thanks to a truncation on random boundaries step, a second one in the curved exponential family context which does not include this additional projection step but requires stronger assumptions to ensure theoretical convergence. This second one and the related results are presented in Appendix. Finally we provide a third algorithm dedicated to general latent variables models without any theoretical results as it is usually the case for such kind of methods (see @sec-generalmodel).
### Description of the algorithm with truncation on random boundaries in curved exponential family model {#sec-algoSAEM}
We develop an extension of the stochastic approximation Expectation Maximization algorithm coupled with a Monte Carlo Markov Chain studied by [@Allassonniere2010] which allows to compute simultaneously the maximum likelihood estimate and the FIM estimate proposed in the previous section. We assume in this section that all the individual complete log-likelihoods belong to the curved exponential family (see [@bickel2015mathematical]) for stating the theoretical results. As our estimate involves individual conditional expectations, we have to consider an extended form of sufficient statistics for the model at the individual level. Indeed, it is necessary to compute stochastic approximation of each individual sufficient statistic at individual level since they are required to be able to compute the proposed FIM estimate. This is the main difference with the usual algorithm. Therefore we introduce the following notations and assumptions.
The individual complete data likelihood function is given for all $1 \leq i \leq n$ by:
$$
f_i(z_i;\theta) = \exp\left(-\psi_i(\theta) + \left<S_i(z_i),\phi_i(\theta)\right>\right),
$$ {#eq-curvedexpo}
where $\left<\cdot,\cdot\right>$ denotes the scalar product, $S_i$ is a function on $\mathbb{R}^{d_i}$ taking its values in a subset $\mathcal{S}_i$ of $\mathbb{R}^{m_i}$.
Let us denote for all $1 \leq i \leq n$ by $L_i$ the function defined on $\mathcal{S}_i \times \Theta$ by $L_i(s_i; \theta)\triangleq - \psi_i(\theta) + \left<s_i,\phi_i(\theta)\right>$ and by $L: \mathcal{S} \times \Theta \to \mathbb{R}$ the function defined as $L(s,\theta)=\sum_i L_i(s_i; \theta)$ with $\mathcal{S}=\prod_i \mathcal{S}_i$ and $s=(s_1,\ldots,s_n)$.
For sake of simplicity, we omitted all dependency on the observations $(y_i)_{1 \leq i \leq n}$ since the considered stochasticity relies here on the latent variables.
Finally let us denote by $(\gamma_k)_{k \geq 1}$ and $(\varepsilon_k)_{k \geq 1}$ sequences of positive step sizes, by $\mathrm{K}$ a compact set of $\mathbb{R}^d$ with $d=\sum d_i$ and by $(\mathcal{K}_k)$ a sequence of increasing compact sets of $\mathcal{S}$ such that $\cup \mathcal{K}_k=\mathcal{S}$ and for all $k$ $\mathcal{K}_{k} \subset int(\mathcal{K}_{k+1} )$.
Moreover we assume that there exists a function $\widehat{\theta} : \ \mathcal{S} \rightarrow \Theta$, such that $\forall s \in \mathcal{S}, \ \ \forall \theta \in \Theta, \ \ L(s; \widehat{\theta}(s))\geq L(s; \theta).$
**Initialization step**: Initialize arbitrarily for all $1 \leq i \leq n$ $s_i^0$ and $\theta_0$. Set $\kappa_0=\zeta_0=\nu_0=0$.
**Repeat until convergence the three steps defined at iteration $k$ by**:
- **Simulation step**: for $1 \leq i \leq n$ simulate a realization $\bar{Z}_i$ from a parametric transition kernel $\Pi_i$ of a Markov Chain parametrized by the current parameter value $\theta_{k-1}$ and having the conditional distribution given the observations $Y_i$ denoted by $p_i$ as stationary distribution
- **Stochastic approximation step**: compute the quantities for all $1 \leq i \leq n$
$$
\bar{s_i} = (1-\gamma_k)s_i^{k-1} +\gamma_k S_i(Z_i^k)
$$
where $(\gamma_k)$ is a sequence of positive step sizes satisfying $\sum \gamma_k=\infty$ and $\sum \gamma_k^2 <~\infty$.
- **Truncation step**: Let us denote $\bar{Z}=(\bar{Z_i})$, $\bar{s}=(\bar{s_i})$ and $s=(s_i)$. If $\bar{s}\in\mathcal{K}_{\kappa_{k-1}}$ and $\|\bar{s}-s^{k-1} \|\leq \varepsilon_{\zeta_{k-1}}$, then set $(Z^k,s^k)=(\bar{Z},\bar{s})$, $\kappa_{k}=\kappa_{k-1}$, $\nu_{k}=\nu_{k-1}+1$, $\zeta_{k}=\zeta_{k-1}+1$, else set $(Z^k,s^k)=(\tilde{Z},\tilde{s})\in \mathrm{K}\times \mathcal{K}_0$, $\kappa_{k}=\kappa_{k-1}+1$, $\nu_{k}=0$, $\zeta_{k}=\zeta_{k-1}+ \Psi(\nu_{k-1})$ where $\Psi:\mathbb{N} \rightarrow \mathbb{Z}$ is a function such that $\Psi(k)>k$ for any $k$ and $(\tilde{Z},\tilde{s})$ chosen arbitrarily.
- **Maximisation step**: update of the parameter estimator according to:
$$
\theta_{k} = \arg \max_{\theta} \sum_{i=1}^n \left( -\psi_i(\theta) + \left<s_i^k,\phi_i(\theta)\right>\right) = \hat{\theta}(s^{k})
$$
**When convergence is reached, say at iteration $K$ of the algorithm, evaluate the FIM estimator according to**:
$$
I_{n,sco}^K = \frac{1}{n} \sum_{i=1}^n \hat{\Delta}_i\left(s^{K}\right) \hat{\Delta}_i\left(s^{K}\right)^t
$$
where $\hat{\Delta}_i(s) = -\partial \psi_i(\hat{\theta}(s)) + \left<s_i,\partial \phi_i(\hat{\theta}(s))\right>$ for all $s$.
::: {.remark}
Note that the projection step which is done through the truncation procedure on random boundaries ensures the stability of the algorithm in particular for the theoretical analysis provided below. More details on this projection step are available in [@Andrieu2005]. However, the authors do not provide recommendations on the choice of $\tilde{Z}$ and $\tilde{s}$. In practice, one could use $(\tilde{Z},\tilde{s})=(Z^{k-1},s^{k-1})$ or $(\tilde{Z},\tilde{s})=(Z^{0},s^{0})$, as done in the numerical experiments in @sec-simul.
:::
### Theoretical convergence property
The theoretical result provided in this section for the sequence $(\theta_k)$ generated by the algorithm with truncation on random boundaries is based on that of [@Allassonniere2010]. Indeed it established convergence guarantees for the FIM estimate obtained as a by-product of that for the MLE. To that purpose,
in addition to the exponential family assumption for each individual likelihood, we also make the same type of regularity assumptions as those presented in [@Allassonniere2010] at each individual level. These assumptions are detailed in the appendix section.
We establish our theoretical result for transition kernels $(\Pi_i)$ corresponding to those of the random walk Metropolis Hastings algorithm [@jarner2000]. We denote by $(q_i)$ the family of symmetric densities used to generate the candidate with the proposal distribution.
We introduce additional assumptions required to control the stochastic behavior of the algorithm:
- **(H1)** There exists a constant $M_0$ such that
$$
\begin{split}
\mathcal L=
\left\{s\in\mathcal S, \langle \nabla l(\hat\theta(s)), h(s)\rangle=0
\right\}\\
\subset
\{s\in\mathcal S, -l(\hat\theta(s))<M_0
\}.
\end{split}
$$
In addition, there exists $M_1\in(M_0,\infty]$ such that
$\{s\in\mathcal S, -l(\hat\theta(s)) \leq M_1
\}$
is a compact set.
- **(H2)** For all $s\in\mathcal{S}$, $\lim_{z \rightarrow \infty} n(z).\nabla_z \log p(z;\hat{\theta}(s))=-\infty$ and $\lim_{z \rightarrow \infty} \sup n(z).m_s(z) <0$ where where $n(z)=z/|z|$ for $z \neq 0$, and $m_s(z)=\nabla_z p(z;\hat{\theta}(s)) /p(z;\hat{\theta}(s))$ with $p(z;\theta)=\prod_i p_i(z_i;\theta)$.
- **(H3)** The family $\{q_i\}_{1\le i \le n}$ of symmetric densities is such that, for $i = 1,\dots,n$, there exist constants $\eta_i > 0$ and $\delta_i <\infty$ such that $q_i (z) > \eta_i$ for all $|z|< \delta_i$.
- **(H4)** There exist $C>1$, $\rho\in(0,1)$ and $\theta_0 \in \Theta$ such that, for all $z\in\mathbb{R}^d$,
$$
|S(z)|\le C p(z;\theta_0)^{-\rho}.
$$
::: {.remark}
Assumption $(H2)$ is standard and usually called super-exponentiality property in the literature [@jarner2000].
:::
::: {.remark}
We established our results for transition kernels corresponding to random walk Metropolis Hastings algorithms which are of common use in practice. We emphasize that our result can be generalised to more general transition kernels by replacing our assumptions $(H2)$ and $(H3)$ by assumption $(DRI)$ of [@Andrieu2005] which is more generic. The latter can be verified in practice for more general transition kernels.
:::
::: {#thm-conv.algo}
Assume that $(M1')$ and $(M2')$, $(M3)$ to $(M5)$, $(SAEM1)$ and $(SAEM2)$, $(H1)$ to $(H4)$ are fulfilled. Let us define $\mathcal{L}=\{\theta \in\Theta, \partial_\theta l(y;\theta)=0\}$ the set of stationary points of the observed log-likelihood $l$ defined as $l(y;\theta)=\sum_{i=1}^n \log g(y_i;\theta)$. Then, for all $\theta_0 \in \Theta$, for fixed $n \in \mathbb{N}^*$, we get: $\lim_k d(\theta_k,\mathcal{L})=0$ a.s. and $\lim_k d(I_{n,sco}^k,\mathcal{I})=0$ a.s. where $\mathcal{I}=\{I_{n,sco}(\theta), \theta \in \mathcal{L}\}$.
:::
:::{.proof}
Let us denote by $S(Z)=(S_1(Z_1),\ldots,S_n(Z_n))$ the sufficient statistics of the model we consider in our approach. Let us also define $H(Z,s)=S(Z)-s$ and $h(s)=\mathrm{E}_{Z|Y;\hat{\theta}(s)}(S(Z))-s$. The proof is composed of two steps following for example the lines of [@Allassonniere2010]. First we establish the almost sure convergence of the sequence $(s_k)$ generated by the algorithm toward the zero of the function $h$. Second we deduce the almost sure convergence of the sequences $(\theta_k)$ and $(I_{n,sco}^k)$ toward the set of critical points of the observed log-likelihood and the set $\mathcal{I}$ respectively.
To prove the first step we apply Theorem 5.5 of [@Andrieu2005]. Therefore we have to verify that their four conditions denoted $(A1)$ to $(A4)$ are fulfilled. Our proof will follow the same global strategy as for example the one of Theorem 1 in [@kuhn2020]. We get first that condition $(A1)$ is satisfied by applying Lemma 2 of [@Delyon1999].
Indeed our assumptions $(M1')$ and $(M2')$ imply that assumptions $(M1)$ and $(M2)$ of [@Delyon1999] are satisfied. These assumptions $(M1')$ and $(M2')$ focus on expressions and regularity properties of the individual likelihood functions and the corresponding sufficient statistics for each index $i \in \{1,\ldots,n\}$. The implication above follows by linearity of the log-likelihood function. Then we get that assumptions $(H1), (M1)-(M5), (SAEM2)$ ensured that condition $(A1)$ is satisfied.
To prove assumptions $(A2)$ and $(A3)$, we will follow the strategy of [@Allassonniere2010] to handle the difficulty of finding a common drift function $V$ for the family of posterior distributions indexed by $s \in \mathcal{S}$. Therefore we will construct first a family of drift functions $(V_s)$ using Proposition 6.1 of [@Andrieu2005], which stated drift conditions, called $(DRI)$, easy to check in practice.
To prove condition $(DRI1)$ for each kernels, we use Theorem 4.1 and Theorem 4.3 of [@jarner2000] which stated that assumptions $(H2)$,$(H3)$ and $(H4)$ imply that Equations $(6.1)$ and $(6.3)$ of $(DRI1)$ are satisfied with $m=1$ and $V_s(z)= p(z;\hat{\theta}(s))^{- \rho}$ with $\rho$ given by $(H4)$. Then the common drift function is defined by $V(z)= p(z;\theta_0)^{- \rho}$ using assumption $(H4)$. Thus for any compact $\mathcal{K}$ of $\Theta$, there exist constants $c_{\mathcal{K}}>0$ and $C_{\mathcal{K}}>0$ such that for all $\theta \in \mathcal{K}$ and for all $z$, $c_{\mathcal{K}} V(z)\leq p(z;\hat{\theta}(s))^{- \rho} \leq C_{\mathcal{K}}V(z)$. Therefore Equations $(6.1)$ and $(6.3)$ are satisfied for this common drift function $V$. Equation $(6.2)$ follows also from Theorem 2.1 of [@jarner2000] which concludes the proof of $(DRI1)$. The first part of $(DRI2)$ is ensured by assumption $(H4)$. The second part is satisfied directly with Lipschitz exponent $\beta$ equal to $1$ in our case. Finally assumption $(DRI3)$ is satisfied also with $\beta=1$ in our framework. This proof is obtained by using the usual strategy of splitting the whole space in four parts depending on the acceptance region and on the rejection region (see the proof of Lemma 4.7 in [@Fort2015] for example) and the fact that the function $\hat\theta$ is twice continuously differentiable.
Finally assumption $(SAEM1)$ allows to choose a sequence $(\varepsilon_k)$ such that $(A4)$ is satisfied (see constructive details in [@Andrieu2005] after the statement of assumption $(A4)$). This concludes the proof of the first step.
The function $\hat\theta$ being continuous, we get that $\lim_k d(\theta_k,\mathcal{L})=0$ applying Lemma 2 of [@Delyon1999]. Moreover we get that for $1 \leq i \leq n$, each sequence $(s_i^k)$ converges almost surely toward $\mathrm{E}_{Z_i|Y_i;\theta} (S_i(Z_i) )$. Since assumption $(M2')$ ensures that for all $1 \leq i \leq n$ the functions $\psi_i$ and $\phi_i$ are twice continuously differentiable and assumption $(M5)$ ensures that the function $\hat{\theta}$ is continuously differentiable, the function $\Phi_n$ defined by $\Phi_n(s^{k})=\frac1{n}\sum_{i=1}^n \hat{\Delta}_i(s^{k})\hat{\Delta}_i(s^{k})$ is continuous. Therefore we get that $\lim_k d(I_{n,sco}^k,\mathcal{I})=0$ which concludes the whole proof.
:::
### Description of the algorithm for general latent variables models {#sec-generalmodel}
In general settings, the SAEM algorithm can yet be applied to approximate numerically the maximum likelihood estimate of the model parameter. Nevertheless there are no more theoretical guarantees of convergence for the algorithm. However we propose an extended version of our algorithm which allows to get an estimate of the Fisher information matrix as a by-product of the estimation algorithm.
**Initialization step**: Initialize arbitrarily $\Delta_i^0$ for all $1 \leq i \leq n$, $Q_0$ and $\theta_0$.
**Repeat until convergence the three steps defined at iteration $k$ by**:
- **Simulation step**: for $1 \leq i \leq n$ simulate a realization $Z_i^k$ directly from the conditional distribution given the observations $Y_i$, denoted by $p_i$, or from a transition kernel of an ergodic Markov Chain having $p_i$ as stationary distribution, using the current parameter $\theta_{k-1}$.
- **Stochastic approximation step**: compute the quantities for all $1 \leq i \leq n$
$$
Q_{k}(\theta) = (1-\gamma_k)Q_{k-1}(\theta)+\gamma_k \sum_{i=1}^n \log f(y_i,Z_i^k;\theta)
$$
$$
\Delta_i^{k} = (1-\gamma_k)\Delta_i^{k-1} +\gamma_k \partial_\theta \log f(y_i,Z_i^k;\theta_{k-1})
$$
- **Maximisation step**: update of the parameter estimator according to:
$$
\theta_{k} = \arg \max_{\theta} Q_{k}(\theta).
$$
**When convergence is reached, say at iteration $K$ of the algorithm, evaluate the FIM estimator according to**:
$$
I_{n,sco}^K = \frac{1}{n} \sum_{i=1}^n \Delta_i^K (\Delta_i^K )^t.
$$
We illustrate through simulations in a nonlinear mixed effects model the performance of this algorithm in @sec-SimusNLMM.
# Simulation study {#sec-simul}
## Asymptotic properties of the estimators $I_{n,sco}(\theta)$ and $I_{n,obs}(\theta)$
In this section, we investigate the properties of the estimators $I_{n,sco}(\theta)$ and $I_{n,obs}(\theta)$ when the sample size $n$ grows.
### Simulation settings
First we consider the following linear mixed effects model $y_{ij} = \beta + z_{i} + \varepsilon_{ij},$
where $y_{ij} \in \mathbb{R}$ denotes the $j^{th}$ observation of individual $i$, $1\leq i \leq n$, $1\leq j \leq J$, $z_i \in \mathbb{R}$ the unobserved random effect of individual $i$ and $\varepsilon_{ij} \in \mathbb{R}$ the residual term. The random effects $(z_{i})$ are assumed independent and identically distributed such that $z_{i} \underset{i.i.d.}{\sim} \mathcal{N}(0,\eta^2)$, the residuals $(\varepsilon_{ij})$ are assumed independent and identically distributed such that $\varepsilon_{ij} \underset{i.i.d.}{\sim} \mathcal{N}(0,\sigma^2)$ and the sequences $(z_i)$ and $(\varepsilon_{ij})$ are assumed mutually independent. Here, the model parameters are $\theta = (\beta, \eta^2, \sigma^2)$. We set $\beta=3$, $\eta^2=2$, $\sigma^2=5$ and $J=12$.
Second we consider the following Poisson mixture model where the distribution of each observation $y_i$, $1\leq i \leq n$, depends on a state variable $z_i$ which is latent leading to
$y_i|z_i=k \sim \mathcal{P}(\lambda_k)$ with $P(z_i=k) = \alpha_k$ and $\sum_{k=1}^{K} \alpha_k = 1.$
The model parameters are $\theta=(\lambda_1,\ldots,\lambda_K,\alpha_1,\ldots,\alpha_{K-1})$. For the simulation study, we consider a mixture of $K=3$ components, and the following values for the parameters $\lambda_1=2$, $\lambda_2=5$, $\lambda_3=9$, $\alpha_1=0.3$ and $\alpha_2=0.5$.
For each model, we generate $M=500$ datasets for different sample sizes $n \in \left\{20,100,500 \right\}$. As a first step, we assume that the true parameter values, denoted by $\theta^{\star}$, are known in order to investigate the asymptotic properties of both $I_{n,sco}$ and $I_{n,obs}$ without adding extra noise induced by the estimation of the parameters. Hence, for each value of $n$ and for each $1 \leq m \leq M$, we derive $I_{n,sco}^{(m)}(\theta^{\star})$ and $I_{n,obs}^{(m)}(\theta^{\star})$. The estimators $I_{n,sco}(\theta^{\star})$ and $I_{n,obs}(\theta^{\star})$ can be computed explicitly in both models by applying @eq-vnmis and Louis' formula [@Louis1982] (see R functions provided in the Appendix section). We then compute the empirical bias and the root mean squared deviation of each component $(\ell,\ell')$ of the estimated matrix as:
$$
\frac{1}{M} \sum\limits_{m=1}^{M} I_{n,sco,\ell,\ell'}^{(m)}(\theta^\star) - I_{\ell,\ell'}(\theta^\star) \; \; \; \mathrm{and} \; \; \; \sqrt{\frac{1}{M} \sum\limits_{m=1}^{M} \left(I_{n,sco,\ell,\ell'}^{(m)}(\theta^\star) - I_{\ell,\ell'}(\theta^\star)\right)^2}.
$$
In the previous quantities, $I(\theta^\star)$ is explicit in the linear mixed effects model and approximated by a Monte-Carlo estimation based on a sample of size $10^8$ in the Poisson mixture model. The results are presented in @tbl-BiasLMM and @tbl-SdLMM for the linear mixed effects model and in @tbl-BiasMixt and @tbl-SdMixt for the mixture model.
In a second step, we use the linear mixed effects model to look at what happens when the parameter $\theta$ is unknown and the estimation of the Fisher information matrix requires to compute an estimate $\hat{\theta}_n$. We use the datasets simulated with $n=500$ and we compute the $M=500$ asymptotic confidence intervals of the three model parameters. We then deduce empirical coverage rates for the following nominal rates $1-\alpha \in \{0.90, 0.95, 0.99\}$ by using the diagonal terms of either the inversed $I_{n,sco}^{(m)}(\theta^{\star})$ (resp. $I_{n,obs}^{(m)}(\theta^{\star})$) or the inversed $I_{n,sco}^{(m)}(\hat{\theta}_n)$ (resp. $I_{n,obs}^{(m)}(\hat{\theta}_n)$). The results are depicted in @tbl-coverageLMM-n100 and @tbl-coverageLMM-n500.
```{r}
#| label: simuLMM-functions
#| eval: false
#| echo: false
source('functions/Fisher_LMM.R')
source('functions/Isco_LMM.R')
source('functions/Iobs_LMM.R')
```
```{r}
#| label: simuLMM-FIM-sco-obs
#| echo: true
#| eval: false
#| message: false
#| file: scripts/simuLMM-estimFIM.R
```
```{r}
#| label: simuPoissonMixture-functions
#| eval: false
#| echo: false
source('functions/sim_poisson_mixture.R')
source('functions/em_poisson_mixture.R')
source('functions/fisher_estimation_poisson_mixture.R')
```
```{r}
#| label: simuPoissonMixture-exactFIM-MCMC
#| eval: false
#| file: scripts/simuPoissonMixture-exactFIM-MCMC.R
```
```{r}
#| label: simuPoissonMixture-FIM-sco-obs
#| echo: true
#| eval: false
#| file: scripts/simuPoissonMixture-estimFIM.R
```
### Results
From @tbl-BiasLMM, @tbl-SdLMM, @tbl-BiasMixt and @tbl-SdMixt, we observe that whatever the model and whatever the components of $I_{n,sco}(\theta^{\star})$ and $I_{n,obs}(\theta^{\star})$, the bias is very small even for small values of $n$. Note that in the linear mixed effects model the second derivative with respect to parameter $\beta$ is deterministic, which explains why the bias and the dispersion of the estimations $I_{n,obs}(\theta^{\star})$ are zero for every value of $n$. The bias and the standard deviation decrease as $n$ increases overall, which illustrates the consistency of both M-estimators. The distributions of the normalized estimations $\sqrt{n} \left(I_{n,sco}^{(m)}(\theta^\star) - I(\theta^\star)\right)$ and $\sqrt{n} \left(I_{n,obs}^{(m)}(\theta^\star) - I(\theta^\star)\right)$ are also represented when $n=500$ for some components of the matrices in @fig-simuLMM (linear mixed effects model) and @fig-simuPoissonMixture (Poisson mixture model). The empirical distributions have the shape of Gaussian distributions and illustrate the asymptotic normality of the two estimators. The numerical results highlight that neither $I_{n,sco}(\theta^{\star})$ nor $I_{n,obs}(\theta^{\star})$ is systematically better than the other one in terms of bias and asymptotic covariance matrix. In the same model, different behaviors can be observed depending on the components of the parameter vector.
```{r}
#| label: fig-simuLMM
#| echo: false
#| eval: true
#| fig-cap: Linear mixed effects model. Kernel density estimates of the normalized values of some components of the estimated Fisher information matrix based on the score ($I_{n,sco}$) and of the observed Fisher information matrix ($I_{n,obs}$) computed in the true parameter values from the 500 simulated datasets with n=500.
#| file: scripts/simuLMM-resPlots.R
```
```{r}
#| label: fig-simuPoissonMixture
#| echo: false
#| eval: true
#| fig-cap: Poisson mixture model. Kernel density estimates of the normalized values of some components of the estimated Fisher information matrix based on the score ($I_{n,sco}$) and of the observed Fisher information matrix ($I_{n,obs}$) computed in the true parameter values from the 500 simulated datasets with n=500.
#| file: scripts/simuPoissonMixture-resPlots.R
```
```{r}
#| label: tbl-BiasLMM
#| tbl-cap: Linear mixed effects model. Empirical bias to the Fisher Information matrix of $I_{n,sco}$ and $I_{n,obs}$ computed in the true parameter values for different values of n.
#| echo: false
#| eval: true
#| warning: false
#| message: false
#| file: scripts/tableBiasLMM.R
```
```{r}
#| label: tbl-SdLMM
#| tbl-cap: Linear mixed effects model. Empirical squared deviation to the Fisher Information matrix of $I_{n,sco}$ and $I_{n,obs}$ computed in the true parameter values for different values of n.
#| echo: false
#| eval: true
#| warning: false
#| message: false
#| file: scripts/tableSdLMM.R
```
```{r}
#| label: tbl-BiasMixt
#| tbl-cap: Poisson mixture model. Empirical bias to the Fisher Information matrix of $I_{n,sco}$ and $I_{n,obs}$ computed in the true parameter values for different values of n.
#| echo: false
#| warning: false
#| message: false
#| file: scripts/tableBiasPoissonMixture.R
```
```{r}
#| label: tbl-SdMixt
#| tbl-cap: Poisson mixture model. Empirical squared deviation to the Fisher Information matrix of $I_{n,sco}$ and $I_{n,obs}$ computed in the true parameter values for different values of n.
#| echo: false
#| warning: false
#| message: false
#| file: scripts/tableSdPoissonMixture.R
```
@tbl-coverageLMM-n100 and @tbl-coverageLMM-n500 show that the empirical coverage rates computed from $I_{n,sco}$ and $I_{n,obs}$ in the linear mixed effects model are close to the nominal values, which corroborates the relevance of both estimators. Moreover there is little difference between the results obtained when using $I_{n,sco}$ or $I_{n,obs}$ to estimate the Fisher information matrix. When the parameter value is unknown, the uncertainty related to the parameter estimation leads to a deterioration of the coverage rates. Still, this deterioration diminishes when $n$ increases.
```{r}
#| label: tbl-coverageLMM-n100
#| tbl-cap: Linear mixed effects model. Comparison of the coverage rates computed from both estimates of the Fisher information matrix in either the true or the estimated parameter values when n=100.
#| echo: false
#| warning: false
#| message: false
#| file: scripts/simuLMM-coverage-n100.R
```
```{r}
#| label: tbl-coverageLMM-n500
#| tbl-cap: Linear mixed effects model. Comparison of the coverage rates computed from both estimates of the Fisher information matrix in either the true or the estimated parameter values when n=500.
#| echo: false
#| warning: false
#| message: false
#| file: scripts/simuLMM-coverage-n500.R
```
## Asymptotic properties of the stochastic approximation algorithm {#sec-SimusNLMM}
We now investigate the properties of our algorithm with truncation on random boundaries in the curved exponential family when the number of iterations grows (@sec-simuExpo) and the good performance of its extended version in more general latent variable models (@sec-simuNonExpo). We also present a short comparison with existing methods (@sec-simuComparison).
### In curved exponential family models {#sec-simuExpo}
We consider the following nonlinear mixed effects model which is widely used in pharmacokinetics for describing the evolution of drug concentration over time:
$$
y_{ij}= g_i(t_{ij},z_i) + \varepsilon_{ij},
$$ {#eq-modelPK}
where $z_i=(\log ka_i, \log Cl_i, \log V_i)'$ are individual random parameters such that
$$\log ka_{i} = \log(ka) + \eta_{i,1}, \log Cl_{i} = \log(Cl) + \eta_{i,2}, \log V_i = \log(V) + \eta_{i,3},$$
and
$$g_i(t_{ij},z_i) = \frac{d_i ka_{i}}{V_i ka_{i}-Cl_{i}}\left[e^{-\frac{Cl_{i}}{V_i} t_{ij}} - e^{-ka_{i} t_{ij}}\right].$$
For all $1 \leq i \leq n$ and all $1\leq j \leq J$, $y_{ij}$ denotes the measure of drug concentration on individual $i$ at time $t_{ij}$, $d_i$ the dose of drug administered to individual $i$, and $V_i$, $ka_i$ and $Cl_i$ respectively denote the volume of the central compartment, the drug's absorption rate constant and the drug's clearance of individual $i$.
The terms $\eta_{i} = (\eta_{i,1},\eta_{i,2},\eta_{i,3})' \in \mathbb{R}^3$ are unobserved random effects which are assumed independent and identically distributed such that $\eta_i \underset{i.i.d.}{\sim} \mathcal{N}(0,\Omega)$, where $\Omega = \mathrm{diag}(\omega^2_{ka},\omega^2_{Cl},\omega^2_{V})$, the residuals $(\varepsilon_{ij})$ are assumed independent and identically distributed such that $\varepsilon_{ij} \underset{i.i.d.}{\sim} \mathcal{N}(0,\sigma^2)$ and the sequences $(\eta_i)$ and $(\varepsilon_{ij})$ are assumed mutually independent. Here, the model parameter is $\theta = (ka,V,Cl,\omega^2_{ka},\omega^2_{V},\omega^2_{Cl},\sigma^2)$.
In this model, as in a large majority of nonlinear mixed effects models, the likelihood does not have any analytical expression. As a consequence, neither the Fisher Information Matrix, nor the estimators $I_{n,sco}(\theta)$, $I_{n,obs}(\theta)$ have explicit expressions. However, as the complete data log-likelihood is explicit, stochastic approximations of $I_{n,sco}(\theta)$, $I_{n,obs}(\theta)$ can be implemented. Note moreover that this model belongs to the curved exponential family as defined in @eq-curvedexpo with
$$
\begin{aligned}
S_i(z_i) = \left(\sum_{j=1}^{J} (y_{ij} g_i(t_{ij}, z_i)), (\log ka_i), (\log Cl_i), (\log V_i), (\log ka_i)^2, (\log Cl_i)^2, (\log V_i)^2 \right)'\\
\phi_i(\theta) = \left(\frac{1}{2\sigma^2},\frac{\log ka}{\omega_{ka}^2}, \frac{\log Cl}{\omega_{Cl}^2}, \frac{\log V}{\omega_{V}^2},-\frac{1}{2\omega_{ka}^2},-\frac{1}{2\omega_{Cl}^2},-\frac{1}{2\omega_{V}^2}\right),\\
\psi_i(\theta) = \frac{1}{2}\left(\frac{(\log ka)^2}{\omega_{ka}^2} + \frac{(\log Cl)^2}{\omega_{Cl}^2} + \frac{(\log V)^2}{\omega_{V}^2}\right).
\end{aligned}
$$
The algorithm described in @sec-algoSAEM can therefore be easily implemented to estimate $\theta$ and the Fisher information matrix simultaneously (see R function provided in the Appendix section).
We take the following values for the parameters $V=31$, $ka=1.6$, $Cl=2.8$, $\omega^2_V=0.40$, $\omega^2_{ka}=0.40$, $\omega^2_{Cl}=0.40$ and $\sigma^2=0.75$. We consider the same dose $d_i=320$ and the same observation times (in hours): $0.25$,$0.5$, $1$, $2$, $3.5$, $5$, $7$, $9$, $12$, $24$ for all the individuals. We simulate one dataset with $n=100$ individuals under model specified by @eq-modelPK. On this simulated dataset, we run $M=500$ times the stochastic approximation algorithm described in @sec-algoSAEM for computing $I_{n,sco}(\hat{\theta})$ together with $\hat{\theta}$ and the algorithm of [@Delyon1999] for computing $I_{n,obs}(\hat{\theta})$. We perform $K=3000$ iterations in total for each algorithm by setting $\gamma_k=0.95$ for $1 \leq k \leq 1000$ (burn in iterations) and $\gamma_k=(k-1000)^{-3/5}$ otherwise, $\varepsilon_k=5.10^4\gamma_k^{2/5}$ and $\mathcal{K}_{\kappa} = [-20-\kappa,20+\kappa]^6\times[0,5.10^4+\kappa]$. At any iteration, we compute the empirical relative bias and the empirical relative standard deviation of each component $(\ell,\ell')$ of $I_{n,sco}$ defined respectively as:
$$
\frac{1}{M} \sum\limits_{m=1}^{M} \frac{\widehat{I_{n,sco,\ell,\ell'}^{(k,m)}} - I_{n,sco,\ell,\ell'}^{\star}}{I_{n,sco,\ell,\ell'}^{\star}} \; \; \; \mathrm{and}
\; \; \; \sqrt{\frac{1}{M} \sum\limits_{m=1}^{M} \left(\frac{\widehat{I_{n,sco,\ell,\ell'}^{(k,m)}} - I_{n,sco,\ell,\ell'}^{\star}}{I_{n,sco,\ell,\ell'}^{\star}}
\right)^2}
$$
where $\widehat{I_{n,sco}^{(k,m)}}$ denotes the estimated value of $I_{n,sco}(\hat{\theta})$ at iteration $k$ of the $m^{th}$ algorithm. We compute the same quantities for $I_{n,obs}$. As the true values of $I_{n,sco}^{\star}=I_{n,sco}(\theta^{\star})$ and $I_{n,obs}^{\star}=I_{n,obs}(\theta^{\star})$ are not known, they are estimated by Monte-Carlo integration based on $10^5$ iterations, including $5000$ burnin, of a Metropolis-Hastings algorithm.
```{r}
#| label: simuNlmeExponential-functions
#| eval: false
#| echo: false
source('functions/model-nlme.R')
source('functions/saem_nlme_exponential_bis.R')
source('functions/fim-mcmc-nlme.R')
```
```{r}
#| label: simuNlme-exponential
#| echo: true
#| eval: false
#| file: scripts/simuNLME-exponential-bis.R
```
The results are displayed in @fig-simuNlme-exponential-bias and @fig-simuNlme-exponential-sd.
```{r}
#| label: fig-simuNlme-exponential-bias
#| echo: false
#| eval: true
#| fig-cap: Non linear mixed effects model. Representation over iterations of the mean relative bias of the diagonal components of the estimated Fisher information matrix computed from the $M=500$ runs of the stochastic algorithm. Red line corresponds to $I_{n,sco}(\theta)$ and blue line corresponds to $I_{n,obs}(\theta)$. The burn-in iterations of the algorithm are not depicted.
#| file: scripts/simuNLME-exponential-plots-bias.R
```
```{r}
#| label: fig-simuNlme-exponential-sd
#| echo: false
#| eval: true
#| fig-cap: Non linear mixed effects model. Representation over iterations of the mean relative standard error of the diagonal components of the estimated Fisher information matrix computed from the $M=500$ runs of the stochastic algorithm. Red line corresponds to $I_{n,sco}(\theta)$ and blue line corresponds to $I_{n,obs}(\theta)$. The burn-in iterations of the algorithme are not depicted
#| file: scripts/simuNLME-exponential-plots-sd.R
```
We observe that the bias and the standard deviations of the estimates of the components of both matrices decrease over iterations, and that for both estimates the bias is nearly zero when the convergence of the algorithm is reached. According to these simulation results, there is no evidence that one method is better than the other in terms of bias or standard deviation.
### In general latent variable models {#sec-simuNonExpo}
We use model specified by @eq-modelPK again, but we now consider that individual parameter $V_i$ is fixed, *i.e.* $V_i \equiv V$ $\forall i = 1,\ldots,n$. The model is no longer exponential in the sense of @eq-curvedexpo. We must therefore use the general version of the stochastic approximation algorithm from @sec-generalmodel to compute $I_{n,sco}(\hat{\theta})$ (see R function provided in the Appendix section). We simulate 500 datasets according to this model and we estimate $I_{n,sco}(\hat{\theta})$ and $\hat{\theta}$ for each one. We perform $K=3000$ iterations of the algorithm by setting $\gamma_k=k^{-0.501}$. We compute the 500 asymptotic confidence intervals of the model parameters, by using either the inversed $I_{n,sco}(\hat{\theta}_k)$'s or the inversed $I_{n,obs}(\hat{\theta}_k)$'s and then deduce from them empirical coverage rates.
```{r}
#| label: simuNlmeNonExponential-functions
#| eval: false
#| echo: false
source('functions/saem_nlme_non_exponential.R')
```
```{r}
#| label: simuNlme-non-exponential
#| echo: true
#| eval: false
#| file: scripts/simuNLME-nonexponential.R
```
```{r}
#| label: simuNlme-non-exponential-coverage
#| echo: false
#| eval: true
#| file: scripts/simuNLME-nonexponential-coverage.R
```
We obtain for the six parameters $(ka,V,Cl,\omega^2_{ka},\omega^2_{Cl},\sigma^2)$ empirical covering rates of \newline $`r covering.isco/nbsim`$ respectively for a nominal covering rate of $0.95$. This highlights that our estimate accurately quantifies the precisions of parameter estimates. Note that empirical coverage rates computed from $I_{n,obs}$ are similar (here $`r covering.iobs/nbsim`$) but that the real advantage of our method is that it requires stochastic approximation only on the first-order derivatives of the complete log-likelihood, contrary to $I_{n,obs}$ which requires deriving the complete log-likelihood at the second order and thus implies more complicated formulas since the model does not belong to the exponential family.
Convergence graphs obtained from a simulated data set are shown in @fig-NLMEnonexponential-conv-plot. Although theoretical guarantee is missing in non exponential models, the stochastic approximation algorithm proposed in @sec-generalmodel converges in practice on this example for both the estimation of the model parameters and the estimation of the Fisher information matrix.
```{r}
#| label: simusNLMEnonexponential-single-dataset
#| echo: false
#| eval: false
#| file: scripts/simuNLME-nonexponential-single-dataset.R
```
```{r}
#| label: fig-NLMEnonexponential-conv-plot
#| echo: false
#| eval: true
#| fig-cap: Non linear mixed effects model. Convergence plot for some parameter estimates and for some diagonal components of $I_{n,sco}(\hat{\theta})$ over iterations of the stochastic approximation algorithm.
#| file: scripts/simuNLME-nonexponential-conv-plot.R
```
### Comparison with other methods {#sec-simuComparison}
To the best of our knowledge, although there exists contributions focusing on the estimation of the Fisher information matrix in latent variable models, there is currently no method based on the first derivatives of the log-likelihood. We compare to [@Meng2017] who proposed an iterative method based on numerical first order derivatives of the Q function that is computed at each E-step of the EM algorithm. The model used by [@Meng2017] in their simulation study is a mixture of two Gaussian distributions with unknown expectations $\mu_1$ and $\mu_2$, fixed variances equal to $1$ and unknown proportion $\pi$. The model parameters are denoted by $\theta=(\mu_1,\mu_2,\pi)$.
```{r}
#| label: simuGaussianMixture-functions
#| eval: false
#| echo: false
source('functions/sim_gaussian_mixture.R')
source('functions/em_gaussian_mixture.R')
source('functions/fisher_estimation_gaussian_mixture.R')
```
```{r}
#| label: simusMeng
#| echo: true
#| eval: false
#| file: scripts/simuGaussianMixture.R
```
```{r}
#| label: simusMeng-results
#| echo: false
#| eval: true
load("Rfiles/ResGaussianMixture.Rdata")
```
We simulate 10000 datasets according to this Gaussian mixture model, using the same setting as [@Meng2017], *i.e.* $n=750$, $\pi=2/3$, $\mu_1=3$ and $\mu_2=0$. For each dataset $k=1,\ldots,10000$, we compute the parameter maximum likelihood estimate $\hat{\theta}_k = (\hat{\pi}_k,\widehat{\mu_1}_k,\widehat{\mu_2}_k)$ with an EM algorithm and then we derive $I_{n,sco}(\hat{\theta}_k)$ directly according to @eq-vnmis (see R function provided in the Appendix section) contrary to [@Meng2017] who used an iterative method. We compute the empirical mean of the 10000 estimated matrices leading to:
$$
\frac1{10000} \sum _k I_{n,sco}(\hat{\theta}_k)= \begin{pmatrix}
`r res$isco[1,1]` & `r res$isco[1,2]` & `r res$isco[1,3]`\\
`r res$isco[2,1]` & `r res$isco[2,2]` & `r res$isco[2,3]` \\
`r res$isco[3,1]` & `r res$isco[3,2]` & `r res$isco[3,3]`\\
\end{pmatrix}.
$$
Comparison with the results of [@Meng2017] is delicate since their numerical illustration of their method is based on a single simulated dataset thus potentially sensitive to sampling variations. However, they provide an estimation of the Fisher information matrix from this unique dataset
$$
I_{Meng} = \begin{pmatrix}
2591.3 & -237.9 & -231.8\\
-237.9 & 155.8 & -86.7\\
-231.8 & -86.7 & 394.5
\end{pmatrix}.
$$
Our results are coherent with their ones. To check the reliability of our results, we then compute as above the 10000 asymptotic confidence intervals of the three model parameters. We obtain for the three parameters $(\pi,\mu_1,\mu_2)$ empirical covering rates of $`r res$recouvprob`$, $`r res$recouvm1`$, $`r res$recouvm2`$ respectively for a nominal covering rate of $0.95$. Thus $I_{n,sco}$ accurately quantifies the precisions of parameter estimates.
# Conclusion and discussion
In this work, we address the estimation of the Fisher information matrix in general latent variable models. We focus on the empirical Fisher information matrix which is a moment estimate of the covariance matrix of the score. We propose stochastic approximation algorithms to compute this estimate when it can not be calculated analytically and establish theoretical convergence properties in the curved exponential family setting. We carry out a simulation study in mixed effects model and in a Poisson mixture model to compare the performances of several estimates, namely the considered empirical Fisher information matrix and the observed Fisher information matrix. We emphasize that the empirical FIM requires less regularity assumptions than the observed FIM. From a computational point of view, the implementation of the algorithm for evaluating the empirical FIM only involves the first derivatives of the log-likelihood, in contrary to the one for evaluating the observed FIM which involves the second derivatives of the log-likelihood.
The main perspective of this work is to adapt the procedure for statistical models whose derivatives of the log-likelihood have no tractable expressions, coupling the algorithm with numerical derivative procedures.
# Appendix
## Description of the algorithm without truncation on random boundaries in curved exponential family model {#sec-algoSAEM-appendix}
We provide here a simpler algorithm based on an extension of the stochastic approximation Expectation Maximization algorithm proposed by [@Delyon1999] using a simulation step performed from the conditional distribution and without truncation on random boundaries. Theoretical results are established assuming a stability condition which is usually quite difficult to check. However, this algorithm can be easily applied in practice.
**Initialization step**: Initialize arbitrarily for all $1 \leq i \leq n$ $s_i^0$ and $\theta_0$.
**Repeat until convergence the three steps defined at iteration $k$ by**:
- **Simulation step**: for $1 \leq i \leq n$ simulate a realization $Z_i^k$ from the conditional distribution given the observations $Y_i$ denoted by $p_i$ using the current parameter value $\theta_{k-1}$.
- **Stochastic approximation step**: compute the quantities for all $1 \leq i \leq n$
$$
s_i^{k} = (1-\gamma_k)s_i^{k-1} +\gamma_k S_i(Z_i^k)
$$
where $(\gamma_k)$ is a sequence of positive step sizes satisfying $\sum \gamma_k=\infty$ and $\sum \gamma_k^2 <~\infty$.
- **Maximisation step**: update of the parameter estimator according to:
$$
\theta_{k} = \arg \max_{\theta} \sum_{i=1}^n \left( -\psi_i(\theta) + \left<s_i^k,\phi_i(\theta)\right>\right) = \hat{\theta}(s^{k})
$$
**When convergence is reached, say at iteration $K$ of the algorithm, evaluate the FIM estimator according to**:
$$
I_{n,sco}^K = \frac{1}{n} \sum_{i=1}^n \hat{\Delta}_i\left(s^{K}\right) \hat{\Delta}_i\left(s^{K}\right)^t
$$
where $\hat{\Delta}_i(s) = -\partial \psi_i(\hat{\theta}(s)) + \left<s_i,\partial \phi_i(\hat{\theta}(s))\right>$ for all $s$.
::: {.remark}
In the cases where the latent variables can not be simulated from the conditional distribution, one can apply the extension coupling the stochastic algorithm with a Monte Carlo Markov Chain procedure as presented in [@Kuhn2004]. All the following results can be extended to this case.
:::
## Theoretical convergence properties
The theoretical following results provide convergence guarantees for the FIM estimate obtained as a by-product of the MLE. Therefore they extend those of [@Delyon1999]. To that purpose,
in addition to the exponential family assumption for each individual likelihood, we also make the same type of regularity assumptions as those presented in [@Delyon1999] at each individual level. These regularity assumptions on the model are detailed at the end of the appendix section.
::: {#thm-conv.algo}
Assume that $(M1')$ and $(M2')$, $(M3)$ to $(M5)$ and $(SAEM1)$ to $(SAEM4)$ are fulfilled. Assume also that with probability 1 $\mathrm{clos}(\{s_k\}_{k \geq 1})$ is a compact subset of $\mathcal{S}$. Let us define $\mathcal{L}=\{\theta \in\Theta, \partial_\theta l(y;\theta)=0\}$ the set of stationary points of the observed log-likelihood $l$ defined as $l(y;\theta)=\sum_{i=1}^n \log g(y_i;\theta)$. Then, for all $\theta_0 \in \Theta$, for fixed $n \in \mathbb{N}^*$, we get: $\lim_k d(\theta_k,\mathcal{L})=0$ and $\lim_k d(I_{n,sco}^k,\mathcal{I})=0$ a.s. where $\mathcal{I}=\{I_{n,sco}(\theta), \theta \in \mathcal{L}\}$.
:::
:::{.proof}
Let us denote by $S(Z)=(S_1(Z_1),\ldots,S_n(Z_n))$ the sufficient statistics of the model we consider in our approach. Note as recalled in [@Delyon1999], these are not unique. Let us also define $H(Z,s)=S(Z)-s$ and $h(s) = \mathrm{E}_{Z|Y;\hat{\theta}(s)}(S(Z))-s$.
Assumptions $(M1')$ and $(M2')$ imply that assumptions $(M1)$ and $(M2)$ of Theorem 5 of [@Delyon1999] are fulfilled. Indeed these assumptions focus on expressions and regularity properties of the individual likelihood functions and the corresponding sufficient statistics for each index $i \in \{1,\ldots,n\}$. Then by linearity of the log-likelihood function and of the stochastic approximation and applying Theorem 5 of [@Delyon1999], we get that $\lim_k d(\theta_k,\mathcal{L})=0$.
Moreover we get that for $1 \leq i \leq n$, each sequence $(s_i^k)$ converges almost surely toward $\mathrm{E}_{Z_i|Y_i;\theta} (S_i(Z_i) )$.
Since assumption $(M2')$ ensures that for all $1 \leq i \leq n$ the functions $\psi_i$ and $\phi_i$ are twice continuously differentiable and assumption $(M5)$ ensures that the function $\hat{\theta}$ is continuously differentiable, the function $\Phi_n$ defined by $\Phi_n(s^{k})=\frac1{n}\sum_{i=1}^n \hat{\Delta}_i(s^{k})\hat{\Delta}_i(s^{k})$ is continuous. Therefore we get that $\lim_k d(I_{n,sco}^k,\mathcal{I})=0$.
:::
We now establish the asymptotic normality of the estimate $\bar{I}_{n,sco}^k$ defined as $\bar{I}_{n,sco}^k=\Phi_n(\bar{s}^{k})$ with $\bar{s}^{k}=\sum_{l=1}^k s^l /k$ using the results stated by [@Delyon1999]. Let us denote by $Vect(A)$ the vector composed of the elements of the triangular superior part of matrix $A$ ordered by columns.
::: {#thm-conv2}
Assume that $(M1')$ and $(M2')$, $(M3)$ to $(M5)$, $(SAEM1)$, $(SAEM2)$, $(SAEM3)$, $(SAEM4)$, $(SAEM4')$ and $(LOC1)$ to $(LOC3)$ are fulfilled. Then, there exists a regular stable stationary point $\theta^* \in \Theta$ such that $\lim_k \theta_k=\theta^*$ a.s. Moreover the sequence $(\sqrt{k}(Vect(\bar{I}_{n,sco}^k)-Vect(\bar{I}_{n,sco}(\theta^*))))\mathbb{1}_{\lim \| \theta_k-\theta^*\|=0 }$ converges in distribution toward a centered Gaussian random vector when $k$ goes to infinity. The asymptotic covariance matrix is characterized.
:::
::: {.proof}
The proof follows the lines of this of Theorem 7 of [@Delyon1999].
Assumptions $(LOC1)$ to $(LOC3)$ are those of [@Delyon1999] and ensure the existence of a regular stable stationary point $s^*$ for $h$ and therefore of $\theta^*=\hat{\theta}(s^*)$ for the observed log-likelihood $l$. Then applying Theorem 4 of [@Delyon1999], we get that:
$$
\sqrt{k}( \bar{s}^k - s^*) \mathbb{1}_{\lim \| s^k-s^*\|=0 } \overset{\mathcal{L}}{ \rightarrow} \mathcal{N}(0, J(s^*)^{-1} \Gamma(s^*) J(s^*)^{-1} )\mathbb{1}_{\lim \| s_k-s^*\|=0 }
$$
where the function $\Gamma$ defined in assumption $(SAEM4')$ and $J$ is the Jacobian matrix of the function $h$.
Applying the Delta method, we get that:
$$
\sqrt{k}( Vect(\Phi_n(\bar{s}^k)) - Vect(\Phi_n(s^*))) \mathbb{1}_{\lim \| s^k-s^*\|=0 } \overset{\mathcal{L}}{ \rightarrow} W\mathbb{1}_{\lim \| s^k-s^*\|=0 }
$$
where $W \sim \mathcal{N}(0, \partial Vect(\Phi_n (s^*)) J(s^*)^{-1} \Gamma(s^*) J(s^*)^{-1} \partial Vect(\Phi_n (s^*))^t )$ which leads to the result.
:::
Note that as usually in stochastic approximation results, the rate $\sqrt{k}$ is achieved when considering an average estimator (see Theorem 7 of [@Delyon1999] *e.g*).
It is assumed that the random variables $s^0, z_1, z_2, \cdots$ are
defined on the same probability space $(\Omega, \mathcal{A}, P)$. We denote $\mathcal{F} = \{ \mathcal{F}_k \}_{k \geq 0}$ the increasing family of
$\sigma$-algebras generated by the random variables $s_0, z_1, z_2, \cdots, z_k$. We assume the following conditions:
- **(M1')** The parameter space $\Theta$ is an open subset of $\mathbb{R}^{p}$. The individual complete data likelihood function is given for all $i=1,\ldots,n$ by:
$$
f_i(z_i;\theta)
= \exp\left(-\psi_i(\theta) + \left<S_i(z_i),\phi_i(\theta)\right>\right),
$$
where $\left<\cdot,\cdot\right>$ denotes the scalar product, $S_i$ is a Borel
function on $\mathbb{R}^{d_i}$ taking its values in an open subset $\mathcal{S}_i$ of $\mathbb{R}^{d_i}$, $\phi_i$ and $\psi_i$ are measurable function of $\Theta$ taking values in open subsets of $\mathbb{R}^{d_i}$ and $\mathbb{R}$ respectively. Moreover, the convex hull of $S(\mathbb{R}^{\sum d_i})$ is included in $\mathcal{S}$ and for all $\theta \in \Theta$ $\int S(z) \prod p_i(z_i;\theta) \mu(dz) < \infty$
- **(M2')** Define for each $i$ $L_i : \mathcal{S}_i \times \Theta \to \mathbb{R}$ as $L_i(s_i; \theta)\triangleq - \psi_i(\theta) + \left<s_i,\phi_i(\theta)\right>$.The functions $\psi_i$ and $\phi_i$ are twice
continuously differentiable on $\Theta$.
- **(M3)** The function $\bar{s} : \Theta \rightarrow \mathcal{S}$ defined as
$\bar{s}(\theta) \triangleq \int S(z) p(z; \theta) \mu(dz)$ is continuously differentiable on $\Theta$.
- **(M4)** For all $1 \leq i\leq n$ the function $l_i:\Theta \rightarrow \mathbb{R}$ defined as
$l_i(\theta) = \log \int f_i(z_i;\theta) \mu_i(dz_i)$ is continuously differentiable on $\Theta$ and $\partial_\theta \int f_i(z_i; \theta) \mu_i(dz_i)= \int \partial_\theta f_i(z_i; \theta) \mu_i(dz_i)$.
- **(M5)** There exists a continuously differentiable function
$\widehat{\theta} : \ \mathcal{S} \rightarrow \Theta$, such that:
$$
\forall s \in \mathcal{S}, \ \ \forall \theta \in \Theta, \ \
L(s; \widehat{\theta}(s))\geq L(s; \theta).
$$
In addition, we define:
- **(SAEM1)** For all $k$ in $\mathbb{N}$, $\gamma_k \in [0,1]$,
$\sum_{k=1}^\infty \gamma_k = \infty$ and $\sum_{k=1}^\infty \gamma_k^2 < \infty$.
- **(SAEM2)** $l:\Theta \rightarrow \mathbb{R}$ and $\widehat{\theta} : \mathcal{S} \rightarrow \Theta$ are $m$ times differentiable, where $m$ is the integer such that $\mathcal{S}$ is an open subset of $\mathbb{R}^m$.
- **(SAEM3)** For all positive Borel functions $\Phi$, we have $E[ \Phi( z_{k+1}) | \mathcal{F}_k ] = \int \Phi( z ) p ( z; \theta_k) \mu( dz).$
- **(SAEM4)** For all $\theta \in \Theta$, $\mathrm{E}_\theta(\|S(Z)\|^{2})< \infty$, and the function
$$
\begin{split}
\Gamma(\theta) \triangleq \mathrm{Cov}_\theta [S(z)]\triangleq &\int
S(z)^t S(z) p(z;\theta)\mu(dz)\\
&-\left[\int S(z)p(z;\theta)\mu(dz)\right]^t\left[\int S(z)p(z;\theta)\mu(dz)\right]
\end{split}
$$
is continuous w.r.t. $\theta$, where $\mathrm{E}_\theta$ stands for the expectation with respect to the posterior distribution $p(\cdot;\theta)$.
We also define assumptions required for the normality result:
- **(SAEM1')** There exist $\gamma^*>0$ and $1/2< \alpha<1$ such that $\lim k^\alpha /\gamma_k =\gamma^*$, and $\gamma_k / \gamma_{k+1}=1 + O(k^{-1})$.
- **(SAEM4')** For some $\varepsilon>0$, $\sup_\theta \mathrm{E}_\theta(\|S(Z)\|^{2+\varepsilon})< \infty$ and $\theta \rightarrow \Gamma(\theta)$ is continuous w.r.t. $\theta$.
- **(LOC1)** The stationary points of $l$ are isolated: any compact subset of $\Theta$ contains only a finite number of such points.
- **(LOC2)** For every stationary point $\theta^*$, the matrices $\mathrm{E}_\theta^*(\partial_\theta L(S(Z),\theta^*) (\partial_\theta L(S(Z),\theta^*))^t)$ and $\partial_\theta^2 L(\mathrm{E}_\theta^* (S(Z)),\theta^*)$ are positive definite.
- **(LOC3)** The minimum eigenvalue of the covariance matrix $R(\theta)=\mathrm{E}_\theta((S(Z)-\bar{s}(\theta))(S(Z)-\bar{s}(\theta))^t)$
is bounded away from zero for $\theta$ in any compact subset of $\Theta$.
## R functions
### Exact computation of the Fisher information matrix in the linear mixed effects model {#sec-R-exactFIMLMM}
```{r}
#| eval: true
#| file: functions/Fisher_LMM.R
#| label: LMM-exactFIM-function-show
```
### Fisher information matrix extimation in the linear mixed effects model {#sec-R-estFIMLMM}
```{r}
#| eval: true
#| file: functions/Isco_LMM.R
#| label: LMM-Isco-function-show
```
```{r}
#| eval: true
#| file: functions/Iobs_LMM.R
#| label: LMM-Iobs-function-show
```
### Fisher information matrix estimation in the Poisson mixture model {#sec-R-estFIMPoisson}
```{r}
#| eval: true
#| file: functions/fisher_estimation_poisson_mixture.R
#| label: simuPoissonMixture-function-show
```
### SAEM algorithm in the PK model belonging to the curved exponential family {#sec-R-saemNLMEexp}
```{r}
#| eval: true
#| file: functions/saem_nlme_exponential_bis.R
#| label: simuNlmeExp-function-show
```
### SAEM algorithm in the PK model not belonging to the curved exponential family {#sec-R-saemNLMEnonexp}
```{r}
#| eval: true
#| file: functions/saem_nlme_non_exponential.R
#| label: simuNlmeNonExp-function-show
```
### Fisher information matrix estimation in the Gaussian mixture model {#sec-R-estFIMGaussian}
```{r}
#| eval: true
#| file: functions/fisher_estimation_gaussian_mixture.R
#| label: simuGaussianMixture-function-show
```