---
title: "MATH 5075 R Project 1"
author: "Your Name Here"
date: "October 3, 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(6222016)
```
## Problem 1
1. *Simulate 150 observations from the following process using the functions `rnorm()` and `filter()`:*
$$x_t = 0.5 x_{t - 1} - 0.4 x_{t - 2} + w_t$$
*($w_t \sim N(0,1)$) Discard the first 50 observations; this represents the "burn-in" period.*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
2. *Figure out how to use the function `lm()` to find the OLS estimate for the parameters in the models:*
$$x_t = \mu + \phi_1 x_{t - 1} + w_t$$
$$x_t = \mu + \phi_1 x_{t - 1} + \phi_2 x_{t - 2} + w_t$$
$$x_t = \mu + \phi_1 x_{t - 1} + \phi_2 x_{t - 2} + \phi_3 x_{t - 3} + w_t $$
*using the data obtained in part 1. Report the estimated parameters and their significance levels, the $R^2$ value, and the $F$ statistic with the associated $p$-value assessing the fit of the model. Which model appears to provide the best fit? Plot the residuals for each model. Do the residuals appear to be a white noise process? (Hint: consider making a data frame where the lags are the varianbles upon which you regress.)*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
## Problem 2
*The data set `gtemp` (**astsa**) contains data on global temperatures. This is an R `ts` object.*
1. *What span of time is covered by the data in `gtemp`? What is the data's frequency (is it semiannual, annual, biannual, monthly, etc.)?*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
2. *Plot the data in `gtemp`. Is this a stationary process?*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
3. *Use `diff()` to find the first difference of the data; this represents change in temperature. Plot the result. Does this appear to be a stationary process?*
```{r, error=TRUE, tidy=TRUE}
# Your code here
```
4. *Use the function `lm()` to fit the following model on the first differences of `gtemp`:*
$$y_t = \mu + \phi_1 y_{t - 1} + \phi_2 y_{t - 2} + \phi_3 y_{t - 3} + w_t$$
```{r, error=TRUE, tidy=TRUE}
# Your code here
```