Fitting and visualizing linear regression models with the ggplot2 R package (CC237)
Channel: Riffomonas Project
Date: 2022-08-08

geom_smooth from the ggplot2 R can fit linear regression models through your data, but what if you want the coefficients or you want to fit a more complex model? In this episode Pat shows how to use R's lm and predict functions to fit linear models to predict the precipitation equivalents from the amount of snow and the high daily temperature. He does all this using local weather data downloaded from NOAA in RStudio with a lot of help from the tidyverse


You can find my blog post for this episode at https://www.riffomonas.org/code_club/2022-08-08-models.

#ggplot2 #dplyr #R #Rstudio #Rstats

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/

You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Introduction
2:08 Exploring precipitation and snow data
6:56 Assessing correlation on daily basis
10:33 Defining the model and fit in geom_smooth
12:06 Using geom_abline to draw a line through data
12:42 Assessing a linear model with multiple parameters
17:15 Improve appearance of figure
19:29 Creating a legend for different models