∑GATE DA Atlas

Simple and Multiple Linear Regression

The linear model and least-squares estimation — closed-form slope and intercept for simple regression, the matrix form and normal equations for multiple regression, geometric interpretation as projection, properties of residuals, R² and its link to correlation, assumptions and diagnostics, interpreting coefficients, categorical predictors and interactions, multicollinearity, and fitting by gradient descent.

Section 610 practice questions

The linear model

y=β0+β1x1+⋯+βpxp+ε,y^=β^0+β^1x1+⋯+β^pxp.y = \beta_0 + \beta_1x_1 + \dots + \beta_px_p + \varepsilon, \qquad \hat y = \hat\beta_0 + \hat\beta_1x_1 + \dots + \hat\beta_px_p.

"Linear" refers to linearity in the parameters: y=β0+β1x+β2x2y = \beta_0 + \beta_1x + \beta_2x^2 (polynomial regression) and y=β0+β1log⁡xy = \beta_0 + \beta_1\log x are still linear regressions.

Simple linear regression

Minimise SSE(β0,β1)=∑i(yi−β0−β1xi)2\text{SSE}(\beta_0, \beta_1) = \sum_i(y_i - \beta_0 - \beta_1x_i)^2. Setting both partial derivatives to zero:

β^1=SxySxx=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2=r sysx,β^0=yˉ−β^1xˉ.\hat\beta_1 = \frac{S_{xy}}{S_{xx}} = \frac{\sum(x_i - \bar x)(y_i - \bar y)}{\sum(x_i - \bar x)^2} = r\,\frac{s_y}{s_x}, \qquad \hat\beta_0 = \bar y - \hat\beta_1\bar x.
ŷ = β̂₀ + β̂₁xresidual eᵢ = yᵢ − ŷᵢ OLS minimises the sum of the squared dashed lengths
Least squares fits the line minimising squared vertical residuals.

Properties of the OLS fit (with an intercept):

  • residuals sum to zero, ∑ei=0\sum e_i = 0, and are orthogonal to xx: ∑xiei=0\sum x_ie_i = 0;
  • the line passes through (xˉ,yˉ)(\bar x, \bar y);
  • SStot=SSreg+SSresSS_{tot} = SS_{reg} + SS_{res}, and R2=SSreg/SStot=r2R^2 = SS_{reg}/SS_{tot} = r^2;
  • the regression of xx on yy is a different line (slope product =r2= r^2).

Multiple linear regression

Stack the data into the design matrix XX (n×(p+1)n \times (p+1), a column of ones for the intercept):

β^=arg⁡min⁡∥y−Xβ∥2=(X⊤X)−1X⊤y.\hat{\boldsymbol\beta} = \arg\min\lVert\mathbf y - X\boldsymbol\beta\rVert^2 = (X^\top X)^{-1}X^\top\mathbf y.

Geometry: y^=Xβ^=Hy\hat{\mathbf y} = X\hat{\boldsymbol\beta} = H\mathbf y is the orthogonal projection of y\mathbf y onto the column space of XX, with hat matrix H=X(X⊤X)−1X⊤H = X(X^\top X)^{-1}X^\top; the residual vector is orthogonal to every column (see projections).

Interpretation: β^j\hat\beta_j is the expected change in yy for a one-unit increase in xjx_j holding the other features fixed. Coefficients from a multiple regression can differ (even in sign) from simple-regression slopes when features are correlated.

Categorical predictors and interactions

  • A categorical feature with kk levels becomes k−1k - 1 dummy (one-hot) variables; using all kk with an intercept makes XX rank-deficient (the dummy-variable trap).
  • An interaction term x1x2x_1x_2 lets the effect of x1x_1 depend on x2x_2.

Assumptions and diagnostics

For inference (standard errors, t-tests, confidence intervals) the classical assumptions are: linearity, independent errors, homoscedasticity (constant error variance), normally distributed errors, and no perfect multicollinearity. Under the first four (Gauss–Markov without normality), OLS is the best linear unbiased estimator (BLUE); with normal errors it is also the maximum likelihood estimator.

ProblemSymptomRemedy
Non-linearitycurved residual plottransform features, polynomial terms
Heteroscedasticityfunnel-shaped residualstransform yy (log), weighted least squares
Outliers / leveragepoints far from the restrobust regression, investigate data
Multicollinearityunstable, large coefficients; high VIFremove/combine features, ridge
Too many features (pp close to nn)overfitting, singular X⊤XX^\top Xregularisation, feature selection

Each coefficient's significance is tested with t=β^j/SE(β^j)t = \hat\beta_j/\text{SE}(\hat\beta_j) on n−p−1n - p - 1 degrees of freedom; the error variance is estimated by σ^2=SSres/(n−p−1)\hat\sigma^2 = SS_{res}/(n - p - 1).

Fitting by gradient descent

When pp is large, solving the normal equations (O(np2+p3)O(np^2 + p^3)) is replaced by gradient descent on the MSE:

∇β1n∥Xβ−y∥2=2nX⊤(Xβ−y),β←β−η 2nX⊤(Xβ−y).\nabla_{\boldsymbol\beta}\frac1n\lVert X\boldsymbol\beta - \mathbf y\rVert^2 = \frac2n X^\top(X\boldsymbol\beta - \mathbf y), \qquad \boldsymbol\beta \leftarrow \boldsymbol\beta - \eta\,\frac2nX^\top(X\boldsymbol\beta - \mathbf y).

The loss is convex (a quadratic bowl), so gradient descent converges to the global minimum for a small enough η\eta; feature scaling speeds it up dramatically. Stochastic or mini-batch versions use a subset of rows per step.

Quick revision

Practice questions

GATE-style questions: 5 one-mark and 5 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.

Q1NAT2 marks

For the data (x,y)(x, y): (1,2),(2,4),(3,5),(4,4),(5,5)(1, 2), (2, 4), (3, 5), (4, 4), (5, 5), the least-squares slope β^1\hat\beta_1 of y=β0+β1xy = \beta_0 + \beta_1x is ______.

Q2NAT1 mark

For the same data (1,2),(2,4),(3,5),(4,4),(5,5)(1, 2), (2, 4), (3, 5), (4, 4), (5, 5), the least-squares intercept β^0\hat\beta_0 is ______.

Q3NAT1 mark

Using the fitted line y^=2.2+0.6x\hat y = 2.2 + 0.6x, the predicted value at x=6x = 6 is ______.

Q4MCQ1 mark

Ordinary least squares chooses the regression coefficients that minimise

Q5NAT2 marks

For the data (1,2),(2,4),(3,5),(4,4),(5,5)(1, 2), (2, 4), (3, 5), (4, 4), (5, 5) with fitted line y^=2.2+0.6x\hat y = 2.2 + 0.6x, the coefficient of determination R2R^2 is ______.

Q6MSQ2 marks

For an OLS fit of y=β0+β1xy = \beta_0 + \beta_1x (with intercept), which statements always hold?

One or more options are correct.

Q7MCQ2 marks

In matrix form y=Xβ+ε\mathbf y = X\boldsymbol\beta + \boldsymbol\varepsilon with XX of full column rank, the least-squares estimate is

Q8NAT1 mark

A fitted multiple regression model is y^=3+2x1−0.5x2\hat y = 3 + 2x_1 - 0.5x_2. Its prediction for x1=4x_1 = 4, x2=6x_2 = 6 is ______.

Q9MCQ1 mark

Two features in a multiple regression are almost perfectly correlated. The most likely consequence is

Q10NAT2 marks

The model y^=wx\hat y = wx (no intercept) is fitted to the points (1,2)(1, 2) and (2,4)(2, 4) by gradient descent on J(w)=1n∑i(wxi−yi)2J(w) = \frac1n\sum_i(wx_i - y_i)^2, starting from w=0w = 0 with learning rate 0.10.1. The value of ww after one update is ______.