How are Temperature and Ozone levels related?
We will explore if warmer days correlate to having higher ozone levels by using the built-in airquality data set in R.
How are Temperature and Ozone levels related?
We will explore if warmer days correlate to having higher ozone levels by using the built-in airquality data set in R.
The airquality data set features recorded data from May-September of 1973 with 153 daily observations from New York about the states airquality.
The information we will focus on within the airquality dataset are:
Temp: Maximum daily temperature in Fahrenheit
Ozone: mean ozone concentration in ppb (parts per billion)
head(airquality)
## Ozone Solar.R Wind Temp Month Day ## 1 41 190 7.4 67 5 1 ## 2 36 118 8.0 72 5 2 ## 3 12 149 12.6 74 5 3 ## 4 18 313 11.5 62 5 4 ## 5 NA NA 14.3 56 5 5 ## 6 28 NA 14.9 66 5 6
Correlation is the strength and connection of a linear relationship between two variables.
Ozone levels are right-skewed where most recorded days had lower levels, while a smaller number had much higher levels.
The scatter plot demonstrates a positive association where warmer days tend to have higher ozone levels. There is still variation to where even on days with similar temperatures, ozone levels can be different.
The regression line has an upward slope, which shows that higher temperatures are linked to higher ozone levels. Since all points dont stay on the line, the temperature alone does not fully predict ozone levels.
Equation of a linear regression model:
\[ y=\beta_0+ \beta_1 x+ \varepsilon \]
\(y\) = the ozone level
\(x\) = the maximum daily temperature
\(\beta_0\) = the intercept
\(\beta_1\) = is the slope or how much the expected ozone level changes when temperature increases by 1 degree Fahrenheit
\(\varepsilon\) = how much a day’s ozone level is different from what the model expects at that temperature
A positive slope means that warmer days tend to have higher ozone levels.
ozone_model<-lm(Ozone~ Temp, data=airquality) ozone_model
## ## Call: ## lm(formula = Ozone ~ Temp, data = airquality) ## ## Coefficients: ## (Intercept) Temp ## -146.995 2.429
This model utilizes temperature to predict ozone levels.
R gives us the intercept and slope needed to write the regression equation.
The fitted regression equation is:
\[ \widehat{ozone} = -146.995 + 2.429(Temp) \]
For each 1 degree Fahrenheit increase in temperature, the model predicts an increase of around 2.429 ppb in ozone.
The colors distinguish the months(ex: 5 = May)
The points help to identify when unusually high ozone levels occurred and to compare days with similar temperatures.
The highest recorded ozone level was 168 ppb on August 25th at the maximum temperature of 81 Fahrenheit. This did not occur on the hottest day, which shows that temperature alone does not predict ozone levels.