2024-03-18

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

What is Linear Regression?

Linear Regression is a mathematical concept that is used to create models for predictions regarding a specific set of data

It used in many different types of fields to create predictions, ranging from biology to business

The following slides will contain some examples of linear regression plots

Simple Linear Regression Formula

This is a basic equation for Simple Linear Regression:

\[ y = \alpha + \beta x \]

Simple Linear Regression Formula explained

\[ y\] = the dependent variable or what you are measuring \[\alpha\] = the y intercept \[\beta\] = the slope \[x\] = the independent variable or what you are manipulating

This is the r code and data for the linear regression plot example on the next slide

df <- data.frame(x = 1:10, y = c(1, 3, 4, 9, 11, 13, 15, 17, 19, 21))

ggplot(df, aes(x = x, y = y)) + geom_point() + geom_smooth() + labs(title = “Scatter plot for linear regression”, x = “X”, y = “Y”)

Linear Regression plot example

## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

Linear Regression plot example 2

## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'