4. Linear Regression In R programming language

Understanding and need of Linear Regression

Before we try to understand what linear regression is, let’s quickly explore the need for a linear regression algorithm by means of an analogy. 

Imagine that we were required to predict the number of skiers at a resort, based on the area’s snowfall. The easiest way would be to plot a simple graph with snowfall amounts and skiers on the ‘X’ and ‘Y’ axis respectively. Based on the graph, we could infer that as the amount of snowfall increased, so the number of skiers would obviously increase.

Hence, the graph makes it easy to see the relationship between skiers and snowfall. The number of skiers increases in direct proportion to the amount of snowfall. Based upon the knowledge the graph imparts, we can make better decisions relating to the operations of a ski area.

To understand linear regression, we need to understand the term “regression” first. Regression is used to find relationships between a dependent variable (Y) and multiple independent (X) variables. Here, the independent variables are known as the predictors or explanatory variables, and the dependent variable is referred to as a response or target variable. 

A linear regression’s equation looks like this:

y = B0 + B1x1 + B2x2 + B3x3 + ….

Where B0 is the intercept(value of y when x=0)

B1, B2, B3 are the slopes

x1, x2, x3 are the independent variables

In this case, snowfall is an independent variable and the number of skiers is a dependent variable. So, since regression finds relationships between dependent and independent variables, then what exactly is linear regression?

Leave a Reply

Your email address will not be published. Required fields are marked *