SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Bayes beats Cross Validation: Fast and Accurate Ridge Regression via Expectation Maximization
Shu Yu Tew
shu.tew@monash.edu
Mario Boley
mario.boley@monash.edu
Daniel F. Schmidt
daniel.schmidt@monash.edu
We present a novel method for tuning the regularization hyper-parameter,  $\lambda$ , of a ridge regression that is faster to compute than leave-one-out cross-validation (LOOCV) while yielding estimates of the regression parameters of equal, or particularly in the setting of sparse covariates, superior quality to those obtained by minimising the LOOCV risk. The LOOCV risk can suffer from multiple and bad local minima for finite  $n$  and thus requires the specification of a set of candidate  $\lambda$ , which can fail to provide good solutions. In contrast, we show that the proposed method is guaranteed to find a unique optimal solution for large enough  $n$ , under relatively mild conditions, without requiring the specification of any difficult to determine hyper-parameters. This is based on a Bayesian formulation of ridge regression that we prove to have a unimodal posterior for large enough  $n$ , allowing for both the optimal  $\lambda$  and the regression coefficients to be jointly learned within an iterative expectation maximization (EM) procedure. Importantly, we show that by utilizing an appropriate preprocessing step, a single iteration of the main EM loop can be implemented in  $O(\min(n,p))$  operations, for input data with  $n$  rows and  $p$  columns. In contrast, evaluating a single value of  $\lambda$  using fast LOOCV costs  $O(n\min(n,p))$  operations when using the same preprocessing. This advantage amounts to an asymptotic improvement of a factor of  $l$  for  $l$  candidate values for  $\lambda$  (in the regime  $q,p\in O(\sqrt{n})$  where  $q$  is the number of regression targets).
Ridge regression [25] is one of the most widely used statistical learning algorithms. Given training data  $\mathbf{X} \in \mathbb{R}^{n \times p}$  and  $\mathbf{y} \in \mathbb{R}^n$ , ridge regression finds the linear regression coefficients  $\hat{\beta}_{\lambda}$  that minimize the  $\ell_2$ -regularized sum of squared errors, i.e.,
$$
\hat {\beta} _ {\lambda} = \underset {\beta} {\arg \min } \left\{\left| \left| \mathbf {y} - \mathbf {X} \beta \right| \right| ^ {2} + \lambda \left| \left| \beta \right| \right| ^ {2} \right\}. \tag {1}
$$
In practice, using ridge regression additionally involves estimating the value for the tuning parameter  $\lambda$  that minimizes the expected squared error  $\mathbb{E}(\mathbf{x}^{\mathrm{T}}\hat{\beta}_{\lambda} - y)^{2}$  for new data  $\mathbf{x}$  and  $y$  sampled from the same distribution as the training data. This problem is usually approached via the leave-one-out cross-validation (LOOCV) estimator, which can be computed efficiently by exploiting a closed-form solution for the leave-one-out test errors for a given  $\lambda$ . The wide and long-lasting use of the LOOCV approach suggests that it solves the ridge regression problem more or less optimally, both in terms of its statistical performance, as well as its computational complexity.
Figure 1: Comparison of LOOCV (with fixed candidate grid of size 100) and EM for setting with sparse covariate vectors of  $\mathbf{x} = (x_{1},\dots,x_{100})$  such that  $x_{i}\sim \mathrm{Ber}(1 / 100)$  i.i.d. and responses  $y|\mathbf{x}\sim N(\beta^{\mathrm{T}}\mathbf{x},\sigma^{2})$  for increasing noise levels  $\sigma$  and sample sizes  $n$ . In an initial phase for small  $n$ , the number of EM iterations  $k$  tends to decrease rapidly from an initial large number until it reaches a small constant (around 10). In this phase, EM is computationally slightly more expensive than LOOCV (third row) but has a better parameter mean squared error (first row) corresponding to less shrinkage (second row). In the subsequent phase, both algorithms have essentially identical parameter estimates but EM outperforms LOOCV in terms of computation by a wide margin.
However, in this work, we show that LOOCV is outperformed by a simple expectation maximization (EM) approach based on a Bayesian formulation of ridge regression. While the two procedures are not equivalent, in the sense that they generally do not produce identical parameter values, the EM estimates tend to be of equal quality or, particularly in sparse regimes, superior to the LOOCV estimates (see Figure 1). Specifically, the LOOCV risk estimates can suffer from potential multiple and bad local minima when using iterative optimization, or misspecified candidates when performing grid search. In contrast, we show that the EM algorithm finds a unique optimal solution for large enough  $n$  (outside pathological cases) without requiring any hard to specify hyper-parameters, which is a consequence of a more general bound on  $n$  (Thm. 3.1) that we establish to guarantee the unimodality of the posterior distribution of Bayesian ridge regression—a result with potentially wider applications. In addition, the EM procedure is asymptotically faster than the LOOCV procedure by a factor of  $l$  where  $l$  is the number of candidate values for  $\lambda$  to be evaluated (in the regime  $p, q \in O(\sqrt{n})$  where  $p, q$ , and  $n$  are the number of covariates, target variables, and data points, respectively). In practice, even in the usual case of  $q = 1$  and  $l = O(1)$ , the EM algorithm tends to outperform LOOCV computationally by an order of magnitude as we demonstrate on a test suite of datasets from the UCI machine learning repository and the UCR time series classification archive.
While the EM procedure discussed in this paper is based on a recently published procedure for learning sparse linear regression models [44], the adaption of this procedure to ridge regression has not been previously discussed in the literature. Furthermore, a direct adoption would lead to a main loop complexity of  $O(p^3)$  that is uncompetitive with LOOCV. Therefore, in addition to evaluating the empirical accuracy and efficiency of the EM algorithm for ridge regression, the main technical contributions of this work are to show how certain key quantities can be efficiently computed from either a singular value decomposition of the design matrix, when  $p \geq n$ , or an eigenvalue decomposition of the Gram matrix  $\mathbf{X}^{\mathrm{T}}\mathbf{X}$ , when  $n > p$ . This results in an E-step of the algorithm in time  $O(r)$  where  $r = \min(n, p)$ , and an M-step found in closed form and solved in time  $O(1)$ , yielding an ultra-fast main loop for the EM algorithm.
Table 1: Time complexities of algorithms;  $m = \max (n,p)$ ,  $r = \min (n,p)$ ,  $l$  number of candidate  $\lambda$  for LOOCV,  $k$  number of EM iterations and  $q$  is the number of the target variables.
METHOD	MAIN LOOP	PRE-PROCESSING	OVERALL (p, q ∈ O(√n))
NAIVE ADAPTION OF EM	O(kp³q)	O(p²n)	O(kn²)
PROPOSED BAYESEM	O(krq)	O(mr²)	O(kn + n²)
FAST LOOCV	O(lnrq)	O(mr²)	O(ln²)
These computational advantages result in an algorithm that is computationally superior to efficient, optimized implementations of the fast LOOCV algorithm. Our particular implementation of LOOCV actually outperforms the implementation in scikit-learn by approximately a factor of two by utilizing a similar preprocessing to the EM approach. This enables an  $O(nr)$  evaluation for a single  $\lambda$  (which is still slower than the  $O(r)$  evaluation for our new EM algorithm; see Table 1 for an overview of asymptotic complexities of LOOCV and EM), and may be of interest to readers by itself. Our implementation of both algorithms, along with all experiment code, are publicly available in the standard package ecosystems of the R and Python platforms, as well as on GitHub<sup>1</sup>.
In the remainder of this paper, we first briefly survey the literature of ridge regression with an emphasis on the use of cross validation (Sec. 2). Based on the Bayesian interpretation of ridge regression, we then introduce the EM algorithm and discuss its convergence (Sec. 3). Finally, we develop fast implementations of both the EM algorithm and LOOCV (Sec. 4) and compare them empirically (Sec. 5).
2 Ridge Regression and Cross Validation
Ridge regression [25] (also known as  $\ell_2$ -regularization) is a popular method for estimation and prediction in linear models. The ridge regression estimates are the solutions to the penalized least-squares problem given in (1). The solution to this optimization problem is given by:
$$
\hat {\boldsymbol {\beta}} _ {\lambda} = \left(\mathbf {X} ^ {\mathrm {T}} \mathbf {X} + \lambda \mathbf {I} _ {p}\right) ^ {- 1} \mathbf {X} ^ {\mathrm {T}} \mathbf {y}. \tag {2}
$$
When  $\lambda \rightarrow 0$ , the ridge estimates coincide with the minimum  $\ell_2$  norm least squares solution [22, 31], which simplifies to the usual least squares estimator in cases where the design matrix  $\mathbf{X}$  has full column rank (i.e.  $\mathbf{X}^{\mathrm{T}}\mathbf{X}$  is invertible). Conversely, as  $\lambda \rightarrow \infty$ , the amount of shrinkage induced by the penalty increases, with the resulting ridge estimates becoming smaller for larger values of  $\lambda$ . Under fairly general assumptions [26], including misspecified models and random covariates of growing dimension, the ridge estimator is consistent and enjoys finite sample risk bounds for all fixed  $\lambda \geq 0$ , i.e., it converges almost surely to the prediction risk minimizer, and its squared deviation from this minimizer is bounded for finite  $n$  with high probability. However, its performance can still vary greatly with the choice of  $\lambda$ ; hence, there is a need to estimate the optimal value from the given training data.
Earlier approaches to this problem [e.g. 2, 7, 14, 19, 23, 28-30, 34, 48] rely on an explicit estimate of the (assumed homoskedastic) noise variance, following the original idea of Hoerl and Kennard [25]. However, estimating the noise variance can be problematic, especially when  $p$  is not much smaller than  $n$  [18, 20, 24, 46]. More recent approaches adopt model selection criteria to select the optimal  $\lambda$  without requiring prior knowledge or estimation of the noise variance. These methods involve minimizing a selection criterion of choice, such as the Akaike information criterion (AIC) [1], Bayesian information criterion (BIC) [40], Mallow's conceptual prediction  $(\mathbf{C}_p)$  criterion [33], and, most commonly, cross validation (CV) [4, 49].
A particularly attractive variant of CV is leave-one-out cross validation (LOOCV), also referred to as the prediction error sum of squares (PRESS) statistic in the statistics literature [3]
$$
R _ {n} ^ {\mathrm {C V}} (\lambda) = \frac {1}{n} \sum_ {i = 1} ^ {n} \left(y _ {i} - \hat {y} _ {i}\right) ^ {2} \tag {3}
$$
$^{1}$ https://github.com/marioboley/fastridge.git
where  $\hat{y}_i = \tilde{\mathbf{x}}_i\hat{\beta}_{\lambda}^{-i}$ , and  $\hat{\beta}_{\lambda}^{-i}$  denotes the solution to (2) when the  $i$ -th data point  $(\tilde{\mathbf{x}}_i,y_i)$  is omitted. LOOCV offers several advantages over alternatives such as 10-fold CV: it is deterministic, nearly unbiased [47], and there exists an efficient "shortcut" formula for the LOOCV ridge estimate [36]:
$$
R _ {n} ^ {\mathrm {C V}} (\lambda) = \frac {1}{n} \sum_ {i = 1} ^ {n} \left(\frac {e _ {i}}{1 - H _ {i i} (\lambda)}\right) ^ {2} \tag {4}
$$
where  $\mathbf{H}(\lambda) = \mathbf{X}(\mathbf{X}^{\mathrm{T}}\mathbf{X} + \lambda \mathbf{I}_p)^{-1}\mathbf{X}^{\mathrm{T}}$  is the regularized "hat", or projection, matrix and  $\mathbf{e} = \mathbf{y} - \mathbf{H}(\lambda)\mathbf{y}$  are the residuals of the ridge fit using all  $n$  data points. As it only requires the diagonal entries of the hat matrix, Eq. (4) allows for the computation of the PRESS statistic with the same time complexity  $O(p^{3} + np^{2})$  as a single ridge regression fit.
Moreover, unless  $p / n \to 1$ , the LOOCV ridge regression risk as a function of  $\lambda$  converges uniformly (almost surely) to the true risk function on  $[0, \infty)$  and therefore optimizing it consistently estimates the optimal  $\lambda$  [22, 36]. However, for finite  $n$ , the LOOCV risk can be multimodal and, even worse, there can exist local minima that are almost as bad as the worst  $\lambda$  [42]. Therefore, iterative algorithms like gradient descent cannot be reliably used for the optimization, giving theoretical justification for the pre-dominant approach of optimizing over a finite grid of candidates  $L = (\lambda_1, \dots, \lambda_l)$ . Unfortunately, despite the true risk function being smooth and unimodal, a naively chosen finite grid cannot be guaranteed to contain any candidate with a risk value close to the optimum. While this might not pose a problem for small  $n$  when the error in estimating the true risk via LOOCV is likely large, it can potentially become a dominating source of error for growing  $n$  and  $p$ . Therefore, letting  $l$  grow moderately with the sample size appears necessary, turning it into a relevant factor in the asymptotic time complexity.
As a further disadvantage, LOOCV (or CV in general) is sensitive to sparse covariates, as illustrated in Figure 1 where the performance of LOOCV, relative to the proposed EM algorithm, degrades as the noise variance  $\sigma^2$  grows. In the sparse covariate setting, a situation common in genomics, the information about each coefficient is concentrated in only a few observations. As LOOCV drops an observation to estimate future prediction error, the variance of the CV score can be very large when the predictor matrix is very sparse, as the estimates depend on only a small number of the remaining observations. In the most extreme case, known as the multiple means problem [27],  $\mathbf{X} = \mathbf{I}_n$ , and all the information about each coefficient is concentrated in a single observation. In this setting, the LOOCV score reduces to  $\sum y_i^2$ , and provides no information about how to select  $\lambda$ . In contrast, the proposed EM approach explicitly ties together the coefficients via the probabilistic Bayesian interpretation of  $\lambda$  as the inverse-variance of the unknown coefficient vector. This "borrowing of strength" means that the procedure provides a sensible estimate of  $\lambda$  even in the case of multiple means (see Appendix A).
3 Bayesian Ridge Regression
The ridge estimator (2) has a well-known Bayesian interpretation; specifically, if we assume that the coefficients are a priori normally distributed with mean zero and common variance  $\tau^2\sigma^2$  we obtain a Bayesian version of the usual ridge regression procedure, i.e.,
$$
\begin{array}{l} \mathbf {y} \mid \mathbf {X}, \boldsymbol {\beta}, \sigma^ {2} \sim N _ {n} \left(\mathbf {X} \boldsymbol {\beta}, \sigma^ {2} \mathbf {I} _ {n}\right), \\ \boldsymbol {\beta} \mid \tau^ {2}, \sigma^ {2} \sim N _ {p} (0, \tau^ {2} \sigma^ {2} \mathbf {I} _ {p}), \tag {5} \\ \sigma^ {2} \sim \sigma^ {- 2} d \sigma^ {2}, \\ \tau^ {2} \sim \pi (\tau^ {2}) d \tau^ {2}, \\ \end{array}
$$
where  $\pi (\cdot)$  is an appropriate prior distribution assigned to the variance hyperparameter  $\tau^2$ . For a given  $\tau >0$  and  $\sigma >0$ , the conditional posterior distribution of  $\beta$  is also normal [32]
$$
\boldsymbol {\beta} \mid \tau^ {2}, \sigma^ {2}, \mathbf {y} \sim N _ {p} \left(\hat {\boldsymbol {\beta}} _ {\tau}, \sigma^ {2} \mathbf {A} _ {\tau} ^ {- 1}\right),
$$
$$
\hat {\boldsymbol {\beta}} _ {\tau} = \mathbf {A} _ {\tau} ^ {- 1} \mathbf {X} ^ {\mathrm {T}} \mathbf {y}, \tag {6}
$$
$$
\mathbf {A} _ {\tau} = \left(\mathbf {X} ^ {\mathrm {T}} \mathbf {X} + \tau^ {- 2} \mathbf {I} _ {p}\right),
$$
where the posterior mode (and mean)  $\hat{\beta}_{\tau}$  is equivalent to the ridge estimate with penalty  $\lambda = 1 / \tau^2$  (we rely on the variable name in the notation  $\hat{\beta}_x$  to indicate whether it refers to (6) or (2)).
Shrinkage Prior To estimate the  $\tau^2$  hyperparameter in the Bayesian framework, we first must choose a prior distribution for the hypervariance  $\tau^2$ . We assume that no strong prior knowledge on the degree of shrinkage of the regression coefficients is available, and instead assign the recommended default beta-prime prior distribution for  $\tau^2$  [15, 38] with probability density function:
$$
\pi \left(\tau^ {2}\right) = \frac {\left(\tau^ {2}\right) ^ {a - 1} \left(1 + \tau^ {2}\right) ^ {- a - b}}{B (a , b)}, a > 0, b > 0, \tag {7}
$$
where  $B(a, b)$  is the beta function. Specifically, we choose  $a = b = 1/2$ , which corresponds to a standard half-Cauchy prior on  $\tau$ . The half-Cauchy is a heavy-tailed, weakly informative prior that is frequently recommended as a default choice for scale-type hyperparameters such as  $\tau$  [38]. Further, this estimator is very insensitive to the choice of  $a$  or  $b$ . As demonstrated by Theorem 6.1 in [6], the marginal prior density over  $\beta$ ,  $\int \pi(\beta | \tau^2) \pi(\tau^2 | a, b) d\tau^2 = \pi(\beta | a, b)$  has polynomial tails in  $\| \beta \|^2$  for all  $a > 0, b > 0$ , and has Cauchy or heavier tails for  $b \leq 1/2$ . This type of polynomial-tailed prior distribution over the norm of the coefficients is insensitive to the overall scale of the coefficients, which is likely unknown a priori. This robustness is in contrast to other standard choices of prior distributions for  $\tau^2$  such as the inverse-gamma distribution [e.g., 35, 41] which are highly sensitive to the choice of hyperparameters [38].
Unimodality and Consistency The asymptotic properties of the posterior distributions in Gaussian linear models (5) have been extensively researched [8, 16, 17, 45]. These studies reveal that in linear models, the posterior distribution of  $\beta$  is consistent, and converges asymptotically to a normal distribution centered on the true parameter value. When  $p$  is fixed, this assertion can be established through the Bernstein-Von Mises theorem [45, Sec. 10.2]. Our specific problem (5) satisfies the conditions for this theorem to hold: 1) both the Gaussian-linear model  $p(y|\beta, \sigma^2)$  and the marginal distribution  $\int p(y|\beta, \sigma^2)\pi(\beta|\tau^2)d\beta = p(y|\tau^2, \sigma^2)$  are identifiable; 2) they have well defined Fisher information matrices; and 3) the priors over  $\beta$  and  $\tau$  are absolutely continuous. Further, these asymptotic properties remain valid when the number of predictors  $p_n$  is allowed to grow with the sample size  $n$  at a sufficiently slower rate [8, 16].
The following theorem (see the proof in Appendix B) provides a simple bound on the number of samples required to guarantee that the posterior distribution for the Bayesian ridge regression hierarchy given by (5) has only one mode outside a small environment around zero.
Theorem 3.1. Let  $\epsilon >0$ , and let  $\gamma_{n}$  be the smallest eigenvalue of  $\mathbf{X}^{\mathrm{T}}\mathbf{X} / n$ . If  $\gamma_{n} > 0$  and  $\epsilon >4 / (n\gamma_{n})$  then the joint posterior  $p(\beta ,\sigma^2,\tau^2 |\mathbf{y})$  has a unique mode with  $\tau^2\geq \epsilon$ . In particular, if  $\gamma_{n}\geq cn^{-\alpha}$  with  $\alpha < 1$  and  $c > 0$  then there is a unique mode with  $\tau^2\geq \epsilon$  if  $n > (4 / (c\epsilon))^{1 / (1 - \alpha)}$ .
In other words, all sub-optimal non-zero posterior modes vanish for large enough  $n$  if the smallest eigenvalue of  $\mathbf{X}^{\mathrm{T}}\mathbf{X}$  grows at least proportionally to some positive power of  $n$ . This is a very mild assumption that is typically satisfied in fixed as well as random design settings, e.g., with high probability when the smallest marginal covariate variance is bounded away from zero.
Expectation Maximization Given the restricted unimodality of the joint posterior (5) for large enough  $n$ , in conjunction with its asymptotic concentration around the optimal  $\beta_0$ , estimating the model parameters via an EM algorithm appears attractive, as they are guaranteed to converge to an exact posterior mode. In particular, in the non-degenerate case that  $\beta_0 \neq 0$ , there exist  $\tau^2 = \epsilon^2 > 0$  such that for large enough, but finite  $n$ , the posterior concentrates around  $(\beta_0, \tau^2)$ , and thus  $\beta_0$  is identified by EM if initialized with a large enough  $\tau^2$ .
Specifically, we use the novel approach [44] in which the coefficients  $\beta$  are treated as "missing data", and  $\tau^2$  and  $\sigma^2$  as parameters to be estimated. Given the hierarchy (5), the resulting Bayesian EM algorithm then solves for the posterior mode estimates of  $\beta$  by repeatedly iterating through the following two steps until convergence:
E-step. Find the parameters of the  $Q$ -function, i.e., the expected complete negative log-posterior (with respect to  $\beta$ ), conditional on the current estimates of  $\hat{\tau}_t^2$  and  $\hat{\sigma}_t^2$ , and the observed data  $\mathbf{y}$ :
$$
\begin{array}{l} Q \left(\tau^ {2}, \sigma^ {2} \mid \hat {\tau} _ {t} ^ {2}, \hat {\sigma} _ {t} ^ {2}\right) = \operatorname {E} _ {\boldsymbol {\beta}} \left[ - \log p \left(\boldsymbol {\beta}, \tau^ {2}, \sigma^ {2} \mid \mathbf {y}\right) \mid \hat {\tau} _ {t} ^ {2}, \hat {\sigma} _ {t} ^ {2}, \mathbf {y} \right] \\ = \left(\frac {n + p + 2}{2}\right) \log \sigma^ {2} + \frac {\text {E S S}}{2 \sigma^ {2}} + \frac {p + 1}{2} \log \tau^ {2} + \frac {\text {E S N}}{2 \sigma^ {2} \tau^ {2}} + \log (1 + \tau^ {2}) \tag {8} \\ \end{array}
$$
where the quantities to be computed are the (conditionally) expected sum of squared errors  $\mathrm{ESS} = \operatorname{E}\left[||\mathbf{y} - \mathbf{X}\boldsymbol{\beta}||^2 \mid \hat{\tau}_t^2, \hat{\sigma}_t^2\right]$  and the expected squared norm  $\mathrm{ESN} = \operatorname{E}\left[||\boldsymbol{\beta}||^2 \mid \hat{\tau}_t^2, \hat{\sigma}_t^2\right]$ . Denoting by  $\operatorname{tr}(\cdot)$  the trace operator, one can show (see Appendix C) that these quantities can be computed as
$$
\mathrm {E S S} = | | \mathbf {y} - \mathbf {X} \hat {\boldsymbol {\beta}} _ {\tau} | | ^ {2} + \sigma^ {2} \mathrm {t r} (\mathbf {X} ^ {\mathrm {T}} \mathbf {X} \mathbf {A} _ {\tau} ^ {- 1}) \quad \mathrm {a n d} \quad \mathrm {E S N} = \sigma^ {2} \mathrm {t r} (\mathbf {A} _ {\tau} ^ {- 1}) + \| \hat {\boldsymbol {\beta}} _ {\tau} \| ^ {2}. \quad (9)
$$
M-step. Update the parameter estimates by minimizing the Q-function with respect to the shrinkage hyperparameter  $\tau^2$  and noise variance  $\sigma^2$ , i.e.,
$$
\left\{\hat {\tau} _ {t + 1} ^ {2}, \hat {\sigma} _ {t + 1} ^ {2} \right\} = \underset {\tau^ {2}, \sigma^ {2}} {\arg \min } \left\{Q \left(\tau^ {2}, \sigma^ {2} \mid \hat {\tau} _ {t} ^ {2}, \hat {\sigma} _ {t} ^ {2}\right) \right\}. \tag {10}
$$
Instead of numerically optimizing the two-dimensional Q-function (10), we can derive closed-form solutions for both parameters by first finding  $\hat{\sigma}^2 (\tau^2)$ , i.e., the update for  $\sigma^2$ , as a function of  $\tau^2$ , and then substituting this into the Q-function. This yields a Q-function that is no longer dependent on  $\sigma^2$  and solving for  $\hat{\tau}^2$  is straightforward. The resulting parameter updates in the M-step are given by:
$$
\hat {\sigma} ^ {2} = \frac {\tau^ {2} \mathrm {E S S} + \mathrm {E S N}}{(n + p + 2) \tau^ {2}} \quad \text {a n d} \quad \hat {\tau} ^ {2} = \frac {(n - 1) \mathrm {E S N} - (1 + p) \mathrm {E S S} + \sqrt {g}}{(6 + 2 p) \mathrm {E S S}}, \tag {11}
$$
where  $g = (4n + 4)\mathrm{ESN}(3 + p)\mathrm{ESS} + ((1 - n)\mathrm{ESN} + (p + 1)\mathrm{ESS})^2$ . The derivations of these formulae are presented in Appendix D.
From (11), we see that updating the parameter estimates in the M-step requires only constant time. Therefore, the overall efficiency of the EM algorithm is determined by the computational complexity of the E-step. Computing the parameters of the Q-functions directly via (9) requires inverting  $\mathbf{A}_{\tau}$ , resulting in  $O(p^3)$  operations. In the next section, we show how to substantially improve this approach via singular value decomposition.
4 Fast Implementations via Singular Value Decomposition