Contact

LEVERAGE Function (Gnumeric)

Statistical Intermediate Gnumeric

Calculate regression leverage in Gnumeric from a numeric design matrix, explicit intercept columns and independently checked hat-matrix diagonals.

Verification status: Gnumeric 1.12.57 ssconvert: specified LEVERAGE fixtures and separately captured worked-example GUI. Gnumeric 1.12.62 source inspected separately. How formula examples are checked

LEVERAGE returns regression leverage values for the rows of a supplied design matrix. Each value measures how strongly that row’s predictor position can influence its own fitted value in an ordinary least-squares model. A high-leverage observation is unusual in predictor space; it is not necessarily an outlier in the response, and high leverage alone does not prove a data error.

Syntax and matrix contract

=LEVERAGE(A)

A is the required numeric design matrix. There are no optional arguments or defaults. Each row is an observation and each column is a model term. The result is a single column with one value per row of A.

The mathematical result is the diagonal of H = A×(AᵀA)⁻¹×Aᵀ. The design must have independent columns for this ordinary full-rank expression. An intercept is not added automatically. Include a column of ones yourself if the fitted model contains a constant term.

Select the entire output column, type the formula and press Ctrl+Shift+Enter for Gnumeric array entry. Keep labels outside the numeric matrix. Clean complete observations consistently across model terms rather than assuming one column’s missing entries can be discarded independently.

Worked example: intercept plus one predictor

Enter this design in A1:B3:

Row A: intercept B: predictor
1 1 0
2 1 1
3 1 2

Select D1:D3 and array-enter =LEVERAGE(A1:B3). The expected result is 5/6, 1/3, 5/6, approximately 0.833333333333333, 0.333333333333333 and 0.833333333333333.

An independent calculation for a straight-line model with an intercept is hᵢ = 1/n + (xᵢ−mean(x))² / SUM((x−mean(x))²). Here n = 3, the predictor mean is 1 and the centered sum of squares is 2. The outer points therefore have leverage 1/3 + 1/2 = 5/6, while the central point has leverage 1/3.

Enter =SUM(D1:D3) in D5. The expected total is 2, equal to the number of independent design columns, including the intercept. Their average is 2/3. These are useful audit checks for this full-rank design, not evidence that every row has the same leverage.

Advanced use: detect an accidentally omitted intercept

For comparison, select F1:F3 and array-enter =LEVERAGE(B1:B3). The independently expected output for this one-column through-origin design is 0, 1/5, 4/5. The sum is now 1, because the design has only one independent column.

The difference is intentional: the model changed. LEVERAGE does not know that the analyst intended an intercept, and it does not infer one from a response column elsewhere in the sheet. Keep the leverage matrix identical to the predictor design used for the fit.

A diagnostic threshold such as a multiple of p/n can be a screening convention, but it is not a universal decision rule. With only three observations and two parameters, leverage is necessarily large on average. Inspect residuals and the study context before deciding that a high-leverage row should be excluded. Leverage itself needs only the design matrix; response values are used in other diagnostics of influence and fit.

Errors and troubleshooting

  • Empty input produces #VALUE! in the examined callback.
  • Dependent columns, such as a predictor and exactly twice that predictor, create a singular design. The retained help says singular input yields #VALUE!; the actual callback uses #NUM! for an unacceptable numerical status. The native singular fixture described below returned #NUM!.
  • More model columns than observations cannot produce a full-column-rank ordinary design. Reduce or justify the model rather than treating a numerical error as zero leverage.
  • Nearly dependent columns can make calculations unstable. Retain source precision and inspect redundant variables or units with extreme scaling.
  • For a valid full-rank projection, leverage lies between 0 and 1, within numerical tolerance. Large violations call for investigation, not clipping values to the interval.
  • If the output is shorter than the observation count, check array entry and selection dimensions. The result is one value per row, not one value per model term.

Version and verification scope

Official NEWS and the 1.12.1 announcement identify LEVERAGE as added in Gnumeric 1.12.1. The retained implementation inspected here is from 1.12.62. Gnumeric 1.12.57 ssconvert recalculated the three worked leverage values and a dependent-column fixture on 17 October 2026 in C.UTF-8. The through-origin comparison is independently checked algebra, not a separately claimed native run. The separate GUI screenshot below covers only the worked example; no all-version guarantee is implied.

MMULT, MINVERSE and TRANSPOSE express the projection formula, while SUM checks the diagonal total.

Official sources

Native application screenshot

Gnumeric LEVERAGE worked example with synthetic inputs, formula bar and calculated results

Gnumeric 1.12.57, captured 17 October 2026. Design A1:B3 includes intercept; leverage D1:D3. The selected cell D1 shows the formula in the formula bar. Display precision is shorter than the independent reference values; integer cells may show a trailing decimal point. GUI locale was not independently recorded.