Sitemap
Modupeola Alade

Modupeola Alade

Data Analyst | Power BI Specialist | Python Enthusiast | Transforming Messy Data into Actionable Insights

Regression Analysis

Regression analysis is the “go-to method in analytics,” says Tom Redman, author of Data Driven: Profiting from Your Most Important Business Asset.

8 min readJun 29, 2019

--

Image from Google search

Regression analysis is a set of statistical methods used for the estimation of relationships between a dependent variable and one or more independent variables. It is a powerful statistical method that can be utilized to assess the strength of the relationship between variables of interest and for modeling the future relationship between them.

A dependent variable y is the state, target or final goal we study and try to predict, while the independent variable x, also known as explanatory variable can be seen as the cause of those states.

Image from Google search

The overall idea of regression is to examine two things:

  1. Does a set of predictor variables do a good job in predicting an outcome (dependent) variable?
  2. Which variables in particular are significant predictors of the outcome variable, and in what way do they–indicated by the magnitude and sign of the beta estimates–impact the outcome variable?

These regression estimates are used to explain the relationship between one dependent variable and one or more independent variables. There are various kinds of regression techniques available to make predictions. These are mostly driven by three metrics:

  • number of independent variables
  • type of dependent variables
  • shape of regression line

Regression analysis could either be a linear regression or non-linear regression.

Linear Regression

Linear regression is a basic and commonly used type of predictive analysis. Linear regression analysis is based on six fundamental assumptions:

  1. The dependent and independent variables show a linear relationship between the slope and the intercept.
  2. The independent variable is not random.
  3. The value of the residual (error) is zero.
  4. The value of the residual (error) is constant across all observations.
  5. The value of the residual (error) is not correlated across all observations.
  6. The residual (error) values follow the normal distribution.
Image from Google search

Some type of linear regression are:

  • Simple Linear regression — Is simplest form of the regression equation with one dependent and one independent variable is defined by the equation: Y= a + bX + ϵ, where: Y— dependent variable, X— independent variable, a — intercept, b — slope and ϵ — residual (error).
Press enter or click to view image in full size
Image from Google search
  • Multiple Linear regression — Is essentially similar to the simple linear model, with the exception that 1 dependent variable and multiple independent variables (2 or more) are used. The mathematical equation of multiple linear regression is: Y= a + bX1 + cX2 + dX3 + ϵ , where: y — dependent variable, (X1, X2, X3 )— independent variables, a — intercept, (b, c, d) — slopes and ϵ — residual (error).
Image from Google search
  • Logistic regression — Is used to find the probability of event being a success or a failure. Here, we have one dependent variable (dichotomous) and one or more independent variables (interval or ratio or dichotomous). We should use logistic regression when the dependent variable is binary (0/1, True/False, Yes/No) in nature. Here the value of y ranges from 0 to 1. It is widely used for classification problems and requires large sample sizes.
Image from Google search: How logistics regression model works
  • If the values of the dependent variable is ordinal, then it is called as Ordinal Logistic regression.
  • If dependent variable is multi class(i.e. nominal) then it is known as Multinomial Logistic regression.

Non-linear Regression

Nonlinear regression is a regression in which the dependent or criterion variables are modeled as a non-linear function of model parameters and one or more independent variables. Nonlinear regression uses nonlinear regression equations, which take the form: Y = f(X,β) + ε
where: X = a vector of p predictors, β = a vector of k parameters, f(-) = a known regression function and ε = an error term.

Press enter or click to view image in full size
Image from Google search

There are several common models such as:

  • Asymptotic Regression/Growth Model, which is given by:

b1+ b2 * exp (b3 * x)

  • Logistic Population Growth Model, which is given by:

b1 / (1 + exp (b2 + b3 * x))

  • Asymptotic Regression/Decay Model, which is given by:

b1- (b2 * (b3 * x))

The reason that these models are called nonlinear regression is because the relationships between the dependent and independent parameters are not linear.

Get Modupeola Alade’s stories in your inbox

Join Medium for free to get updates from this writer.

Other regression analysis are:

Polynomial Regression

A regression equation is a polynomial regression equation if the power of independent variable is more than 1. Here, the relationship between the independent variable x and the dependent variable y is modeled as an nth degree polynomial in x. The equation below represents a polynomial equation: y= a + bx²

In this regression technique, the best fit line is not a straight line. It is rather a curve that fits into the data points. Examples of such curved fit line are Quadratic/Parabolic Regression(x²) and Cubic Regression(x³).

Press enter or click to view image in full size
Image from Google search
Press enter or click to view image in full size
Image from Google search

Stepwise Regression

This form of regression is used when we deal with multiple independent variables. Step-wise regression basically fits the regression model by adding/dropping co-variate one at a time based on a specified criterion, which involves no human intervention. This feat is achieved by observing statistical values like R-square, t-stats and AIC metric to discern significant variables. The aim of this modeling technique is to maximize the prediction power with minimum number of predictor variables. It is one of the method to handle higher dimensionality of data set.

Ridge Regression

Ridge Regression is a technique used when the data suffers from multicollinearity (independent variables are highly correlated). In multicollinearity, even though the least squares estimates are unbiased, their variances are large which deviates the observed value far from the true value. Ridge regression solves the multicollinearity problem through shrinkage parameter λ (lambda).

Lasso Regression

Lasso (Least Absolute Shrinkage and Selection Operator) also penalizes the absolute size of the regression coefficients. In addition, it is capable of reducing the variability and improving the accuracy of linear regression models. Lasso regression differs from ridge regression in a way that it uses absolute values in the penalty function, instead of squares.

ElasticNet Regression

ElasticNet is hybrid of Lasso and Ridge Regression techniques. It is trained with regularizer. It is useful when there are multiple features which are correlated.

Image from Google search

How to select the right regression model?

The simple one is this: If the outcome is continuous, apply linear regression. If it is binary, use logistic regression. However, higher the number of options available at our disposal, more difficult it becomes to choose the right one. Within multiple types of regression models, it is important to choose the best suited technique based on type of independent and dependent variables, dimensionality in the data and other essential characteristics of the data. Below are the key factors that you should practice to select the right regression model:

  1. Data exploration is an inevitable part of building predictive model. It should be you first step before selecting the right model like identify the relationship and impact of variables
  2. Model fitting and to compare the goodness of fit for different models, we can analyse different metrics like statistical significance of parameters, R-square, Adjusted r-square, AIC, BIC and error term. This essentially checks for possible bias in your model, by comparing the model with all possible submodels (or a careful selection of them).
  3. Cross-validation is the best way to evaluate models used for prediction. Here you divide your data set into two group (train and validate). A simple mean squared difference between the observed and predicted values give you a measure for the prediction accuracy.
  4. If your data set has multiple confounding variables, you should not choose automatic model selection method because you do not want to put these in a model at the same time.
  5. It will also depend on your objective. It can occur that a less powerful model is easy to implement as compared to a highly statistically significant model.
  6. Regression regularization methods (Lasso, Ridge and ElasticNet) works well in case of high dimensionality and multicollinearity among the variables in the data set.

Why and How companies use regression analysis

Regression analysis is helpful statistical method that can be leveraged across an organization to determine the degree to which particular independent variables are influencing dependent variables .Three major uses for regression analysis are

  1. Determining the strength of predictors
  2. Forecasting an effect
  3. Trend forecasting.
Image from Google search

Most companies use regression analysis to explain a phenomenon they want to understand (e.g. why did customer service calls drop last month?); predict things about the future (e.g. what will sales look like over the next six months?); or to decide what to do (e.g. should we go with this promotion or a different one?). The possible scenarios for conducting regression analysis to yield valuable, actionable business insights are endless.

Performing a regression analysis to determine just how confident one should be in an hypothesis allows one to make more informed business decisions, allocate resources more efficiently, and ultimately boost your bottom line.

Mistakes to avoid working with regression analysis

Tom Redman says there are some things to keep in mind when working with regression analysis to achieve the best possible result:

  • Don’t tell your data analyst to go out and figure out what is affecting sales rather identify the factors that you suspect are having an impact and ask your analyst to look at those.
  • Also keep in mind whether or not you can do anything about the independent variable you’re considering e.g. you cannot change how much it rains
  • Analyses are very sensitive to bad data so be careful about the data you collect and how you collect it, and know whether you can trust it.
  • Don’t ignore the error term
  • Don’t let data replace your intuition. Ask yourself whether the results fit with your understanding of the situation. And if you see something that doesn’t make sense ask whether the data was right or whether there is indeed a large error term, then look to more experienced managers or other analyses.
  • Never forget to look beyond the numbers to what’s happening outside the company. You need to pair any analysis with study of real world. The best scientists and managers look at both.

Happy Analysis!

Reference

  • www.google.com

***Footnote: This study is a part of the final project of my enrollment in a Data Science course organized by GitGirl School.

--

--

Modupeola Alade
Modupeola Alade

Written by Modupeola Alade

Data Analyst | Power BI Specialist | Python Enthusiast | Transforming Messy Data into Actionable Insights