2026-11-01

Continuous Regression Analysis

Regression analysis is a statistical process that is used specifically to determine patterns in data.

This provides valuable insight into predicting future outcomes.

Through out the following slides, we will be predicting the correlation between miles per gallon in a vehicle and other values such as weight and acceleration.

Basic Scatter Plot

-The example scatter plot above shows that not every correlation is strong. Many measurements may be completely independent of one another.

Basic Regression Line sample equation

\[ \begin{equation} {y} = a + b x_{1} + c x_{2} + dx_{3} \end{equation} \]

  • One of the simplest forms of regression analysis is using a simple straight regression line. The intent is to be able to predict a variable y (mpg), using correlated variables x1(acceleration), x2(weight), x3(horsepower)
  • In this case mpg is dependent on many factors, including ones missing from the data set, so it cannot be predicted exactly 100%, but with proper analysis a close approximation for y is attainable
  • the last pieces of the equation are the coefficients, the variable weights/strengths. Not every variable has a strong correlation with mpg. As we established in the previous slide, acceleration does not have a particularly strong coefficient. In the next slide, we will look at a stronger one.

Basic Scatterplot with Regression Line

Other Tools

There are many different tools that can be used to visualize datasets. Another commonly used one is plotly. On the next two slides, you will see both an R script that generates a plotly chart showing the relation between horsepower and mpg and the chart itself. Just from the scatter plot pattern, it looks like a more accurate regression analysis would use a polynomial to create a curved regression line, tracking a more accurate trend of the relation. Such as:

\[ \begin{equation} {y}_i = a + b (x) + c (x)^2 \end{equation} \]

Plotly Example Code

df_sorted <- df[order(df$horsepower), ]
plotlyExample = plot_ly(
  data = df_sorted,
  x = ~horsepower,
  y = ~mpg,
  type = "scatter",
  mode = "markers",
  marker = list(color = "blue")
  
) %>%
  layout(
    title = "Horsepower vs. MPG",
    xaxis = list(title = "Horsepower", type = "linear"),
    yaxis = list(title = "Miles Per Gallon")
  )

Plotly Example Chart

Example of Regression Curve

Here is one last example of the same horsepower data with a fitted regression curve (not generated by my code)