4.9.22 · D4 · HinglishProbability Theory & Statistics

ExercisesLinear regression — least squares, inference on coefficients

2,327 words11 min read↑ Read in English

4.9.22 · D4 · Maths › Probability Theory & Statistics › Linear regression — least squares, inference on coefficients

Shuru karne se pehle, hum apna toolbox define kar lete hain (koi bhi cheez use karne se pehle naam de di jaayegi):

Kuch problems mein ek shared dataset (isko Set A bolenge) use hota hai taaki ek hi table par fluency bane:

Figure mein Set A apni least-squares line (cyan) ke saath dikhaya gaya hai, centroid (amber cross) ke saath, aur residuals amber vertical segments ke roop mein. L2 aur L3 karte waqt ise khula rakho — line woh hai jo tum fit karte ho, segments woh hain jo tum SSE pane ke liye square karte ho.

Figure — Linear regression — least squares, inference on coefficients

Level 1 — Recognition

L1.1 — Ek line se pieces padho

Kuch data ka fitted line hai . (a) Estimated slope kya hai? (b) Estimated intercept kya hai? (c) Slope ka matlab words mein kya hota hai?

Recall Solution

(a) Slope woh number hai jo ko multiply kar raha hai: . (b) Intercept woh standalone number hai (jab ho tab ki value): . (c) "Jab bhi se badhta hai, fitted average par se badhta hai." Slope ek rate hai, total nahi.

L1.2 — Kaun sa number kaun sa hai?

Set A ke liye bataya gaya hai ki . compute karo.

Recall Solution

. Mean sirf add-karke-divide hai; yahan hai.


Level 2 — Application

L2.1 — Set A par haath se line fit karo

, use karke compute karo, phir aur .

Recall Solution

Pehle Means (sab kuch inhi par centre hota hai): , .

Centred deviations : .

Centred deviations : . Pairwise multiply karke add karo: (Term by term: .)

Slope = co-movement divided by -spread: . Intercept (line ko se guzarata hai): . Fitted line: .

L2.2 — Centroid par predict karo aur check karo

L2.1 ki line use karke par predict karo, aur verify karo ki line se guzarti hai.

Recall Solution

par: . par: ✓. Least-squares line hamesha centre of mass se guzarti hai — ek free sanity check.


Level 3 — Analysis

L3.1 — Standard error aur -statistic

Set A ke liye () residuals hain aur residual sum of squares hai (yeh given maan lo). , , , aur test karne ka -statistic compute karo. (Ye inference steps upar toolbox mein bataye gaye error conditions assume karte hain.)

Recall Solution

Residual variance (do coefficients estimate hue isliye se divide karo): Standard error of the slope (toolbox mein define hai — zyada -spread se precision badhti hai): -statistic (slope zero se kitne SEs dur hai):

L3.2 — Significance decide karo

Critical value . 5% level par, kya hum reject karte hain? 95% CI banao.

Recall Solution

, isliye hum reject karte hain: slope significant hai. 95% CI: . Interval mein nahi hai — rejection ke saath consistent hai. Notice karo ki yeh same decision do angles se aa raha hai (Hypothesis Testing se, ya t-distribution ke saath df wale CI se).


Level 4 — Synthesis

L4.1 — Decomposition se

Set A ke liye, aur hai. do tarike se compute karo (SSE ke zariye aur SSR ke zariye) aur confirm karo ki , jahan Correlation coefficient hai.

Recall Solution

Total up–down variation: . Residual (unexplained): . Explained: .

R^2=\frac{\text{SSR}}{\text{SST}}=\frac{24.0190}{31.3333}=0.7666.\ \checkmark$$ **Correlation check (exact):** $r^2 = \dfrac{S_{xy}^2}{S_{xx}S_{yy}}=\dfrac{20.5^2}{17.5\cdot31.3333}=\dfrac{420.25}{548.33}=0.7664.$ $0.7666$ se thoda sa gap sirf "given" SSE mein rounding ki wajah se hai; exact arithmetic se $R^2=r^2$ identically milta hai. Line $y$ ki variance ka lagbhag **77\%** explain karta hai.

L4.2 — Lever effect forecast karo phir verify karo

Data se recompute kiye bina: suppose karo ki tum 's ka spread triple kar sako (toh bada ho jaaye) jabki same rahe. Predict karo ki ka kya hoga, phir formula se confirm karo. Physically iska kya matlab hai?

Recall Solution

Predict: . Agar , toh , isliye SE ko ek-tihaai ho jaana chahiye. Numerically verify karo: old SE ; new SE , aur ✓. Physical meaning: wide-spread values line ko lambi lever arm dete hain, isliye same vertical wobble slope ko kaafi zyada precisely pin karta hai — yeh Gauss–Markov Theorem ki us baat ki echo hai ki spread-out design points least-squares estimator ko sharp banate hain.


Level 5 — Mastery

L5.1 — Slope ki variance scratch se rebuild karo

se shuru karo jahan weights hain, aur independent errors ke saath use karke prove karo ki . Dikhao ki itne neat kyun collapse hote hain.

Recall Solution

Hum kya karte hain: ko random ka ek fixed weighted sum treat karo. Independent terms ke liye, sum ki variance, (weight variance) ka sum hai: Kyun: independence saare cross-covariance terms ko khatam kar deti hai — sirf diagonal bachti hai. Ab collapse:

=\frac{S_{xx}}{S_{xx}^2}=\frac{1}{S_{xx}}.$$ Isliye $\text{Var}(\hat\beta_1)=\dfrac{\sigma^2}{S_{xx}}$. Numerator sum-of-squares *hi* $S_{xx}$ hai, isliye ek power cancel ho jaati hai. Yeh "long lever" fact rigorous roop mein prove hua hai, aur $\sigma^2$ ki jagah $s^2$ daalne se $\text{SE}(\hat\beta_1)=s/\sqrt{S_{xx}}$ milta hai jo humne L3 mein assume kiya tha. (Gaussian errors ke under yeh variance, ek $t$-ratio mein plug hoke, wahi deta hai jo [[Maximum Likelihood Estimation]] bhi deta.)

L5.2 — Naye data par poora pipeline

Naya dataset Set B: , . Poora kaam karo: , , , , ka -statistic, aur 5% par significance decision ().

Recall Solution

Means: , . -deviations: . -deviations: . . Slope: . Intercept: . Line .

Fitted values: . Residuals : . , . . on df. Kyunki , hum 5% par reject karte hain: sirf 5 points ke saath bhi slope significant hai, kyunki fit tight hai aur 's spread hain.


Recall Ek-line self-test

Least squares ka slope ::: SSE ko se kyun divide karte hain ::: do constraints (, ) 2 df hata dete hain, jisse unbiased ho jaata hai chhota kya banata hai ::: bada (spread-out ) aur chhota (kam noise) ek phrase mein ::: ki variance ka woh fraction jo line explain karti hai, yahan ke barabar hai