--- title: "Lab 4" 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). #### Q1. AR Simulation (50 pts) ##### a. Write a function to simulate an AR(p) process. ```{r} simAR <- function(p, alpha, sigma, time.pts){ # function to simulate and AR process # inputs: p - number of AR components # : alpha - the vector of alpha coefficient # : sigma - standard deviation of noise # : time.pts - number of time points # outputs: the time series vector as a ts object } ``` ##### b. Generate a series of length 25 using the following model $x_t = x_{t-1} + \frac{1}{4}x_{t-1} + w_t$ and plot the ACF and PACF. Do the ACF and PACF meet your expectations, why or why not? ##### c. Generate a series of length 1000 using the following model $x_t = x_{t-1} + \frac{1}{4}x_{t-1} + w_t$ and plot the ACF and PACF. Do the ACF and PACF meet your expectations, why or why not? #### 2. Lake Huron Depth (50) Using the `ar()` model, fit an AR model to predict the depth of Lake Huron in feet. Summarize the fit of the model (describe the parameters), and then make predictions (point estimates) for the three time periods below. 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) ```