---
layout: post
title: "Fitting and visualizing linear regression models with the ggplot2 R package (CC237)"
blurb: "Putting the stats back in Rstats"
author: "PD Schloss"
date: 2022-08-08 11:00
comments: false
youtube: 1Vs-ckEI94M
start_hash: 840cf9e9edd3a523303cb84c22903e6fb215a223
end_hash: 4f669e64b728bc77de39f30568deca0a0d830ca1
---

`geom_smooth` from the ggplot2 R package will 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


<iframe style="margin: 0 auto;display:block;" width="560" height="315" src="https://www.youtube.com/embed/{{ page.youtube }}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>


## Code

You can browse the state of the repository at the
* [beginning of the episode](https://github.com/riffomonas/climate_viz/tree/{{ page.start_hash }})
* [end of the episode](https://github.com/riffomonas/climate_viz/tree/{{ page.end_hash }})
