---
title: "MATH 5075 R Project 2"
author: "Your Name Here"
date: "October 18, 2016"
output:
pdf_document:
keep_tex: TRUE
---
*Remember: I expect to see commentary either in the text, in the code with comments created using `#`, or (preferably) both! **Failing to do so may result in lost points!***
*Because randomization is used in this assignment, I set the seed here, in addition to beginning each code block. **Do not change the seed!***
```{r}
set.seed(10182016)
```
## Problem 1
*Consider the following $\text{AR}(p)$ process (with $w_t$ being i.i.d. standard Normal random variables):*
$$x_t = \frac{1}{2}x_{t - 1} - \frac{1}{3}x_{t - 2} + w_t$$
1. *Simulate this process in R using the function `arima.sim()` for $T = 500$ observations, burning in for 1000 observations.*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
2. *Compute and plot the sample autocorrelation function for the simulated process using `acf()`. Compare the sample autocorrelation function to the theoretical autocorrelation function, which you can compute and plot using `ARMAacf()`.*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
3. *The above process is a stationary process (why?), which implies that the process can be written in the form:*
$$x_t = \sum_{l = 0}^{\infty} \psi_l w_{t - l}$$
*Use the function `ARMAtoMA()` to compute the first 25 $\psi$-weights for this process (the theoretical $\psi$-weights, not the empirical), and plot them.*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
# Problem 2
1. *Simulate $T = 100$ observations from an $\text{AR}(1)$ process using `arima.sim()`, burning in for 500 observations, and plot the resulting process. Repeat for each of the following AR coefficients, and comment on what you see: $\phi \in \left\{-0.1, 0, 0.01, 0.1, 0.5, 0.7, 1, 1.2\right\}$*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
2. *Simulate $T = 100$ observations from an $\text{AR}(2)$ process using `arima.sim()`, burning in for 500 observations, and plot the resulting process. Repeat for each of the following combinations of AR coefficients, and comment on what you see: $(\phi_1, \phi_2) \in \left\{(-0.4, 0.4), (0, 0.4), (.5, .5)\right\}$*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
# Problem 3
1. *Consider the data set `globtempl` (**astsa**), which contains measurements of annual land temperatures from 1880 to 2015. Plot the data and estimate the sample autocorrelation function. Does this appear to be a stationary series? Does the ACF appear to be one that could plausibly come from an $\text{AR(p)}$ model? Do you believe that this series (without any modification) can be modeled by an $\text{AR}(p)$ model?*
```{r, error=TRUE, tidy=TRUE}
# install.packages("astsa")
library(astsa)
# Your code here
```
2. *Use `diff()` to compute the first differences of the `globtempl` data set, and repeat the analysis done in part 1 on the differences.*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```