SST 305 • UNIT 6 • Statistics
Least Squares Estimation
Topics covered: Matrix notation for least squares, Fitting a straight line
Syllabus Study Notes (Core Overview)
Free Overview Preview1. Purpose and Statistical Context
1.1 Where least squares fits in estimation
Statistical estimation uses information from a sample to learn about an unknown population characteristic. A population characteristic is called a parameter; a quantity calculated from observed sample data is a statistic. In regression, the parameters describe how a response variable changes with an explanatory variable. The method of least squares estimates those regression parameters by choosing the line whose fitted values are, in total, as close as possible to the observed responses in squared-error terms.
This lesson concerns fitting a straight line. It does not claim that every relationship in data is linear. Rather, it begins with the working model that the mean response changes linearly with the explanatory value. The line's intercept and slope are unknown constants, and the sample is used to estimate them.
1.2 Learning goals for this topic
After studying this topic, a learner should be able to:
- Express a straight-line model in scalar notation and in matrix notation.
- Explain what a residual is and why least squares minimizes the sum of squared residuals.
- Derive the two normal equations by differentiating the sum of squared errors.
- Solve for the least-squares slope and intercept from summary sums or from the matrix formula.
- Build the design matrix, parameter vector, and response vector for given observations.
- Interpret the fitted line and check the arithmetic in a worked problem.
- State why, under the source's zero-mean error assumptions, the least-squares coefficient estimators are unbiased.
1.3 Why use a line and why square errors?
Suppose measurements $y_1,\ldots,y_n$ are observed at explanatory values $x_1,\ldots,x_n$. If the mean of $Y$ varies linearly with $X$, the model is
$$
y_i=\alpha+\beta x_i+e_i,\qquad i=1,2,\ldots,n.
$$
Here $\alpha+\beta x_i$ is the line's fitted mean at $x_i$, while $e_i$ represents the difference between the observed value and that line. A candidate line can lie above some observations and below others. The signed differences could cancel if simply added, even if the line fits poorly. Squaring each difference makes every contribution nonnegative and gives larger residuals more influence. The method selects $\alpha$ and $\beta$ to minimize
$$
S(\alpha,\beta)=\sum_{i=1}^{n}e_i^2
=\sum_{i=1}^{n}(y_i-\alpha-\beta x_i)^2.
$$
The result is called the least-squares fitted line. It is the line with the smallest sum of squared vertical residuals among straight lines for the given data.
2. Definitions and Assumptions
2.1 The straight-line regression model
The approved lecture material assumes observations at explanatory values $x_1,\ldots,x_n$ and models the corresponding responses as
$$
y_i=\alpha+\beta x_i+e_i.
$$
The symbols have these meanings:
- $y_i$ is the observed response for observation $i$.
- $x_i$ is the given explanatory value for observation $i$.
- $\alpha$ is the intercept, the fitted mean response at $x=0$.
- $\beta$ is the slope, the change in fitted mean response for a one-unit increase in $x$.
- $e_i$ is the error for observation $i$, the difference between the response and its modelled mean.
- $n$ is the number of paired observations.
The source assumes the errors are independent, have mean zero, and share variance $\sigma^2$:
$$
E(e_i)=0,\qquad \operatorname{Var}(e_i)=\sigma^2.
$$
The fitted value and residual should not be confused. For estimated coefficients, the fitted value is $\hat y_i=\hat\alpha+\hat\beta x_i$, and the residual is $r_i=y_i-\hat y_i$. The original model error $e_i$ is not directly observed because the true parameters are unknown; the residual is calculated after fitting the line.
2.2 The least-squares criterion
For any proposed pair $(\alpha,\beta)$, the residual at point $i$ is $y_i-\alpha-\beta x_i$. The total squared error is therefore
$$
S(\alpha,\beta)=\sum_{i=1}^{n}(y_i-\alpha-\beta x_i)^2.
$$
Least squares chooses the coefficients that give the smallest possible value of $S$. The observations $x_i$ are treated as the given design values in this calculation. A unique straight-line fit requires the explanatory values not all to be identical; otherwise the intercept and slope cannot be separately determined from the data.
2.3 Matrix notation and dimensions
For $n$ observations, stack all responses into one column vector, place a column of ones beside the explanatory values, and stack the two unknown coefficients into another column vector:
$$
\mathbf y=
\begin{pmatrix}
y_1\
y_2\
\vdots\
y_n
\end{pmatrix},\qquad
X=
\begin{pmatrix}
1&x_1\
1&x_2\
\vdots&\vdots\
1&x_n
\end{pmatrix},\qquad
\boldsymbol\theta=
\begin{pmatrix}
\alpha\
\beta
\end{pmatrix},\qquad
\mathbf e=
\begin{pmatrix}
e_1\
e_2\
\vdots\
e_n
\end{pmatrix}.
$$
The model becomes
$$
\mathbf y=X\boldsymbol\theta+\mathbf e.
$$
The dimensions provide a useful check: $\mathbf y$ is $n\times1$, $X$ is $n\times2$, $\boldsymbol\theta$ is $2\times1$, and $\mathbf e$ is $n\times1$. Thus $X\boldsymbol\theta$ is also $n\times1$, as required to represent all fitted responses. The first column of $X$ contains ones because the model has an intercept; the second contains the observed $x_i$ values because the slope multiplies $x_i$.
For matrices, the prime symbol denotes transpose. The least-squares criterion can be written compactly as
$$
S(\boldsymbol\theta)=\mathbf e^{\mathsf T}\mathbf e
=(\mathbf y-X\boldsymbol\theta)^{\mathsf T}(\mathbf y-X\boldsymbol\theta).
$$
The matrix $X^{\mathsf T}X$ is $2\times2$ and $X^{\mathsf T}\mathbf y$ is $2\times1$. The inverse $(X^{\mathsf T}X)^{-1}$ exists when the two columns of $X$ are linearly independent. In straight-line fitting, that condition holds when the observed $x_i$ values are not all the same.
Unlock Complete Study Notes & Exam Traps
The full guide includes formal proofs, worked exemplar calculations, high-yield exam traps, and examiner marking schemes. Continue studying this topic in Mentify Prep Studio.
Verified Examination Problems
12 verified questions in catalogQuestion 10 (20 marks)
(a) Let $X_1, X_2, \ldots, X_n$ be a random sample of size $n$ from a population whose density function is $$f(x) =
\begin{cases}
\theta^x(1 - \theta)^{1-x}, & x = 0, 1 \ 0, & \text{elsewhere}
\end{cases}$$
(i) Show that $1 - \frac{1}{n} \sum_{1}^{n} X_i$ is a minimum variance unbiased estimator of $\theta + 1$ and (6marks)
(ii) Show that it is also a uniformly minimum variance unbiased estimator. (9marks)
(b) The regression equation of $y$ on $x$ in matrix notation can be written as $y = X\beta + e$ where
$y$ is an $n \times 1$ vector of observations on the independent variable
$e$ is an $n \times 1$ vector of errors
$X$ is an $n \times k$ matrix where we have observations on independent variables for $n$ observations and
$\beta$ is a $k \times 1$ vector of unknown population parameters that we want to estimate
Show that the least square estimator of $\beta$ is given by $\hat{\beta} = (X^T X)^{-1} X^T y$ (5marks)
Question 14 (20 marks)
- [(a)] A random sample $X_1, X_2, \dots, X_n$ of size $n$ is taken from a normal population whose probability density function given by
$$f(x) =
\begin{cases}
\frac{1}{\theta}e^{-\frac{x}{\theta}}, & x > 0 \ 0, & \text{otherwise}
\end{cases}$$
where $\theta$ is a positive constant.
SST305
variance unbiased estimator (UMVUE) of $\theta$. (7marks)
(b) Consider the linear regression line $y_i = \alpha + \beta x_i + e_i$ where $e_i \sim N(0, \sigma^2)$. Show that the least square estimators of $\alpha$ and $\beta$ are unbiased estimators. (3marks)
Access all authentic past questions, interactive AI hint generation, and full marking rubrics in the course studio.
Unlock All Questions in Studio →