---
title: "ADA2: Class 13, Ch 08, polynomial regression"
author: "Name Here"
date: "mm/dd/yyyy"
output:
pdf_document:
number_sections: yes
toc: yes
html_document:
toc: true
number_sections: true
code_folding: show
---
```{R, echo=FALSE}
# I set some GLOBAL R chunk options here.
# (to hide this message add "echo=FALSE" to the code chunk options)
knitr::opts_chunk$set(comment = NA, message = FALSE, warning = FALSE, width = 100)
knitr::opts_chunk$set(fig.align = "center", fig.height = 4, fig.width = 6)
knitr::opts_chunk$set(cache = TRUE, autodep=TRUE) #$
```
# Hooker's Himalayian boiling point altitude data
Dr. Joseph Hooker collected the following data in the 1840s on the boiling
point of water and the atmospheric pressure at 31 locations in the Himalayas.
Boiling point is measured in degrees Fahrenheit. The pressure is recorded in
inches of mercury, adjusted for the difference between the ambient air
temperature when he took the measurements and a standard temperature.
The goal was to develop a model to predict the atmospheric pressure from the
boiling point.
_Historical note:_ Hooker really wanted to estimate altitude above sea level from
measurements of the boiling point of water. He knew that the altitude could be
determined from the atmospheric pressure, measured with a barometer, with lower
pressures corresponding to higher altitudes. His interest in the above
modelling problem was motivated by the difficulty of transporting the fragile
barometers of the 1840s. Measuring the boiling point would give travelers a
quick way to estimate elevation, using the known relationship between elevation
and barometric pressure, and the above model relating pressure to boiling
point.
```{R}
fn.data <- "http://statacumen.com/teach/ADA2/worksheet/ADA2_WS_13_boilingpressure.txt"
boil <- read.table(fn.data, header=TRUE, skip = 2)
```
## __(2 p)__ Plot the data.
Using `ggplot`, try to implement these features in a plot.
Overlay both a straight-line regression line in blue (`geom_smooth(method = lm, col = "blue", ...)`),
as well as a loess smooth (default) dashed line in red (`geom_smooth(method = loess, col = "red", linetype = 2, ...)`).
Using `alpha=1/5` will make the confidence bands more transparent.
Also, if you plot the points last, they'll lie on top of the lines.
Describe the key features of this plot.
### Solution
[answer]
## __(3 p)__ Fit a simple linear regression, assess assumptions.
Fit a simple linear regression model for predicting pressure from boiling
point. Provide output for examining residuals, outliers, and influential cases.
Looking at the plots, are there any indications that the mean pressure is not
linearly related to boiling point? Are there any observations that appear to be
highly influencing the fit of this model? Are there certain points or regions
of the data where the model does not appear to fit well? Discuss.
Which, if any, of the standard linear regression model assumptions appears to
be violated in this analysis? If you believe that some of the assumptions are
violated, does it appear that deleting one or two points would dramatically
improve the fit? Would you use this model for predicting pressure from boiling
point? Discuss and carry out any needed analysis to support your position.
### Solution
[answer]
## __(1 p)__ Interpret $R^2$
Interpret $R^2$ in the previous simple linear regression model.
### Solution
[answer]
## __(2 p)__ A better model.
Decide whether transformation, or a polynomial model in boiling point, is
needed to adequately summarize the relationship between pressure and boiling
point. If so, perform a complete analysis of the data on this scale (that is,
check for influential observations, outliers, non-normality, etc.).
### Solution
[answer]
## __(2 p)__ Final model.
Regardless of which scale you choose for the analysis, provide an equation to
predict pressure from boiling point. Write a short summary, pointing out any
limitations of your analysis.
### Solution
[answer]