2024-02-01

Intro to Simple Linear Regression

  • A statistical method utilized to model the relationship between one dependent variable and one or more independent variables
  • Simple Linear Regression (SLR) is the simplest form, involving one dependent variable and one independent variable
  • The equation for an SLR model follows this formula: \[ y = \beta_0 + \beta_1x + \epsilon \]
  • Beta 0 represents the y-intercept, Beta 1 represents the line’s predicted slope(relationship), x is the independent variable, and epsilon is the error term

More About SLR

  • This statistical method attempt to describe the relationship between two variables in a linear manner

  • When conducting SLR, certain assumptions must be made:

    1. Homoscedasticity: The size of error is generally constant across the values of y

    2. Observations are Independent: Assume the data had no hidden relationships when being sampled

    3. Normality: The data is normally distributed

Applications of SLR

  • SLR is used in a plethora of industries to analyze relationships of two variables (EX: happiness and income)

  • One such application is economics to identify potential sources or predictions of growth

  • The next few slides will show some examples of using SLR by:

    • Using the volume of sales in the Texas housing market to predict the number of sales

    • Using the horsepower of cars to predict its fuel economy

Texas Housing Market

  • There is a linear relationship that indicates a strong positive correlation between volume of sales and # of sales

Fuel Economy

  • There is a linear relationship that indicates a strong negative correlation between MPG and HP

Slide with Plot

  • There is a positive relationship between the two, but it is not well accounted for, as the R-squared is not high

Programming SLR Models

  • SLR can be done with many programming languages, especially those with a focus on data science (Ex: Python, R, etc.)

  • For example, the R code below was used to develop the SLR model of the Texas Housing Market mentioned earlier

data(txhousing)
ggplot(txhousing, aes(x = volume/(10^9), y = sales)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "blue") +
  labs(x = "Volume (in billions)", y = "# of Sales", 
       title = "Predicting Sales From Volume")

Final Remarks

  • SLR can be an effective tool when trying to analyze relationships between two variables, which can be represented as:

\[ Y = \beta_0 + \beta_1 X + \varepsilon \]

  • There are many other calculations from SLR that can offer further insight

  • For example, a residual sum of squares (RSS) can be used to measure the overall fit of the SLR model to the actual data

  • RSS is calculated by:

\[ RSS = \sum_{i=1}^{n} e_i^2 \]