---
title: "Lab 3"
author: "Name here"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(warning = FALSE)
library(datasets)
library(ggplot2)
library(dplyr)
```
Please use D2L to turn in both the PDF/ Word output and your R Markdown file.

For this lab, we will revisit the datasets that we saw on the first day of class. Recall the idea was to construct predictive intervals for a set of points. For each dataset construct point estimates and prediction intervals. Then, write a short paragraph summarizing your results. This should contain a description of what you used to make predictions and the outcome of your predictions (e.g. summary of how accurate your point estimates were and how many prediction intervals contained true values).



#### 1. Lake Huron Depth (33 and 1/3 points)

Predict the depth of Lake Huron in feet, or more specifically a prediction interval, for:

1. 1966: \vfill
2. 1970: \vfill
3. 1972: \vfill

```{r, echo =F, fig.align='center', fig.width=8, fig.height=8}
huron.depth <- data.frame(year = 1875:1972, depth = LakeHuron)
huron.depth[huron.depth$year > 1965, 'depth'] <- NA
label.Dates <- seq(1875,1972, 10)
ggplot(data=huron.depth, aes( x=year, y =depth)) + theme_gray() + geom_line() + geom_point() + ylim(575,585) + labs(title="Depth of Lake Huron", y="Feet") + scale_x_continuous(labels = label.Dates, breaks = label.Dates) 
```

#### 2. Airline Passengers (33 and 1/3 point)

Predict airline passenger counts in thousands, or more specifically a prediction interval, for:

1. January 1960:  \vfill
2. July 1960:  \vfill
3. December 1960: \vfill

```{r, echo =F, fig.align='center', fig.width=8, fig.height=8}
air.passengers <- data.frame(year = rep(c(1949:1960), each = 12), month = rep(1:12, 12), passengers = c(AirPassengers[-c(133:144)], rep(NA,12)))
air.passengers$strDates <- paste(air.passengers$month, '/15/',air.passengers$year, sep='')
air.passengers$date <- as.Date(air.passengers$strDates, "%m/%d/%Y")

label.Dates <- paste('Jan', 1949:1960, sep='')
break.dates <- as.Date(paste(1, '/15/',1949:1960, sep=''), "%m/%d/%Y")

ggplot(data=air.passengers, aes( x=date, y =passengers)) + geom_line() + geom_point() + ylim(0,700) + labs(title="Monthly Airline Passenger Count", y="Number of Passengers(thousands)") + scale_x_date(labels = label.Dates, breaks = break.dates) + theme(axis.text.x = element_text(angle = 90))

```

#### 3. Nile River Flow (33 and 1/3 points)

Predict Nile flow in million cubic meters, or more specifically a prediction interval, for:

1. 1911:  \vfill
2. 1913: \vfill
3. 1916: \vfill

```{r, echo =F, fig.align='center', fig.width=8, fig.height=8}
nile.flow <- data.frame(year = 1871:1970, flow = Nile)
nile.flow[nile.flow$year > 1910 & nile.flow$year < 1920,'flow'] <- NA
label.Dates <- seq(1871,1970, 10)
ggplot(data=nile.flow, aes( x=year, y =flow)) + theme_gray() + geom_line() + geom_point() + ylim(0,1500) + labs(title="Annual flow on Nile River", y="Million cubic meters") + scale_x_continuous(labels = label.Dates, breaks = label.Dates) 
```

