Do hotter days have more ozone in the air?
I’ll use a small New York City dataset to look at the relationship between temperature and ozone.
Ozone is just one measure of air quality, not all pollution.
Do hotter days have more ozone in the air?
I’ll use a small New York City dataset to look at the relationship between temperature and ozone.
Ozone is just one measure of air quality, not all pollution.
R’s built-in airquality data come from May–September 1973.
Temp = temperature (°F); Ozone = ozone level (ppb)I left out missing readings instead of counting them as zero.
The trend goes up, but ozone still varies a lot at similar temperatures.
I used a straight line to describe the relationship:
\[ \text{Ozone}_i = \beta_0 + \beta_1\text{Temp}_i + \varepsilon_i \]
R estimated:
\[ \widehat{\text{Ozone}} = -147 + 2.43\,\text{Temp} \]
For each 1°F increase, the line predicts about 2.43 ppb more ozone.
This is an association, not proof of cause and effect.
I used \(R^2\) to measure how much variation the line explains:
\[ R^2 = 1 - \frac{\sum (y_i-\hat y_i)^2}{\sum (y_i-\bar y)^2} \]
Here, \(R^2\) = 0.488. Temperature explains about 49% of the variation in these observations.
Here is the code used for the regression:
model <- lm(Ozone ~ Temp, data = aq) coef(model)
## (Intercept) Temp ## -146.995491 2.428703
summary(model)$r.squared
## [1] 0.4877072
lm() fits the line, and summary() gives \(R^2\).
Days 80°F or hotter generally have higher ozone, but the values are spread out.
Warmer days usually had more ozone in these data. But days at the same temperature could be very different.
This dataset is from one city in 1973, and some readings are missing. Wind and sunlight may also matter.
My conclusion: Temperature helps explain ozone levels, but it cannot predict them by itself.
Source: R built-in airquality dataset (?airquality).