Statistical Relationships Between Variables
- Measures how variables relate to each other
- Predicts outcomes based on relations
2025-10-14
Statistical Relationships Between Variables
This is Pearson Correlation Coefficient (r): \[ r=\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{ \sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}} \]
Regression Equation: \[ Y = \beta_0+\beta_1X+\epsilon \]
n <- 50
study_hours <- runif(n, 1, 10)
exam_score <- 50 + 5 * study_hours + rnorm(n, 0, 8)
study_data <- data.frame(study_hours, exam_score)
ggplot(study_data, aes(x = study_hours, y = exam_score)) +
geom_point(color = "darkblue", alpha = 0.7, size = 2) +
geom_smooth(method = "lm", color = "red", se = TRUE, fill = "lightpink") +
labs(title = "Linear Regression: Study Hours vs Exam Score",
x = "Study Hours", y = "Exam Score") +
theme_minimal()
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'