projpred v3.0.0 highlights

Authors

Aki Vehtari

Osvaldo Martin

Florence Bockting

Published

November 22, 2026

We are happy to announce a new major CRAN release of projpred: version 3.0.0! This release brings many user-facing improvements, including:

Below we provide more details on these improvements.

1 LOO search fix

The search finds the best submodel for each size, but choosing a size requires an estimate of how well each submodel predicts new data. This needs cross-validation of the search. Piironen, Paasiniemi, and Vehtari (2020) showed how Pareto smoothed importance sampling leave-one-out cross-validation (PSIS-LOO) can be used for fast cross-validation of the search. In projpred 2.11.0 and earlier, this cross-validation was too optimistic for larger submodels: they could look as good as the reference model even when they predicted new data worse. The reason was that the left-out observation was not completely left out. It still took part in fitting the submodels that were then evaluated on it. projpred 3.0.0 leaves it out completely. This affects cv_varsel() with LOO CV and validated search, which are the defaults; K-fold CV was not affected. The elpd (expected log predictive density) estimates of larger submodels become lower and more realistic, and the size suggested by suggest_size() can change (in our experiments, it was slightly larger). No code changes are needed, but the results differ from those of earlier versions.

The rest of this section gives a short, more detailed explanation of the problem.

Background. The data D consist of N observations with inputs x_j and outcomes y_j, j = 1, \dots, N. In LOO CV, fold i is the step that leaves out observation i. For observation i, LOO CV with validated search estimates the predictive performance of a submodel M with parameters \phi built without observation i:

\mathrm{elpd}_i(M) = \log \int p(y_i \mid x_i, \phi) \, p_M(\phi \mid D_{-i}) \, d\phi ,

where D_{-i} are the data without (x_i, y_i).

The submodel posterior p_M(\phi \mid D_{-i}) is not fitted to the data directly. It is obtained by projecting the posterior of the reference model, with parameters \theta, onto the submodel.

For this, projpred approximates the reference model posterior p(\theta \mid D_{-i}) with PSIS-LOO weights w_s^{(i)} on the draws \theta_s, s = 1, \dots, S, of the full-data posterior, and projects each weighted draw \theta_s to a submodel draw \phi_s^{(i)}. The weights are w_s^{(i)} \propto 1 / p(y_i \mid x_i, \theta_s), Pareto smoothed and normalised to sum to one.

The reference predictions of fold i are the weighted averages1

\tilde{\mu}^{(i)}(x) = \sum_{s=1}^{S} w_s^{(i)} \, \tilde{\mu}_s(x), \qquad \tilde{\mu}_s(x) = \int \tilde{y} \, p(\tilde{y} \mid x, \theta_s) \, d\tilde{y}.

Each draw \theta_s is projected by fitting the submodel to the reference predictions at the observed inputs x_j:

\phi_s^{(i)} = \arg\max_{\phi} \sum_{j=1}^{N} v_j \int p(\tilde{y}_j \mid x_j, \theta_s) \, \log p(\tilde{y}_j \mid x_j, \phi) \, d\tilde{y}_j ,

where v_j are the observation weights (usually 1). The projected draws keep the weights w_s^{(i)}, so that \mathrm{elpd}_i(M) \approx \log \sum_{s=1}^{S} w_s^{(i)} \, p(y_i \mid x_i, \phi_s^{(i)}).2

Problem. The PSIS-LOO weights remove y_i from the reference predictions, but up to release 2.11.0 the projection still used observation i: the sum runs over all N observations, including j = i. The term j = i fits the submodel at x_i to the reference model’s LOO prediction \tilde{\mu}^{(i)}(x_i) there, and the evaluation then predicts at the same x_i. This moves the submodel prediction at x_i toward \tilde{\mu}^{(i)}(x_i). The shift grows with the submodel size: a submodel with about as many parameters as observations can match the reference predictions at every input exactly, including at x_i. The elpd of large submodels then approaches the LOO elpd of the reference model, even if these submodels overfit and predict new data poorly (Figure 1, top row).

Solution. The fix is to remove observation i from the projections of fold i, that is, to set v_i = 0:

\phi_s^{(i)} = \arg\max_{\phi} \sum_{j \neq i} v_j \int p(\tilde{y}_j \mid x_j, \theta_s) \, \log p(\tilde{y}_j \mid x_j, \phi) \, d\tilde{y}_j .

The submodel then predicts at x_i as at a new input, which is what LOO CV is meant to simulate. In most cases, setting the weight to 0 is all that is needed, which makes the fix fast. For multilevel and additive submodels, the row of observation i is removed instead.3

Figure 1 shows example elpd curves before and after the fix, compared to 10-fold CV, which leaves the observations of the left-out fold out of the projection by construction. 10-fold CV can still be biased (usually slightly pessimistic), as only 90% of the data are used for the projection. Before the fix (top row), the LOO estimates stay near the reference model up to the largest submodels, while the test curve drops. After the fix (middle row), they follow the test curve. Both fixed LOO and 10-fold CV show a drop in elpd when the submodel size gets close to N (LOO) or 0.9N (10-fold CV), as does the test curve: these submodels have about as many parameters as observations and overfit.

Figure 1: CV estimate ± SE per submodel size for one simulated data set: Gaussian response, N = 100, P = 200, 20 nonzero effects, ρ = 0.9, R² = 0.4, brms reference model with R2D2 prior. Rows: LOO with search before the fix (projpred ≤ 2.11.0), LOO with search after the fix, and 10-fold CV with reference model refits. Black line: the same search path evaluated on 1000 independent test observations. The y axis is cut at −30 and +20 nat. The unit nat refers to log densities with the natural logarithm.

With many more observations than candidate terms (N \gg P), this fix changes the results little (not shown), because no submodel has enough parameters to match the reference predictions at single observations. That case has a different problem, which Section LOO search with weight perturbation addresses.

2 LOO search with weight perturbation

When there are many more observations than candidate terms (N \gg P), the LOO CV of the search in projpred 2.11.0 and earlier could give elpd curves that jump up and down between neighboring submodel sizes, with standard errors that are too small. With such a curve, the suggested size can depend on chance. projpred 3.0.0 adds a small random perturbation to the search of each LOO fold, which makes the curve smoother and its standard errors more realistic. It is on by default in cv_varsel() with LOO CV, validated search and refit_prj = TRUE (all defaults). Argument loo_perturb_alpha (default 10) sets its strength, and loo_perturb_alpha = Inf turns it off. The perturbation is random, but reproducible with argument seed. It changes the default results; K-fold CV is not affected. McLatchie et al. (2025) proposed using a monotonic spline to smooth the elpd curve, but while that reduces variance, it introduces a slight bias. The weight perturbation instead smooths the curve where the jumps come from, in the fold-wise searches.

The rest of this section explains the problem and the solution in more detail.

Background. Bayesian LOO with the log score (elpd_loo) usually has smaller variance than K-fold CV, as integration over the posterior and smooth log score make log-predictive densities stable, that is, small changes in data lead to small changes in log-predictive densities. However, the search is not smooth, and in the case of an unstable method, LOO can have higher variance than K-fold CV (Arlot and Celisse 2010).

Problem. With LOO and N<P, or with K-fold CV (e.g., K=10), the data sets in different folds vary enough that the folds have many different search paths and the average over those is smoother. With LOO and N \gg P, the data sets in different folds vary only a little and there are fewer search paths explored. This, combined with the dependency between the folds due to overlap, makes the search more coarsely discrete, which leads to large jumps in the elpd curve and thus high variance.

Below, \pi is the search path with the full data, \pi^{(-i)} is the search path of fold i (without observation i), and \pi_k are the first k terms of a path. \Delta_k is the LOO estimate of the elpd difference to the reference model at submodel size k. It is a sum of N fold terms, and \mathrm{SE}_k is its standard error.

  • When N \gg P, the removal of y_i seldom changes the path, so \pi^{(-i)} = \pi for most folds. These folds share the selection of the full-data path. On the fixed full-data path, the LOO curve is high above the test curve (too optimistic). This is because the same data selected the path.
  • In the other folds, two candidate terms have almost equal scores, and y_i selects one of them. Without y_i, the other term is selected, and the fold model predicts y_i worse. The prediction of y_i changes only a little, but the change has the same sign in all these folds.
  • The fraction of folds with \pi^{(-i)}_k \ne \pi_k changes with k, so \Delta_k jumps.
  • The test curve evaluates one path on independent data. The errors of the test points do not depend on the selection, so they have no common sign.

Furthermore, the uncertainty of the elpd estimates is underestimated. The fold terms depend on each other through the selection, and \mathrm{SE}_k, which assumes independent terms, does not include this variation. Averaged over many data sets, LOO with search has approximately no bias. The problem is the large error for a single data set.

Solution. The aim is a curve that is smooth, has a small bias and has an SE that includes the selection variation, at about the cost of LOO. projpred 3.0.0 improves smoothness and reduces variance of the elpd curves by adding a small amount of randomness to lower the dependency between the folds.

We can increase the variation in LOO folds by bootstrapping the original data. The Bayesian bootstrap (Rubin 1981) weights the observations with weights drawn from a Dirichlet distribution. For fold i, projpred draws b^{(i)} = N \cdot d^{(i)} with d^{(i)} \sim \mathrm{Dirichlet}(\alpha, \dots, \alpha) and sets b_i^{(i)} = 0, so the weights b_j^{(i)} have mean 1. Reweighting the posterior draws with these weights on top of the PSIS-LOO weights would, however, often leave only a few draws with non-negligible weight. We approximate the effect of the Bayesian bootstrap by a first-order approximation of the fold posterior mean. This can be implemented using a fold-specific shift of the posterior draws of the linear predictor and the (unconstrained) dispersion parameter.

For the linear predictor \eta_s(x_j) of draw s, the shift is the w^{(i)}-weighted covariance between the linear predictor and the change of the log-likelihood under the weights b^{(i)}:

\delta_j = \sum_{s=1}^{S} w_s^{(i)} \, (c_s - \bar{c}) \, \eta_s(x_j), \qquad c_s = \sum_{j' \neq i} \big(b_{j'}^{(i)} - 1\big) \log p(y_{j'} \mid x_{j'}, \theta_s), \qquad \bar{c} = \sum_{s=1}^{S} w_s^{(i)} c_s .

The weights b_j^{(i)} also multiply the observation weights v_j in the projections of the search. The performance evaluation of each fold does not use the weights or the shift, so the weight perturbation changes only the search path of the fold.

To balance the improved smoothness without adding too much extra noise, the weight perturbation magnitude is based on using a Dirichlet distribution with \alpha = 10 (based on simulation experiments), which gives less variation in the weights than the usual Bayesian bootstrap with \alpha = 1 (standard deviation of the weights b_j^{(i)}, roughly 1/\sqrt{\alpha}, about 0.32 instead of 1). In cv_varsel(), argument loo_perturb_alpha sets \alpha.

The path of fold i now changes with the random weights of fold i, and these weights are independent between folds. The paths no longer change together because of y_i. The selection variation of the fold terms then averages over the folds: the curve \Delta_k jumps less between neighboring sizes, and its variance is smaller. Each fold term carries its own selection variation, so \mathrm{SE}_k includes more of it and is more realistic.

Figure 2 shows example elpd curves without and with the weight perturbation, compared to 10-fold CV. In the top row (without the perturbation), the LOO curve jumps between neighboring sizes and often lies far from the test curve. In the middle row (with the perturbation), the curve is smooth and close to the 10-fold CV curve in the bottom row.

Figure 2: CV estimate ± SE per submodel size for one simulated data set: Gaussian response, N = 1000, P = 100, 30 nonzero effects, ρ = 0.5, R² = 0.2, brms reference model with R2D2 prior. Rows: LOO with search without weight perturbation (with the fix of the previous section), LOO with search with weight perturbation (α = 10, the default of loo_perturb_alpha), and 10-fold CV with reference model refits. Black line: the full-data search path evaluated on 10 000 independent test observations. The y axis is cut at −20 and +20 nat.

Without the weight perturbation, the LOO curve has jumps of up to 17 nat between neighboring sizes from size 10 on. From size 30 on, the errors compared to the test curve are up to 15 nat, while the SE is on average 0.9 nat. With the weight perturbation, the curve is smooth, and from size 30 on the errors are at most 4 nat with an average SE of 1.1 nat. The result is similar to 10-fold CV, but without the need to refit the reference model. In this data set, all three curves are above the test curve at sizes 12–25.

3 Speed

projpred 3.0.0 is faster than 2.11.0 for all model types that we tested. The speedups come from moving common computations outside of loops, linear regression matrix algebra tricks, faster submodel fits and from caching work that the folds share. They need no code changes; NEWS lists the individual improvements. Table 1 gives the speedup of cv_varsel() with LOO CV and validated search on one CPU, with the same arguments in both versions. The speedup is the 2.11.0 time divided by the 3.0.0 time. Section Screen search gives the speed of the new search_screen argument, and Section Updated parallel implementation the speed with parallel workers. In Table 1, the variants are the projection types (traditional, latent or augmented-data projection) and the kinds of terms (multilevel, additive); see the projpred vignettes.

Table 1: Speedup of cv_varsel() with LOO CV and validated search in projpred 3.0.0 against 2.11.0 on one CPU. The speedup column gives the 2.11.0 time divided by the 3.0.0 time. N is the number of observations and P the number of candidate terms. Some data sets use full LOO and some subsampled LOO. “+” marks a lower bound, because 2.11.0 was stopped after 47.8 h. The speedup is largest for the Gaussian traditional projection and for the latent projection with many candidate terms. It is smallest for the Gaussian multilevel and additive models and for the latent projection of the binomial multilevel models.
family variant data sets N P cv_varsel() speedup
Gaussian traditional 9 46–407 6–200 220–6300
multilevel 1 300 9 3.9
additive 1 300 6 2.8
additive multilevel 1 300 7 3.7
binomial traditional 4 100–407 26–500 6.9–12
latent 2 100 100–500 840–2000
multilevel 1 300 8 24
multilevel latent 2 300–600 28 2.5–3.4
categorical augmented data 1 400 20 9.6
multilevel 1 300 7 33
negative binomial latent 1 382 25 25
ordinal augmented data 4 99–800 11–100 41–46
latent 5 56–800 11–500 10–1900
multilevel 1 300 7 10
Poisson traditional 2 200–382 4–25 8.3–8.9
multilevel 1 300 8 1800+
Weibull latent 4 100–2982 8–500 32–1900

5 Updated parallel implementation

projpred 3.0.0 runs the parallel CV of cv_varsel() with the future package instead of foreach. This uses less memory and has lower overhead, and foreach has had no CRAN release since 2022. This needs a code change: a foreach backend, for example from doParallel::registerDoParallel(), no longer has any effect. Set up the workers with future::plan() instead. The global options projpred.foreach_errorhandling and projpred.foreach_verbose are removed.

Set up the workers with, for example, future::plan(future.mirai::mirai_multisession, workers = 8) and call cv_varsel(..., parallel = TRUE). If no parallel future plan is set, cv_varsel(..., parallel = TRUE) gives a warning and runs the folds sequentially. future::plan(future::multisession, workers = 8) also works, but in our experiments the first parallel call was faster with the workers of future.mirai. Each fold has its own random number stream, so for a given seed the results do not depend on parallel or on the number of workers.

future::plan(future.mirai::mirai_multisession, workers = 8)
cvvs <- cv_varsel(fit, parallel = TRUE)
future::plan(future::sequential)  # stop the workers

The workers now get only the objects that their folds need. Examples are a copy of the reference model without its fits and the PSIS-LOO weights of their own fold. Thus, for most reference models, the workers do not load the package that fitted the reference model (for example, brms or rstanarm). The multilevel and additive submodel fits that the workers send back do not hold copies of the data. If the functions of a custom reference model use objects of the global environment, projpred now finds these objects and sends them to the workers; global option projpred.export_to_workers can name more objects.

We compared projpred 3.0.0 with the development version just before the new parallel implementation. That version uses foreach with the doFuture backend and has most of the other speed improvements of 3.0.0, so the comparison shows the effect of the new parallel implementation alone. All runs use LOO CV with validated search and future.mirai workers, and each run starts new workers.

Table 3: Speedup of the parallel LOO CV with validated search. The speedup is the median time of the compared version divided by the median time of parallel projpred 3.0.0 (8 runs per cell). The Gaussian model uses full LOO, the other two models subsampled LOO. N is the number of observations and P the number of candidate terms. “Before” is the parallel run of the development version before the new parallel implementation. “3.0.0 sequential” is projpred 3.0.0 with parallel = FALSE. The runs shared one compute node (AMD EPYC 9965) at the same time. The new implementation is faster mainly in the Gaussian model, which has the shortest run time. In all three models, the speedup from the workers grows with their number.
model N P comparison 4 workers 8 workers 16 workers
Gaussian 382 26 3.0.0 vs before 1.2 1.2 1.3
3.0.0 vs 3.0.0 sequential 1.8 2.5 3.3
Bernoulli multilevel 300 8 3.0.0 vs before 1.0 1.1 1.0
3.0.0 vs 3.0.0 sequential 3.0 5.4 9.0
ordinal 100 50 3.0.0 vs before 1.0 1.0 0.99
3.0.0 vs 3.0.0 sequential 3.1 5.1 8.4
Table 4: Memory of parallel projpred 3.0.0 divided by the memory of the development version before the new parallel implementation; values below 1 mean that 3.0.0 uses less memory. Memory is the proportional set size (Pss) after the call; total is the main R process plus the workers. One run per cell, one run at a time. The Gaussian and Bernoulli workers of 3.0.0 do not load brms or rstanarm and use 35–61% less memory. The ordinal workers of both versions load brms, so the memory changes little.
model N P memory 4 workers 8 workers 16 workers
Gaussian 382 26 per worker 0.39 0.39 0.40
total 0.51 0.46 0.44
Bernoulli multilevel 300 8 per worker 0.65 0.64 0.64
total 0.72 0.69 0.66
ordinal 100 50 per worker 0.95 0.95 0.97
total 0.96 0.96 0.98

6 Other changes

  • The new function custom_stat() defines a user-defined performance statistic for summary(), plot(), performances() and suggest_size().
  • The new argument latent_epred of extend_family() gives the response-scale expected values of the latent projection, for example exp(meanlog + sdlog^2 / 2) for a log-normal model.
  • The forward search adds a smooth term only after the linear terms of its variables. The full model then has the same size on all search paths. This changes the results of additive models.

7 References

Arlot, Sylvain, and Alain Celisse. 2010. “A Survey of Cross-Validation Procedures for Model Selection.” Statistics Surveys 4: 40–79.
McLatchie, Y., S. Rögnvaldsson, F. Weber, and A. Vehtari. 2025. “Advances in Projection Predictive Inference.” Statistical Science 40: 128–47.
Piironen, Juho, Markus Paasiniemi, and Aki Vehtari. 2020. “Projective Inference in High-Dimensional Problems: Prediction and Feature Selection.” Electronic Journal of Statistics 14 (1): 2155–97.
Rubin, Donald B. 1981. “The Bayesian Bootstrap.” The Annals of Statistics 9 (1): 130–34.

Footnotes

  1. For discrete outcomes (for example, in binomial, Poisson or ordinal models), the integrals over \tilde{y} are sums over the possible values of \tilde{y}.↩︎

  2. By default, the search projects clusters of draws instead of single draws. In fold i, the cluster centres are then w^{(i)}-weighted averages of the draws in each cluster.↩︎

  3. The fitters of these submodels do not ignore an observation with weight 0. For example, lme4 still uses its response, and mgcv uses its predictor values for the smooth bases.↩︎