Skip to content

Home / Monte Carlo / Analyzing the Model / Percent Contribution / Math Details

Math Details

How each share is computed. What the tool reports and how to read it is on Percent Contribution, and every control is on Options.

Every method below is computed from the valid trials only, in trial order, so row \(i\) of an input column and row \(i\) of an output column belong to the same trial.

The three methods

Method What it measures
Spearman the squared rank correlation between an input and an output, normalised across the inputs
Least Squares a multiple regression of the output on all inputs, decomposed two ways at once
LMG the average over orderings of what each input adds to the model sum of squares

Spearman

Each column is replaced by its rank. Equal values share the average of the positions they occupy when sorted, so \(\{5.6, 2.2, 2.2, 3.3\}\) becomes \(\{4, 1.5, 1.5, 3\}\).

With \(r_i\) the rank correlation between input \(i\) and the output, the reported share is

\[ \text{share}_i = \frac{r_i^2}{\sum_j r_j^2} \]

so the shares are non-negative and sum to one by construction. The correlation itself is reported alongside and keeps its sign.

Least Squares

One multiple regression of the output on every varying input produces both decompositions, which is why there is one method here and not two: Type I and Type III always come from the same fit and are always produced together.

Quantity Definition
\(SST\) the total sum of squares of the output, \(\sum (y - \bar{y})^2\)
\(SSM\) the model sum of squares
\(R^2\) \(SSM / SST\)
Type I for input \(i\) the sequential sum of squares: what input \(i\) adds when entered in order
Type III for input \(i\) the drop in the model sum of squares when input \(i\) alone is removed from the full model

Every share is divided by \(SST\), never by \(SSM\):

\[ \text{share}_i = \frac{SS_i}{SST} \]

Dividing by the total rather than by the model sum of squares avoids dividing by zero when the model explains nothing, and avoids it again when the Type III shares happen to sum to zero.

The signed statistic beside each share is the standardized regression coefficient from the full regression,

\[ b_i \frac{s_{X_i}}{s_Y} \]

Its sign is the partial direction. Under suppression that can be the opposite of the simple correlation, and when it is, that is a real property of the fit rather than an error.

LMG

LMG averages, over the orderings of the inputs, the amount each input adds to the model sum of squares when it enters. Every share is therefore non-negative, and the shares sum to \(R^2\) by construction.

The signed statistic beside an LMG share is the simple Pearson correlation \(\text{corr}(X_i, Y)\), not the regression coefficient. An LMG magnitude is an average of marginal contributions, so it can disagree in sign with the full-model coefficient; the simple correlation carries an honest sign and a magnitude in \([-1, 1]\). The units of the signed statistic therefore depend on the method, and any reading of its magnitude has to keep the method label in view.

The remainders

Unexplained Variation is the same under every method:

\[ \text{Unexplained} = 1 - R^2 \]

It is the output variation no input receives, because a straight-line fit cannot reproduce the output. It is nonzero whenever the model formula is not a weighted sum of the inputs: two inputs multiplied, an input squared or raised to a power, IF, MIN, MAX, a lookup, or any other curvature or joint action.

It is not your noise term. A declared noise distribution is an ordinary input and gets a share of its own.

Type III has a second remainder, and Type I and LMG do not. Their shares sum to \(R^2\) by construction, so one remainder accounts for everything. Type III credits each input only with the variance that belongs to that input alone, so variance two correlated inputs hold in common is credited to neither:

\[ \text{Shared Variation} = R^2 - \sum_i \text{share}_i^{\,\text{Type III}} \]

This has nothing to do with the shape of the formula. It appears in a perfectly straight-line model and it grows as the inputs become more correlated.

Why the Type III shares are not rescaled

They are reported exactly as computed. They are not normalised, not clamped, and not rescaled to reach 100 percent, and Shared Variation is not clamped at zero.

The reason is that a Type III share is not a slice of a whole. It is what one input contributes that no other input accounts for, so under correlation the shares can add to more or less than the model explains. Rescaling them would produce numbers that add up and mean nothing. A decomposition that always adds up is available: LMG is non-negative and sums to \(R^2\) by construction.

Edge rules

NaN means nothing was analysed; 0 means no contribution. The two are never conflated.

Condition Result
no inputs, or no outputs everything NaN
no valid trials everything NaN
too few trials to fit and leave a residual, \(N \le k + 1\) for \(k\) inputs everything NaN. The engine refuses rather than return a rank-deficient fit
an output with no variation, \(SST = 0\) its shares and signed statistics are 0; its \(R^2\) is NaN
an input that never varies share 0 and signed statistic 0. The column is never put into the design matrix at all
every input constant all shares and signed statistics 0, and \(R^2\) is 0
a fit the engine rejects for an output that output's shares and signed statistics are NaN, and its \(R^2\) is NaN

A constant input is excluded rather than dropped by the fit, and that is deliberate. A constant column is an exact multiple of the intercept column, so leaving it in makes the design rank deficient and leaves the solver to notice by a floating-point threshold. That test gets less reliable as the trial count grows: at 2000 rows the dependent column's pivot measured about three machine epsilons against a drop-at-one-epsilon rule, so the column survived, the solve ran at a condition number near \(6 \times 10^{14}\), and \(R^2\) came out wrong in the fourth significant digit. Excluding the column removes the rank-deficient design instead of relying on a threshold to recognise it, and it is the right answer anyway: an input that never varies contributes no variance.

See Also