Gradient \(\nabla_{\boldsymbol{p}}\ell\) of the unconstrained log-likelihood
Source:R/03_03_DeCovarT_estimate_ratios_frequentist.R
gradient_loglik_unconstrained.RdAnalytic gradient of loglik_multivariate() with respect to
\(\boldsymbol{p}\). Writing
\(\boldsymbol{\Theta}=\boldsymbol{\Sigma}(\boldsymbol{p})^{-1}\) and
\(\boldsymbol{r}=\boldsymbol{y}-\boldsymbol{\mu}\boldsymbol{p}\), the
\(j\)-th coordinate is
$$
\frac{\partial\ell}{\partial p_j}
=
-2p_j\,\mathrm{Tr}\!\bigl(\boldsymbol{\Theta}\boldsymbol{\Sigma}_j\bigr)
+\boldsymbol{r}^{\mathsf{T}}\boldsymbol{\Theta}\boldsymbol{\mu}_{\cdot j}
+p_j\,\boldsymbol{r}^{\mathsf{T}}
\boldsymbol{\Theta}\boldsymbol{\Sigma}_j\boldsymbol{\Theta}\boldsymbol{r}.
$$
Arguments
- p
Numeric vector \(\boldsymbol{p}\in\mathbb{R}^{J}\).
- y
Numeric vector (or one-column matrix) \(\boldsymbol{y}\in\mathbb{R}^{G}\).
- mean_signature_matrix
Numeric matrix \(\boldsymbol{\mu}\in\mathcal{M}_{G\times J}\) (plug-in means).
- Sigma
Array of cell-type covariances in \(\mathcal{M}_{G\times G\times J}\).
Details
Unit tests compare this analytic gradient to a numerical reference from
numDeriv::grad() applied to loglik_multivariate(). For that check the
Richardson method is preferred; main method.args knobs:
epsInitial finite-difference step (default
1e-4).rNumber of Richardson extrapolations (default
4; tests use6). Raisingrusually improves accuracy more safely than shrinkingepsalone.d,vRelative step factor and geometric reduction between extrapolations (default
v = 2).zero.tol,show.detailsSee
?numDeriv::grad.
Alternative method values: "simple" and "complex".