A faster LMG and PMVD
Why a routine of my own
LMG and PMVD split a regression’s R² among correlated predictors by averaging what each one adds, over the orders in which the predictors can enter. The exact way, in the R package relaimpo, runs through every subset of predictors. With the 28 determinants of the thesis that was out of reach, so I wrote my own, in MATLAB.
Fig. 1. Cost of the exact method against mine as the predictors grow. Mine is cheaper from p = 23. At p = 28, the thesis case, the exact method costs about 34 times more.
Source: thesis, section 4.1.2 · Method: asymptotic cost, all subsets O(p · 2^p) against 10,000 sampled orderings O(N · p³), constants dropped · Limit: operation counts, not measured times.
One factorisation per ordering
For every sampled ordering the routine permutes the predictors’ covariance matrix and factorises it once (Cholesky). One forward substitution gives a vector u, and the running sums of u² are the R² of the first predictor, of the first two, and so on up to all of them: every sequential R² at once, and no matrix is ever inverted.
Sxx_perm = Sxx.Value(current_set, current_set);the covariance of the predictors, in this ordering
L_full = chol(Sxx_perm, 'lower');one Cholesky factorisation
u_full = L_full \ Sxy_perm;one forward substitution, no inverse
seq_R2 = cumsum(u_full.^2).' * invSy2;every sequential R² of the ordering, at once
Fig. 2. The heart of the loop over orderings, from lmgANDpmvd.m.
Source: my routine, lines 66 to 73 · Method: Grömping (2006), formula 12, rewritten with a Cholesky factor · Limit: the loop runs in series, and the parallel pool only shares the matrices.
Checked, then used
- 4.3 × 10⁻⁹largest gap from relaimpo on Grömping’s own example (5 predictors, all 120 orderings)
- ≤ 0.0007error of the sampled LMG shares against the exact ones at 20 predictors, over five random seeds
- 0.17 sfor 10,000 orderings of the thesis model, rerun on a laptop in September 2026
The checks are in the repository. Then the routine went on the thesis model: 144 countries, 29 regressors.
- Financial system and inclusion43.9%37.0%
- Institutions and politics19.2%17.8%
- Socio-cultural factors16.1%15.8%
- Development and infrastructure4.4%13.9%
- Macroeconomic environment13.7%11.7%
- Illicit economy and risk2.8%3.8%
Fig. 3. Where the explained variance of crypto adoption goes, by family of determinants (R² = 0.503).
Source: thesis, Table 3 · Method: LMG and PMVD, 10,000 sampled orderings, 144 countries · Limit: shares of explained variance, not causal effects. With sampled orderings PMVD is not stable, LMG is.
PMVD puts almost all its weight on a handful of orderings, and uniform sampling rarely draws them, so its shares move from one run to the next: bank concentration was 34% in the thesis and 29% when rerun. LMG stays put, at 26.75% and 26.55%, and it is the one the thesis reads.