February 4th, 2024

What is Linear Regression?

According to IBM, linear regression is a form of data analysis used to predict the value of a variable, called the dependent variable. This is done by looking at the value of another variable, the independent variable, to mathematically obtain the value of the variable you are trying to predict.

Why does Linear Regression Matter?

Linear regression is important as it is an easy way to generate a math based prediction of a variable. For example, in business, if shareholders wanted to have estimations for next quarter’s values one could use linear regression to generate such values.

Linear Regression and Data

Now that we touched on linear regression and why it is important, its key to touch on key aspects of data that would be a good fit for linear regression. According to IBM the following characteristics are important for linear regression:

  • Data without extreme variance
  • Continuous Variables
  • Data that, when on a scatter plot, illustrates a linear relationship

Example Data #1

For this presentation, I created a data set of purely fictional individuals with ages corresponding to their salary. Plotting these data points illustrates that there is no extreme variance and a linear relationship between salary and age. Thus making this data set a prime candidate for linear regression For this data set, the formula for linear regression would be as follows: \[Salary = \beta_0 + \beta_1 * Age\]

Example Data #2

This data set does not make a good fit for linear regression due its variance and missing values

## Warning: Removed 1 rows containing missing values (`geom_point()`).

Data

Building off of Example #1, here we perform linear regression on data set. Below is the equation documenting the function of linear regression Function Math: \[Salary = \beta_0 + \beta_1 * Age\] ## CodeBehindPlot

lmSalary = lm(salary~age, data = data)
plot(data, col = "red", pch = 20) 
abline(lmSalary)

Sources Cited:

“What Is Linear Regression.” Https://Www.Ibm.Com/Us-en, www.ibm.com/topics/linear-regression#:~:text=the%20next%20step-,What%20is%20linear%20regression%3F,is%20called%20the%20independent%20variable.