2026-10-10

What is Simple Linear Regression?

Simple linear regression is a model of a relationship between two continuous variables \(x\) and \(y\)

\(x\) is the independent variable and \(y\) is the dependent variable.

The simple linear regression function is denoted as \(y\) = \(\beta_0\) + \(\beta_1x\)

  • \(\beta_0\) is the \(y\) intercept
  • \(\beta_1\) is the slope
  • \(x\) is the independent variable
  • \(y\) is the dependent variable

What does a simple linear regression do?

The goal of simple linear regression is to predict future outcomes based on a certain input parameters .

The data set we are going to b be using for further explanation is ‘women’ from R’s built in data set.

Women data. height vs wieght

##    Height Weight
## 1      58    115
## 2      59    117
## 3      60    120
## 4      61    123
## 5      62    126
## 6      63    129
## 7      64    132
## 8      65    135
## 9      66    139
## 10     67    142
## 11     68    146
## 12     69    150
## 13     70    154
## 14     71    159
## 15     72    164

If we plot the point of each women height and weight we get the scatter plot

Just by visuale inspecetion we can see that there is a linear relationship happining because as height goes up weight goes up almost linearly

To see what the actual linear regression we need to find 2 coefficients, the slope \(\beta_1\) and the y-intercept \(\beta_0\).

to calculate Women slop by hand we’d use the following equation

\(\beta_1\) = (\(N\)\(\sum\)(\(x\)\(y\))-\(\sum\)(\(x\))\(\sum\)(\(y\)))/(\(N\)\(\sum\)(\(x\)\(^2\))-(\(\sum\)(\(y\)))\(^2\)

  • \(N\) is the number of total inputs
  • \(x\) is the hieght at a given interval
  • \(y\) is the weight at a given interval

To calculate the y-intercept we’d use the following equation

\(\beta_0\) = (1/\(N\))\(\sum\)(\(y\)) - (\(\beta_1\)/\(N\))\(\sum\)(\(x\))

  • \(N\) is the number of total inputs
  • \(\beta_1\) is the slop of women heigh vs weight
  • \(x\) is the hieght at a given interval
  • \(y\) is the weight at a given interval

Fortienetly R has a built in calculator for linear model

## (Intercept)      height 
##   -87.51667     3.45000

Our \(\beta_0\) is about -87.52 and \(\beta_1\) = 3.45 lbs/ foot

Now we can use the equation to get a rough weight of any women based on the data set.

For example 6’6” women would be

6’6” = 78”

weight = -87.52 + 3.45*(78)

weight = 181.58 lbs

To check if our equation work lets try to see if we can get almost exact value as one of our test cases

sample #10
has a height of 67” and weight of 142 lbs

If we use the equation we get weight = -87.52 + 3.45(67) weight = 143.63

I said rough answer instead of eact answer because we are guarnteed an error unless we had a perefectly linear data set.

we can calculate the error by using the following equation

\(E\) = |\(weight_e\)\(_x\)\(_p\) - \(weight_0\)| / \(weight_0\)

\(E\) = |143.63-142|/142 = 0.0147 which is about 1.15% error which is acceptable