9.2.2.Non Linear Regression - sj50179/IBM-Data-Science-Professional-Certificate GitHub Wiki

Should we use linear regression?

These data points correspond to China's gross domestic product or GDP from 1960-2014. The first column is the years and the second is China's corresponding annual gross domestic income in US dollars for that year.

Untitled

Now, we have a couple of interesting questions.

  1. Can GDP be predicted based on time?
  2. Can we use a simple linear regression to model it?

If the data shows a curvy trend, then linear regression would not produce very accurate results when compared to a non-linear regression. Simply because, as the name implies, linear regression presumes that the data is linear.

The scatter plot shows that there seems to be a strong relationship between GDP and time, but the relationship is not linear.

It looks like either a logistical or exponential function. So, it requires a special estimation method of the non-linear regression procedure.

Untitled

if we assume that the model for these data points are exponential functions, such as , our job is to estimate the parameters of the model, i.e., Thetas, and use the fitted model to predict GDP for unknown or future cases.

Different types of regression

Untitled

Many different regressions exists that can be used to fit whatever the dataset looks like. You can see a quadratic and cubic regression lines here, and it can go on and on to infinite degrees.

In essence, we can call all of these polynomial regression, where the relationship between the independent variable X and the dependent variable Y is modeled as an Nth degree polynomial in X.

With many types of regression to choose from, there's a good chance that one will fit your dataset well.

What is polynomial regression?

  • Some curvy data can be modeled by a Polynomial Regression
  • For example:

Untitled

  • A polynomial regression model can be transformed into linear regression model.

    → Multiple linear regression → Least Squares

    • Minimizing the sum of the squares of the differences between and

Question

Which sentences are TRUE about "Polynomial Regression"?

  • polynomial regression fits a curve line to your data.
  • Quadratic and cubic regression lines are a type polynomial regression
  • A polynomial regression model cannot be expressed as linear regression
  • Polynomial regression models can fit using the method of least squares.

Correct

What is non-linear regression?

  • To model non-linear relationship between the dependent variable and a set of independent variables
  • must be a non-linear function of the parameters , not necessarily the features

In contrast to linear regression, we cannot use the ordinary least squares method to fit the data in non-linear regression. In general, estimation of the parameters is not easy.

Linear vs non-linear regression

  • How can I know if a problem is linear is linear or non-linear in an easy way?
    • Inspect visually
    • Based on accuracy
  • How should I model my data, if it displays non-linear on a scatter plot?
    • Polynomial regression
    • Non-linear regression model
    • Transform your data