Reading section 4 of 8 · Example · 5 minSection 4 of 8 · 5 min
Section 4 of 8 · 5 min read
Polynomial Regression › ExampleOne section · Sections in this chapter4 / 8 ↓
Sections in this chapter8
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let's work through a concrete example to understand how polynomial regression works step-by-step. You'll use a simple dataset and see the complete calculation process.
Step 1: Data PreparationLink Copied
Consider the following dataset with 5 observations:
Observation
X
Y
1
1
2.1
2
2
3.9
3
3
8.1
4
4
15.9
5
5
25.1
Step 2: Setting Up the Quadratic ModelLink Copied
We'll fit a quadraticpolynomial regression model:
Step 3: Constructing the Design MatrixLink Copied
For a quadratic model, our design matrix includes columns for the intercept, , and :
Step 4: Matrix CalculationsLink Copied
The response vector is:
Now you calculate (the Gram matrix). First, note that is the transpose of :
For example, the element in row 1, column 2 is: .
Similarly, calculate :
For example, the first element is: .
Step 5: Solving for CoefficientsLink Copied
Using the normal equation, we first compute the inverse of :
Therefore, the coefficient estimates are:
where:
is the estimated intercept
is the estimated coefficient for the linear term
is the estimated coefficient for the quadratic term
Step 6: Final ModelLink Copied
Our fitted quadraticpolynomial regression model is:
where:
is the predicted response value
is the predictor variable
The coefficients indicate a quadratic relationship with both linear and quadratic components
This model shows that the relationship has a negative linear component () and a positive quadratic component (), creating a U-shaped curve that increases more rapidly for larger values of .
Step 7: VerificationLink Copied
Let's verify our model by calculating predictions for each observation:
For : (actual: 2.1, residual: )
For : (actual: 3.9, residual: )
For : (actual: 8.1, residual: )
For : (actual: 15.9, residual: )
For : (actual: 25.1, residual: )
where the residual is defined as (predicted minus actual).
The model captures the quadratic trend very well, with small residuals. The residual sum of squares is:
where:
is the residual sum of squares
Each term represents the squared difference between predicted and actual values
A smaller RSS indicates a better fit to the data
This small RSS value of 0.265 indicates an excellent fit to the data.