Top Leaderboard
Markets

Sum of Squares

Ad — article-top

Overview
– The sum of squares (SS) is a basic statistical measure of variability: it quantifies how far observations are from a reference value (typically the mean or predicted value).
– It is central to variance and standard deviation calculations and to regression analysis (where it helps evaluate model fit).
– In finance, SS underpins volatility measurement, regression-based relationship testing (e.g., correlation or beta estimation), and model evaluation.

Key Definitions and Formulas
– Total Sum of Squares (SST): measures total variation of observed values yi around their mean ȳ.
SST = Σi (yi − ȳ)²
– Residual Sum of Squares / Sum of Squared Errors (SSE or RSS): variation not explained by a model — sum of squared differences between observed and predicted values.
SSE = Σi (yi − ŷi)²
– Regression Sum of Squares (SSR): variation explained by the model — sum of squared differences between predicted values and the mean.
SSR = Σi (ŷi − ȳ)²
– Relationship (decomposition): SST = SSR + SSE
– Sample variance (s²) from SST: s² = SST / (n − 1)
– Standard deviation: s = sqrt(s²)
– Coefficient of determination (R²): R² = SSR / SST = 1 − (SSE / SST)

Why squares?
– Squaring deviations ensures all contributions are nonnegative and gives greater weight to larger deviations, which is useful for measuring dispersion and penalizing large errors.

How to calculate the Sum of Squares — practical steps
1. For raw-data variation (SST)
• Step 1: Compute the sample mean ȳ = (1/n) Σi yi.
• Step 2: For each observation, compute the deviation di = yi − ȳ.
• Step 3: Square each deviation: di².
• Step 4: Sum the squared deviations: SST = Σi di².
• Optional: Compute sample variance s² = SST/(n−1) and standard deviation s = sqrt(s²).

2. For regression (SSR and SSE)
• Step 1: Fit the regression model (e.g., OLS) to obtain predicted values ŷi.
• Step 2: Compute residuals ei = yi − ŷi.
• Step 3: SSE = Σi ei² (unexplained variation).
• Step 4: SSR = Σi (ŷi − ȳ)² (explained variation).
• Step 5: Check SST = SSR + SSE; compute R² = SSR/SST to quantify proportion of variance explained.

Worked numeric example (complete, small dataset)
Data: x = [1, 2, 3, 4, 5]; y = [2, 4, 5, 4, 5]
1. Means: x̄ = 3; ȳ = 4
2. Fit simple linear regression via OLS:
• Slope b1 = Σ(xi−x̄)(yi−ȳ) / Σ(xi−x̄)² = 6 / 10 = 0.6
• Intercept b0 = ȳ − b1*x̄ = 4 − 0.6*3 = 2.2
• Predicted ŷi: [2.8, 3.4, 4.0, 4.6, 5.2]
3. Compute sums of squares:
• SST = Σ(yi − ȳ)² = 6.0
• SSR = Σ(ŷi − ȳ)² = 3.6
• SSE = Σ(yi − ŷi)² = 2.4
• Check: SST = SSR + SSE = 6.0
4. Interpretation:
• R² = SSR/SST = 3.6/6.0 = 0.60 → model explains 60% of variance in y.
• SSE = 2.4 shows residual error remaining; smaller SSE means better fit.

How the Sum of Squares Helps in Finance (practical applications)
– Volatility measurement: SST (or variance derived from it) quantifies historical price volatility.
– Risk metrics: variances and covariances (built from sum-of-squares computations) feed portfolio risk and beta estimates.
– Regression analysis: estimating beta, CAPM testing, forecasting returns or sensitivities — SSE and R² indicate how well models explain asset returns.
– Model selection and diagnostics: compare SSE/R² across candidate models; use residual analysis to spot model misspecification or outliers.
– Performance attribution: decomposition of total return variance into explained vs unexplained components.

Practical checklist for financial analysts
– Before computing: ensure data quality (consistent sampling frequency, adjusted prices for splits/dividends).
– Choose the correct SS depending on goal: SST for raw dispersion; SSE/SSR for model evaluation.
– Use sample variance (divide by n−1) when estimating population variance from a sample.
– When comparing datasets, remember SS scales with sample size and unit of measurement — prefer variance, standard deviation, or normalized metrics (R²) for comparisons.
– Inspect residuals for nonlinearity, heteroskedasticity, serial correlation — sum of squares alone doesn’t detect these issues.

Limitations and cautions
– Sensitive to outliers: squaring exaggerates the effect of extreme values.
– Scale-dependent: SS grows with the magnitude of the data and sample size; raw SS isn’t comparable across differently scaled datasets.
– Model dependence: SSR and SSE depend on the chosen model form; a low SSE doesn’t guarantee correct model form or out-of-sample performance.
– Assumptions: regression SS interpretation assumes appropriate model assumptions (linearity, independent errors, homoskedasticity) — violations can mislead.
– Historical bias: SS-based measures rely on past data — they may not predict future behavior.

Quick reference / cheat sheet
– SST = Σ(yi − ȳ)² (total variation)
– SSR = Σ(ŷi − ȳ)² (explained by model)
– SSE = Σ(yi − ŷi)² (unexplained / residual)
– SST = SSR + SSE
– s² (sample variance) = SST / (n − 1)
– R² = SSR / SST = 1 − SSE/SST

The bottom line
The sum of squares is a foundational tool in statistics and finance for quantifying dispersion and evaluating model fit. It is straightforward to compute and underlies variance, standard deviation, and regression diagnostics. However, it must be used with an awareness of scale, sensitivity to outliers, and the assumptions behind any model-based decomposition (SST = SSR + SSE). For finance applications—volatility measurement, beta estimation, model evaluation—SS provides quantitative clarity but should be combined with diagnostic checks and robust out-of-sample validation.

Reference
Michela Buttignol, “Sum of Squares,” Investopedia. (accessed 2025‑10‑14).

Ad — article-mid