2024-06-04

Introduction to Simple Linear Regression

What is Simple Linear Regression?

  • Statistical method to model the relationship between two variables: one independent variable (predictor) and one dependent variable (response).
  • It assumes a linear relationship between the predictor and the response variable.

Equation of Simple Linear Regression

The simple linear regression model can be expressed as:

\[ Y = \beta_0 + \beta_1X + \epsilon \]

  • \(Y\): Dependent variable (response)
  • \(X\): Independent variable (predictor)
  • \(\beta_0\): Intercept
  • \(\beta_1\): Slope
  • \(\epsilon\): Error term

Example

Suppose we want to predict the sales of a product based on advertising expenditure. We collect data on advertising spending (\(X\)) and corresponding sales (\(Y\)) for different products.

Let’s perform simple linear regression to model this relationship.

Hypotheses

In simple linear regression, the null and alternative hypotheses are related to the slope (\(\beta_1\)):

  • Null Hypothesis (H0): There is no linear relationship between advertising expenditure and sales (\(\beta_1 = 0\)).
  • Alternative Hypothesis (Ha): There is a linear relationship between advertising expenditure and sales (\(\beta_1 \neq 0\)).

Assumptions of Simple Linear Regression

  1. Linearity: The relationship between the predictor and response variable is linear.
  2. Independence: The residuals (errors) are independent of each other.
  3. Homoscedasticity: The variability of residuals is constant across all levels of the predictor variable.
  4. Normality: The residuals follow a normal distribution.

Steps in Simple Linear Regression

  1. Data Collection: Gather data on predictor and response variables.
  2. Model Specification: Define the relationship between variables.
  3. Parameter Estimation: Estimate the slope and intercept of the regression line.
  4. Model Fitting: Fit the model to the data using least squares estimation.
  5. Model Evaluation: Assess the goodness of fit and check assumptions.
  6. Interpretation: Interpret the coefficients and make predictions.

Scatter Plot With regression line

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

Surface Plot (plotly)**

Scatter Plot with Regression Line (plotly)**

## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels