GNGiseldo Neo and Alana NeoBooks
Linear Regression with Python6 / 19

Types of Linear Regression

5.1 Simple Linear Regression

Simple linear regression is the most basic type of regression, used to model the relationship between two variables: one dependent variable and one independent variable. The equation for simple linear regression is given by:

y=β0+β1x+ϵy = \beta_0 + \beta_1x + \epsilon

where:

  • yy is the dependent variable.

  • xx is the independent variable.

  • β0\beta_0 is the regression intercept.

  • β1\beta_1 is the slope coefficient, which indicates the inclination of the line.

  • ϵ\epsilon is the error term.

Practical Example

A classic example of simple linear regression is predicting a person’s weight (yy) based on their height (xx). In this case, only one predictor variable is used, which simplifies both the analysis and the interpretation of the results.

5.2 Multiple Linear Regression

Multiple linear regression extends the concept of simple linear regression to include multiple independent variables. This allows the model to capture the relationship between a dependent variable and several predictors, yielding a more comprehensive and accurate model.

The equation for multiple linear regression is:

y=β0+β1x1+β2x2+⋯+βnxn+ϵy = \beta_0 + \beta_1x_1 + \beta_2x_2 + \cdots + \beta_nx_n + \epsilon

where:

  • yy is the dependent variable.

  • x1,x2,…,xnx_1, x_2, \ldots, x_n are the independent variables.

  • β0,β1,…,βn\beta_0, \beta_1, \ldots, \beta_n are the coefficients representing the contribution of each independent variable.

  • ϵ\epsilon is the error term.

Practical Example

An example of multiple linear regression is predicting the price of a house (yy) using multiple features, such as the number of bedrooms (x1x_1), floor area (x2x_2), and location (x3x_3). Here, multiple factors are considered to improve the accuracy of the predictive model.

5.3 Comparison Between Simple and Multiple Regression

5.3.1 When to Use Simple Linear Regression

  • Simplicity: Useful when there is only one key predictor variable and an easy-to-interpret analysis is desired.

  • Intuitive Interpretation: Easy to visualize and communicate results, since it involves only two dimensions.

5.3.2 When to Use Multiple Linear Regression

  • Complexity of Factors: Necessary when multiple variables influence the outcome and we wish to capture their combined effects and interactions.

  • Better Fit: Provides a more accurate fit when multiple factors are relevant to predicting the dependent variable.

5.3.3 Practical Considerations

  • Collinearity: In multiple regression, it is important to check for collinearity among the independent variables, as it can affect the stability and interpretation of the coefficients.

  • Overfitting: Adding too many variables can lead to overfitting, where the model fits the training data well but fails to generalize to new data. Techniques such as regularization can help mitigate this issue.