- Statistical technique to estimate a linear relationship between variables
- Can be used to predict outcomes based on trends in a data set
- Examines how a dependent variable affects an independent variable
2024-10-22
cor(icecream$Temperature,icecream$Revenue)
## [1] 0.9898408
A linear regression line takes the form of \(y=a+bx\), where \(a\) is the y-intercept and \(b\) is the slope of the line
x <- c(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0) y <- c(8.5, 7.1, 6.2, 5.4, 4.1, 3.3, 2.4, 1.5, 0.9, -0.2) negative <- data.frame(x,y)
These are points that are put into a data frame to be graphed.
cor(x,y)
## [1] -0.9975846
In the previous graph, the regression line shows that x and y are negatively correlated. In this case, the \(b\) in \(y=a+bx\) is negative.
gym <- read.csv(file="C:/Users/mystk/Desktop/DAT301/gym_members_exercise_tracking.csv") myX = gym$Water_Intake..liters. myY = gym$Calories_Burned myZ = gym$Age