0% found this document useful (0 votes)
64 views4 pages

Ozone Analysis Using Linear Models

The document analyzes the relationship between ozone levels and various predictor variables like solar radiation, wind, temperature, and month using linear regression models on air quality data. It first fits a linear model with all predictors and plots diagnostics. A second model is then fit with wind, wind-squared, temperature, and temperature-squared as predictors, which improves fit slightly based on summary statistics.

Uploaded by

lucas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views4 pages

Ozone Analysis Using Linear Models

The document analyzes the relationship between ozone levels and various predictor variables like solar radiation, wind, temperature, and month using linear regression models on air quality data. It first fits a linear model with all predictors and plots diagnostics. A second model is then fit with wind, wind-squared, temperature, and temperature-squared as predictors, which improves fit slightly based on summary statistics.

Uploaded by

lucas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

> data(airquality)

> attach(airquality)
> names(airquality)
[1] "Ozone" "Solar.R" "Wind" "Temp" "Month" "Day"
> plot(Month,Ozone)
150
100
Ozone

50
0

5 6 7 8 9

Month

> ozone.fit1<- lm(Ozone~.,airquality)


> plot(ozone.fit1)

Residuals vs Fitted
100

117

62
50

30
Residuals

0
-50

-20 0 20 40 60 80 100

Fitted values
lm(formula = Ozone ~ ., data = airquality)

1
Normal Q-Q plot

5
117
4

62
3
Standardized residuals

30
2
1
0
-1
-2

-2 -1 0 1 2

Theoretical Quantiles
lm(formula = Ozone ~ ., data = airquality)

Scale-Location plot
117
2.0

62
1.5

30
Standardized residuals

1.0
0.5
0.0

-20 0 20 40 60 80 100

Fitted values
lm(formula = Ozone ~ ., data = airquality)

2
Cook's distance plot

0.25
117
0.20
0.15
Cook's distance

62
0.10

9
0.05
0.00

0 20 40 60 80 100

Obs. number
lm(formula = Ozone ~ ., data = airquality)

> summary(ozone.fit1)

Call:
lm(formula = Ozone ~ ., data = airquality)

Residuals:
Min 1Q Median 3Q Max
-37.014 -12.284 -3.302 8.454 95.348

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -64.11632 23.48249 -2.730 0.00742 **
Solar.R 0.05027 0.02342 2.147 0.03411 *
Wind -3.31844 0.64451 -5.149 1.23e-06 ***
Temp 1.89579 0.27389 6.922 3.66e-10 ***
Month -3.03996 1.51346 -2.009 0.04714 *
Day 0.27388 0.22967 1.192 0.23576
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Residual standard error: 20.86 on 105 degrees of freedom


Multiple R-Squared: 0.6249, Adjusted R-squared: 0.6071
F-statistic: 34.99 on 5 and 105 DF, p-value: < 2.2e-16

Now lets try a new model

> ozone.fit2<- lm(Ozone~Wind+I(Wind^2)+Temp+I(Temp^2),airquality)

3
> ozone.fit2

Call:
lm(formula = Ozone ~ Wind + I(Wind^2) + Temp + I(Temp^2), data =
airquality)

Coefficients:
(Intercept) Wind I(Wind^2) Temp I(Temp^2)
279.99831 -12.75492 0.44873 -6.07823 0.05069

> summary(ozone.fit2)

Call:
lm(formula = Ozone ~ Wind + I(Wind^2) + Temp + I(Temp^2), data =
airquality)

Residuals:
Min 1Q Median 3Q Max
-47.960 -11.266 -2.528 9.815 85.929

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 279.99831 106.00903 2.641 0.00945 **
Wind -12.75492 2.40170 -5.311 5.67e-07 ***
I(Wind^2) 0.44873 0.10566 4.247 4.52e-05 ***
Temp -6.07823 2.84598 -2.136 0.03490 *
I(Temp^2) 0.05069 0.01862 2.723 0.00752 **
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

Residual standard error: 19.32 on 111 degrees of freedom


Multiple R-Squared: 0.6688, Adjusted R-squared: 0.6569
F-statistic: 56.04 on 4 and 111 DF, p-value: < 2.2e-16

You might also like