# Regression Analysis

## Regression Analysis with MATLAB


       
  


### What is Regression Analysis?

Suppose we calculate some variable of interest, y, as a function of some other variable x. We call y the dependent variable and x the independent variable. For example, consider the data set below,  taken from a simple experiment involving a vehicle, its velocity versus time is tabulated. In this case, velocity is a function of time, thus velocity is the dependent variable and the time is the independent variable.    

In its simplest form regression analysis involves fitting the best straight line relationship to explain how the variation in a dependent variable, y, depends on the variation in an independent variable, x. In our example above, once the relationship (in this case a linear relationship) has been estimated we can produce a linear equation in the following form:
And once an analytic equation such as the one above has been determined, dependent variables at intermediate independent values can be computed. 

### Performing Linear Regression

Regression analysis with MATLAB is easy. The MATLAB Basic Fitting GUI allows us to interactively to do "curve fitting" which is a method to arrive at the best "straight line" fit for linear equations or the best curve fit for a polynomial up to the tenth degree. The procedure to perform a curve fitting with MATLAB is as follows:

1. Input the variables,
2. Plot the data,
3. Initialize the Basic Fitting GUI,
4. Select the desired regression analysis parameters.
Now let us do another curve fitting and obtain an equation for the function. Using that equation, we can evaluate the function at a desired value with polyval.

### Summary of Key Points

1. Linear regression involves fitting the best straight line relationship to explain how the variation in a dependent variable, y, depends on the variation in an independent variable, x,
2. Basic Fitting GUI allows us to interactively perform curve fitting,
3. Some of the plot fits available are linear, quadratic and cubic functions,
4. Basic Fitting GUI can evaluate functions at given points.