--- title: "HW 4" author: "Name here" date: "Due October 5, 2018" output: html_document --- Please use D2L to turn in both the PDF output and your R Markdown file. Include your code in line in the document. #### Q1. (4 pts) With a random walk, show mathematically and explain the intuition behind why the covariance, $\gamma_k(t) = t\sigma^2$. #### Q2. (4 pts) 536 Only With a random walk, show mathematically that $\rho_k(t) = \frac{1}{\sqrt{1 + \frac{k}{t}}}$. Then write code to estimate $\rho_k(t)$. #### Q3. About $\alpha$ (4 points) In lecture 6, we spent a lot of time talking about the $\alpha$ parameter. Use the code below to fit the Holt Winters method with 3 different values of $\alpha$: 1. the optimized version, 2. $\alpha = 1$, and $\alpha$ near 0. Compare and contrast the results from these three settings. ```{r, eval = F} # Simulate Data set.seed(09142018) mu.evol.sd <- .5 sigma <- 1 time.pts <- 100 mu <- rep(0,time.pts) x <- rep(0, time.pts) for (t in 2:time.pts){ mu[t] <- mu[t-1] + rnorm(1,mean=0, sd=mu.evol.sd) x[t] <- mu[t] + rnorm(1, mean=0, sd=sigma) } # Plot Data ts.df <- data.frame(mu=mu, x=x, time = 1:time.pts) library(ggplot2) ggplot(data=ts.df) + geom_line(aes(x = time, y = mu), color = "red") + geom_point(aes(x=time, y=x)) + ylab('') + ggtitle('Simulated Time Series') + labs(caption = "latent mean shown in red and observed points in black") # 1. Fit HoltWinters - let model find alpha ts.x <- ts(x) HW.1 <- HoltWinters(ts.x, gamma = FALSE, beta = FALSE) HW.1$alpha HW.1.pred <- predict(HW.1, n.ahead = 5, prediction.interval = T); plot(HW.1, HW.1.pred) # 2. Fit HoltWinters - set alpha = 1 HW.2 <- HoltWinters(ts.x, gamma = FALSE, beta = FALSE, alpha = 1) HW.2$alpha HW.2.pred <- predict(HW.2, n.ahead = 5, prediction.interval = T); plot(HW.2, HW.2.pred) # 3. Fit HoltWinters - set alpha near 0 HW.3 <- HoltWinters(ts.x, gamma = FALSE, beta = FALSE, alpha = .01) HW.3$alpha HW.3.pred <- predict(HW.3, n.ahead = 5, prediction.interval = T); plot(HW.3, HW.3.pred) ``` #### Q4 (12 pts) The final question for Lab 2 stated *Discuss a strategy for estimating the volume of avocados sold weekly ...*. Now implement a procedure to estimate the total volume of avocados sold during each week for 10 weeks after the end of the data available in the data set. I'd like you to treat this as a short report, which I'd expect to be somewhere between 3/4 a page and 2 pages (depending on the size of your graphics). You can assume your audience is the owner of Jam. The report should include the following: 1. Intro: (talk a little about avocadoes) 2. Data: (Discuss the dataset, probably a visualization of some form) 3. Methods: (Describe what you are using as a model. There might be a little math - particularly for 536 students, but make sure this is acccessible to the general public). 4. Results and Summary: Summarize your predictions, make sure to talk about uncertainty.