Regression
Regression
Objectives:
To determine the linear relationship between two variables by fitting a straight-line model
using the curve fitting regression method (Linear Regression).
To explore and model a non-linear relationship between two variables by fitting a
polynomial curve using the curve fitting regression method (Linear Regression)
Theory:
Linear regression is a fundamental statistical method used for modeling the relationship between
a dependent variable (also known as the response variable) and one or more independent
variables (predictors or explanatory variables). It aims to find the best fitting linear relationship
between the variables, allowing us to make predictions or understand the impact of the
independent variables on the dependent variable. Here's a basic overview of the theory behind
linear regression. The simplest case of a least squares regression involves finding a straight line
(linear function) in the form:
= + ………………….( )
that best it's a set of data points ( , ), …, ( , ). Of course, the data first needs to be
plotted to see whether the independent and dependent variables exhibit a somewhat linear
relationship. If this is the case, then the coefficient 1 and 0 are determined such that the error
associated with the line is minimized.
Figure 1: This figure represents the diagram of a linear fit of data and individual errors.
As shown in above figure, at each data point ( , ) the error is defined as the difference
between the true value and the approximate value + ,
= −( + )……………….( )
These individual errors will be used to calculate a total error associated with the line
= + ……………………( )
As decided above, the criterion to find the line = + that best it’s the data ( , ), …,
( , ) is to determine the coefficient 1 and 0 that minimize
= ……………….( )
Noting that is a (nonlinear) function of 0 and 1, it attains its minimum where ∂E/∂ and ∂E/∂
vanish, that is,
Circuit Diagram:
Figure 2: This figure represents the block diagram of linear (least square) regression.
Procedure:
Task 1: Suppose the values of any function, y = f(x) is given for some values of x as shown below:
x 1 2 4 6 9 10
y = f(x) 5 6 7 8 7 12
CODE:
x y = f(x)
1 8
2 9.5
3 11
4 11.75
5 12
6 13.6
7 14
CODE:
Values:
Results
This MATLAB experiment demonstrated the versatility of curve fitting and regression
techniques—particularly polynomial regression—in capturing relationships between variables.
The choice between a linear or higher-order polynomial model depends on the data’s underlying
patterns and the goals of the analysis. By applying various polynomial models and assessing
their accuracy, we gained valuable insights into the dataset’s behavior and trends. These
techniques are broadly applicable in scientific, engineering, and analytical fields for effective
data analysis and prediction.