Module 9 · Dependence, Regression, and Model Foundations Lesson 90 of 120

Regression Assumptions, Heteroskedasticity, and Multicollinearity

Diagnosing unstable uncertainty and redundant predictors.

2:56 clip4:46:20–4:49:17 in the full courseWatch on YouTube

Transcript

19 sentences · select one to jump there

Check your understanding

Does a robust standard error automatically solve omitted-variable confounding?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

090-regression-assumptions-heteroskedasticity-and-multicollinearity.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 090 of 120
 * Regression Assumptions, Heteroskedasticity, and Multicollinearity
 * Module 09: Dependence, Regression, and Model Foundations
 *
 * Scenario: Diagnosing unstable uncertainty and redundant predictors
 * Rule:     nonconstant error variance; collinearity creates unstable coefficient identification
 *
 * Try it:   Does a robust standard error automatically solve omitted-variable confounding?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/dependence-regression-and-model-foundations/regression-assumptions-heteroskedasticity-and-multicollinearity/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson090() {
  const lowErrors=[-1,1],highErrors=[-4,4];
  const meanSquare=(a:number[])=>a.reduce((s,x)=>s+x*x,0)/a.length;
  const x=[1,2,3,4],duplicate=x.map(v=>2*v);
  const avg=(a:number[])=>a.reduce((s,v)=>s+v,0)/a.length;
  const dx=x.map(v=>v-avg(x)),dd=duplicate.map(v=>v-avg(duplicate));
  const dot=(a:number[],b:number[])=>a.reduce((s,v,i)=>s+v*b[i],0);
  const r2Between=dot(dx,dd)**2/(dot(dx,dx)*dot(dd,dd)); // 1 means VIF is infinite
  const result={lowSpread:meanSquare(lowErrors),highSpread:meanSquare(highErrors),
    exactRedundancy:r2Between===1};
  return result;
}

export const checkedResult = {"lowSpread":1,"highSpread":16,"exactRedundancy":true};

// Run this file directly: npx tsx lessons/09-dependence-regression-and-model-foundations/090-regression-assumptions-heteroskedasticity-and-multicollinearity.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson090(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

{
  "lowSpread": 1,
  "highSpread": 16,
  "exactRedundancy": true
}

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

nonconstant error variance; collinearity creates unstable coefficient identification