2024-06-04

Slide 1

Simple Linear Regression is a method of modelling the relationship between any number of indepedent variables and one dependent variable. Put simply, it is used to generate an equation used to predict a certain output based on certain inputs.

Slide 2

The equation is: \[ y = \beta_0 + \beta_1 x \]

Slide 3

In practice, one will use tools like R in order to perform simple linear regression. For instance, when looking at trees, if one wanted to examine the relationship between tree height and tree volume, they could do so with the following R code.

model = lm(Volume ~ Height, data=trees) model

Slide 4

Practically, this is better displayed through a graph, which would allow one to clearly visualize the relationship, or lack thereof, between the two variables.

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

## NULL

Slide 5

To perform something like this yourself, you can look at and adapt the following code for your own uses:

ggplot(trees, aes(x=Volume, y=Height)) + geom_point(color=‘green’, size=4) + geom_smooth(method=“lm”, color=“Black”) labs(title=‘Volume vs Height’, x=“Volume”, y=“Height”) + theme_minimal()

Slide 6

Here is another example showing the relationship between Orange tree age and Circumference

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

## NULL

Slide 7

Here is a demonstration of how I changed my code to adapt to the different dataset and set of requirements.

ggplot(Orange, aes(x=age, y=circumference)) + geom_point(color=‘orange’, size=4) + geom_smooth(method=“lm”, color=“Black”) labs(title=‘Age vs Circumference of Orange Trees’, x=“Age”, y=“Circumference”) + theme_minimal()

Slide 7

Simple Linear Regression can also be applied to problems with more than one independent variable.

For something like that, one can adapt the original formula to include more instances of x: \[ y = \beta_0 + \beta_1x_1 + \beta_2x_2... \]

Slide 8

For example, take a set of tree girths, heights, and volumes. Letting volume be the independent variable while girth and height are the dependent, one can simulate the relationships between these variables.

Slide 9

Plugging these variables into the formula from earlier, one gets:

\[ Volume = \beta_0 + \beta_1 \times Girth + \beta_2 \times Height \]

This could theoretically be scaled infinitely with more and more variables being added. However it is important to note that linear regression is an imperfect tool in modelling relationships. For instance, linear regression assumes the relationship is linear when it could be quadratic or logarithmic or something else. Furthermore, linear regression is sensitive to outliers skewing results. In summary, exercise caution when making big assumptions with regression.

Slide 10

Thank you for viewing :)