2025-04-12

Introduction

Linear regression is a statistical technique used to model and analyze the relationship between two continuous variables. It helps us understand how one variable (the dependent variable) changes when the other (the independent variable) changes.

Example: One common application is predicting weight based on height. By modeling this relationship, we can make predictions about a person’s weight given their height.

Mathematical Formula

We model the relationship as:

\[ y = \beta_0 + \beta_1 x + \epsilon \]

where: - \(y\) = dependent variable (Weight) - \(x\) = independent variable (Height) - \(\beta_0\) = intercept - \(\beta_1\) = slope - \(\epsilon\) = error term

R-Squared Formula

The R-squared value represents the proportion of the variance in the dependent variable that is predictable from the independent variable(s).

\[ R^2 = 1 - \frac{\sum (y_i - \hat{y_i})^2}{\sum (y_i - \bar{y})^2} \]

Where: - \(y_i\) = actual value - \(\hat{y_i}\) = predicted value - \(\bar{y}\) = mean of the actual values

Scatter Plot with Regression Line (ggplot)

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

3D Plot with Plotly

Residuals Plot (ggplot)

Linear Regression Model

Linear Regression Coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 105.8501313 15.1292553 6.9963874 0.0000000
Height 0.0008819 0.0886153 0.0099517 0.9920638

Summary of Analysis

In this analysis, we investigated the relationship between height and weight using linear regression. The model provided the following insights:

Intercept: The estimated weight when height is 0 cm is 105.85 kg (though this is not a meaningful value in practice).

Height Coefficient: For each additional centimeter of height, the model predicts an increase of 0.00088 kg in weight.

P-value for Height: The p-value for height is 0.992, which is much higher than the typical significance threshold of 0.05. This suggests that the height variable is not statistically significant in predicting weight.