Pracitcal 7 Polynomial Regression
Pracitcal 7 Polynomial Regression
Polynomial Regression
• Polynomial regression is an extension of linear regression that models
the relationship between the independent variable(s) and the
dependent variable as an nth-degree polynomial.
• It is useful for capturing non-linear relationships in data.
• Polynomial regression is used when the relationship between the
independent variables is non-linear.
When to Use Polynomial regression
• Non-Linear Relationship
• When data does not follow a straight-line trend but instead follows a curved
pattern (e.g., U-shaped, inverted U-shaped, or S-shaped).
• Better Fit for Curved Trends
• If a scatter plot suggests a curvilinear pattern, polynomial regression can
provide a better fit than simple linear regression.
• Higher Accuracy in Certain Models
• Used when linear regression underfits the data and adding polynomial terms
improves predictive performance.
nth degree polynomial regression
Where
coefficients
• x is dependent variable
• is error term
Polynomial regression for two
variables, 2nd degree
Steps for Polynomial Regression in
SPSS
• Load your data
• Open SPSS and load your dataset.
• Ensure that your dependent variable (Y) and independent variable (X) are
clearly defined.
• Create polynomial terms
• Polynomial regression requires you to create additional terms (e.g., X2, X3
etc.).
• To create these:
• Click Transform > Compute Variable.
• Enter a new name (e.g. X_squared)
• In the numeric box enter X**2
• Click Ok to create the square term.
• Repeat for higher order terms (e.g. X_cubed=X**3)
Enter Data
• Define Room_price (Independent) and
occupancy_rate (Dependent) variables.
• Enter the data values.
Check for linearity
• Make a scatter plot between room_price and occupancy_rate
variable.
• Clearly we can see relationship is
non-linear
• Then define new non-linear term,
Based on room_price by using
compute variable function.
Make a new variable of second order
• Go to Transform,
Compute variable
• Target variable name is
room_price_squared
• In numeric expression
box write,
room_price**2, this will
make square of
room_price variable.
Click Ok and go to data
view to check a new
variable is created.
Make a regression model
• Make a regression model based on room_price and
room_price_squared as independent variable.
• Occupancy rate as Dependent variable.
• Check all the assumptions of regression model.
• Save residual and predicted values
Output