Linear Regression intro

What is Linear Regression?

According to IBM, “Linear regression analysis is used to predict the value of a variable based on the value of another variable.” Why is that useful? It can be used for predictions of behavior in terms of 2 variables, such as: how many more car accidents could there be when it’s raining, and how much does security increase in concert venues when there are more security guards, etc.

To be able to predict this, we would plot one variable against another for numerous values and find the line of “best fit” to determine a value Y for a certain value of X. See the next slide for an example of linear regression using Plotly

Linear regression example using Plotly

We can see in the plot that as weight increases in vehicles, their MPG decreases. The red regression line is the “best fit” that we can use to compare weight to it’s MPG

Linear Regression using ggplot2

Here we can see that as urban population increases, so do rates of assault.

Linear Regression using ggplot2 #2

Here is a regression line showing that women’s height increases, so does her weight

Linear regression!

I hope this intro helped you gain a better understanding of why linear regression modeling is an important technique to use and enable accurate predictions.

Of course these were very basic examples using R’s build in datasets, but this can be an extremely powerful tool to use in real-life datasets to make educated predictions and aid in decision making.

Examples of math symbols

Einstein’s famous equation: \(E=mc^2\)

Integrals: \[ \int_{a}^{b} f(x) \, dx \]

Quadratic formula: \(\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\)

Matrix equation: \(A\mathbf{x}=\mathbf{b}\)

Formula of a circle: \(A = \pi r^2\)

Pythagorean theorom: \(a^2 + b^2 = c^2\)

Math symbols continued….

Double angle formula for sine: \(\sin(2\theta) = 2\sin(\theta)\cos(\theta)\)

Summation (sigma): \(\sum_{i=1}^{n} i\)

Taylor series: \(f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n\)

\(\arctan(\pi/2) = 1.0038848\)

Identity matrix: \[ \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \]

And finally a regression plot in R…

This plot highlights how as pressure increases (such as in a gas compressing), the temperature will also increase.