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

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

For this exercise, we will revisit the avocado dataset. Our goal is to fit a model that explains avocado volumes. This should build upon the methods you used for question 4 on homework 4.

For this analysis, the goal is to understand the relationship between the volume of conventional avocados purchase and a set of explantory variables.
```{r}
library(readr)
library(dplyr)
library(lubridate)
library(forecast)
library(ggplot2)
avo <- read_csv('http://www.math.montana.edu/ahoegh/teaching/timeseries/data/avocado_west.csv')

avo.volume <- avo %>% arrange(Date) %>% filter(type == 'conventional') %>% mutate(month = month(Date), year = year(Date), week.number = 1:n())

ggtsdisplay(avo.volume %>% select(TotalVolume) %>% pull() %>% ts(), main = 'Conventional Avocado Volumes') 
```

Assume that you are interested in an explanatory modeling framework that assess the impact of avocado price, year, month, and whether the week is a super bowl week to model prices. Additionally, use appropriate tools to verify that the residuals of this model do not contain any structure.


Print out your results and include a written summary of your findings.
