4.9.23 · D3 · HinglishProbability Theory & Statistics

Worked examplesMultiple regression

3,073 words14 min read↑ Read in English

4.9.23 · D3 · Maths › Probability Theory & Statistics › Multiple regression

Yeh page ek lambi practice hall hai. Hum yahan har tarah ki situation walk through karte hain jo ek multiple-regression problem de sakta hai — clean data, degenerate data, collinear data, ek real-world story, aur ek exam trick — aur har ek ko scratch se solve karte hain. Agar koi symbol yahan aisa hai jo tumne pehle nahi dekha, hum pehle usse build karte hain.

Shuru karne se pehle, parent note se ek reminder: poora game hai solve karna, jahan predictors ki table hai (ek leading column of 's ke saath), outcome column hai, aur woh numbers ki list hai jo hum chahte hain: intercept aur slopes.

Hume fit judge karne ke liye teen "sum of squares" quantities bhi chahiye hongi. Inhe abhi build karte hain taaki baad mein koi surprise na ho:


The scenario matrix

Neeche har problem inhi cells mein se kisi ek mein aati hai. Point yeh hai ki is page ke baad tumne har cell kam se kam ek baar dekhi hai, toh exam mein kuch bhi sach mein naya nahi hoga.

Cell Kya special banata hai isse Example
A. Clean full-rank fit predictors independent, invertible Ex 1
B. Single predictor sanity multiple-regression machinery ko simple regression tak reduce karna hoga Ex 2
C. Negative slope ek predictor jo ko neeche laata hai Ex 3
D. Prediction + interpretation fitted plane mein ek naya point plug karo, partial slope padho Ex 4
E. Degenerate: perfect collinearity singular, inverse exist nahi karta Ex 5
F. Near-collinearity (VIF blow-up) inverse exist karta hai but coefficients explode ho jaate hain Ex 6
G. Fit quality: and adjusted "useless extra predictor" limiting case bhi include karte hue Ex 7
H. Real-world word problem ek story ko mein translate karo Ex 8
I. Exam twist centring / rescaling coefficients change karta hai but fit nahi Ex 9

Ex 1 — Cell A: ek clean full-rank fit

Forecast: guess karo — kya slope positive hai, aur kya yeh se bada hai ya chhota? (Dots generally upar jaate hain.)

  1. build karo. 's ka leading column, phir column: Yeh step kyun? -column woh tarika hai jisse intercept algebra mein enter karta hai — yeh har row mein se multiply karta hai.

  2. aur banao — aur dekho ki har entry kahan se aati hai. Yahan (chaar rows), , aur . Toh aur . Yeh step kyun? (ek matrix jiska pehla row saare 's hai aur doosra row 's hai) ko ek column se multiply karna literally cheezein add karta hai: 's ki row times column ek simple sum hai; -row times column har entry ko se weight karta hai. Yeh exactly wahi sums hain jo simple regression use karta hai.

  3. system solve karo. Ek matrix ke liye inverse hai . Yahan . Toh .

Determinant flag kyun karo? , toh inverse genuinely exist karta hai (Matrix Inverse) — machinery sound hai. Safe habit yeh hai ki hamesha ek plug-back check se bachna chahiye (Ex 2).

Verify: VERIFY block exact system symbolically solve karta hai: correct line hai , jo deta hai jisme residuals ka sum hai.

Neeche ki figure yeh chaar points plot karti hai, fit line ko yellow mein draw karti hai, aur har residual (dot se line tak pink vertical stick) mark karti hai. Pink sticks dekho: yeh vertical gaps hain jise least squares jitna ho sake chhota karta hai, aur inki signed lengths ka sum zero hota hai.

Figure — Multiple regression

Ex 2 — Cell B: machine ko simple regression tak reduce karna hoga

Forecast: honest slope 1 se kam hona chahiye (dots upar jaate hain but perfect line par nahi). Guess: around ?

  1. Data centre karo. . Deviations , . Yeh step kyun? Centring slope calculation se intercept hata deta hai — "tilt" ko isolate karta hai. Simple-regression slope formula ka single-predictor special case hai, toh agar dono disagree karein toh hum se arithmetic slip hui hai.

  2. Numerator (covariation) .

  3. Denominator ( ka spread) .

  4. Slope , aur intercept .

Yeh Ex 1 se kyun match karta hai: do independent routes — Ex 1 mein matrix inverse aur yahan centred slope formula — dono par land karte hain. Yeh agreement sabse strong sanity check hai jo hamare paas hai.

Verify: ke saath, predictions hain , residuals jo sum to hote hain. ✓


Ex 3 — Cell C: genuinely negative slope

Forecast: zyada maintenance → kam defects, toh slope negative hona chahiye. Uska size guess karo.

  1. Sums. . Yeh step kyun? Yeh chaar sums hi sab kuch hain jo aur ko chahiye — exactly wahi pattern aur jo humne Ex 1 Step 2 mein build kiya tha.

  2. Normal equations.

  3. Determinant , toh Toh .

Negative kyun theek kaam karta hai: least squares kabhi positive slopes demand nahi karta; sign bas data ki tilt follow karta hai.

Verify: exactly se match karta hai — points perfectly collinear hain, toh saare residuals hain aur . Units: defects per (maintenance hour) , meaning har extra hour par 2 kam defects. ✓


Ex 4 — Cell D: do predictors, predict aur interpret karo

Forecast: plug in karna ek weighted sum hai; sleep ka effect per hour bas hai.

  1. (a) Substitute karo. . Yeh step kyun? Model linear hai, toh prediction literally coefficient vector aur ka dot product hai.

  2. (b) Partial slope. ko se change karo, fixed rakho: . " fixed rakho" kyun: partial slope hai — sleep ka unique contribution study account karne ke baad (Orthogonal Projection ki wajah se yeh "baad" clean hai).

Verify: (a) ko ek chhoti nudge ke saath recompute karo: par, , jo hai — per study hour ke saath consistent. Units check: points, aur points-per-hour. ✓


Ex 5 — Cell E: perfect collinearity, inverse mar jaata hai

Forecast: do columns same information carry kar rahe hain — machine ko choke karna chahiye.

  1. Columns dekho. column exactly column hai. Ek doosre ki copy hai (scaled). Yeh kyun matter karta hai: ka column space plane mein "flat" hai — predictors genuine 2D direction span nahi karte.

  2. Determinant explicitly compute karo. Sirf do length columns ke saath ek tiny two-row example lo (intercept drop karo clean ke liye algebra visible banane ke liye): , Ab determinant, entry by entry: Toh exactly — do products cancel karte hain kyunki doosra column pehla hai, jo aur patterns force karta hai jo aur ko equal banaate hain.

  3. Koi inverse nahi. Kyunki determinant hai, formula zero se divide karta hai: exist nahi karta. Infinitely many equally minimise karte hain — plane redundant direction mein zero cost par freely tilt ho sakta hai. Kyun: ek "flat" matrix se divide karna zero se divide karne jaisa hai — dekho Multicollinearity & VIF aur Positive Semidefinite Matrices ( yahan sirf semidefinite hai, positive definite nahi).

Verify: VERIFY block puri teen-column version ke liye bhi confirm karta hai. Fix: do length columns mein se ek drop karo; bacha hua fit unique hai. ✓

Neeche ki figure do predictor columns ko arrows ki tarah origin se draw karti hai. Kyunki , pink arrow blue wale ki direction ke exactly upar lie karta hai (sirf uski length differ karti hai). Ek hi direction mein point karne wale do arrows genuinely 2-D area ka patch frame nahi kar sakte — aur zero area hai ek zero determinant.

Figure — Multiple regression

Ex 6 — Cell F: near-collinearity, coefficients explode ho jaate hain

Forecast: inverse exist karta hai (determinant tiny but nonzero) phir bhi answer unstable hai.

  1. Kyun unstable: ek near-zero determinant se divide karta hai, tiny data changes ko huge coefficient swings mein magnify karta hai. Yeh step kyun? Yeh Multicollinearity & VIF ka practical chehra hai.

  2. Concrete blow-up. ke liye least-squares fit ek baar solve karo, phir last outcome se change karo aur dobara solve karo. Dono slopes ek mere -unit data nudge se substantially shift ho jaate hain — exact rational before/after values, aur swing ka size, VERIFY block mein compute kiye gaye hain. Yeh kyun hota hai: aur sirf last entry mein differ karte hain, toh fit ko us ek distinguishing coordinate par heavily lean karna padta hai; wahan ek tiny wobble dono slopes ko whipsaw kar deta hai.

  3. VIF summary. ko par regress karo; near-perfect fit ke close deta hai, toh variance inflation factor bahut bada hai. par yeh ke barabar hai; standard errors ke saath scale karte hain. High VIF Step 2 ke whipsaw ke liye early-warning gauge hai.

Verify: VERIFY confirm karta hai (i) yahan small-but-positive hai (inverse exist karta hai, Ex 5 ki tarah nahi); (ii) do coefficient vectors -unit nudge ke baad noticeably differ karte hain; aur (iii) . ✓


Ex 7 — Cell G: , adjusted , aur useless predictor limit

Forecast: hamesha rise karta hai jab tum variable add karte ho; adjusted junk ke liye fall karna chahiye.

  1. (a) . . Yeh step kyun? fraction of variance explained hai: leftover error total wobble ke share ke roop mein, se subtract karke.

  2. Adjusted with : Yeh step kyun? Degrees of freedom se divide karna har extra predictor ko penalise karta hai.

  3. (b) Junk add karo. Ab , , toh (thoda rise hua, hamesha ki tarah). But Adjusted fall hua se tak.

Kyun: useless predictor ne ek degree of freedom cost ki ( drop hua) but error barely reduce ki — ek bura trade.

Verify: VERIFY charon numbers () recompute karta hai aur confirm karta hai ki adjusted value drop hua. ✓


Ex 8 — Cell H: ek real-world word problem

Forecast: garme din zyada bikta hai (positive ), weekends zyada bikta hai (positive ).

  1. Teen equations set up karo. Yeh step kyun? Exactly utne hi points jitne unknowns hain aur independent rows ke saath, plane teeno se guzarta hai — koi least-squares averaging ki zaroorat nahi.

  2. Eqn 1 eqn 2 se subtract karo: ($4 revenue per °C).

  3. Eqn 1 eqn 3 se subtract karo: (weekend par $60 extra).

  4. Eqn 1 mein back-substitute karo: .

Verify: plug karo: ✓; plug karo: ✓. Units: dollars, dollars-per-degree, dollars-per-weekend. ka interpretation: weekend bump temperature fixed rakhte hue — ek clean partial effect. ✓


Ex 9 — Cell I: exam twist (centring coefficients change karta hai, fit nahi)

Forecast: slope rehna chahiye (steepness axis shift se unaffected hoti hai); intercept change hona chahiye taaki line same points se guzarti rahe.

  1. Slope shifting ke liye invariant hai. ko se replace karna aur covariation ko unchanged chhod deta hai, toh . Yeh step kyun? Centring vertical axis ko left/right slide karta hai; yeh line ko tilt nahi karta, aur slope formula sirf mean se deviations par depend karta hai, jise shifting alter nahi kar sakti.

  2. Naya intercept = par fitted value, yani par: . Toh . Kyun: jab hota hai hum ke mean par baithte hain; ek least-squares line hamesha point se guzarti hai, aur . Isliye centred intercept ke barabar hota hai.

  3. Fit unchanged. Predictions — algebraically Ex 3 se identical. Toh , har residual, aur har prediction exactly same hai; sirf labels vs moved hue.

Verify: VERIFY confirm karta hai aur ki centred predictions original ke barabar hain. Lesson: predictors ko rescale/centre karna coefficients reshuffle karta hai but fit ki quality kabhi nahi — exam questions se savdhan raho jo ise ek scary-looking coefficient change ke peeche chhupa dete hain.


Recall Tumhare liye kaun sa cell sabse hard tha?

Perfect collinearity (Ex 5) fail hoti hai ::: kyunki singular hai (), toh exist nahi karta aur unique nahi hai. Adjusted useless predictor ke liye fall karta hai ::: kyunki shrink hota hai (lost degree of freedom) jabki barely drop hota hai — ek bura trade. ko centre karna intercept change karta hai ::: tak (fitted value ke mean par), jabki slope aur fit unchanged rehti hain.