---
title: "Exercise 2.1"
author: "Garland Durham"
date: "January 22, 2017"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Exercise 02-01

```{r}
require(astsa)
require(knitr)
mort = cbind(Mortality=cmort, Temperature=tempr, Particulate=part)
plot.ts(mort)
pairs(mort)

trend=time(cmort)
temp=tempr - mean(tempr)
temp2 = temp^2
temp3 = temp^3
temp4 = temp^4
part2 = part^2
part3 = part^3

fit1 = lm( cmort ~ trend )
fit2 = lm( cmort ~ trend + temp )
fit3 = lm( cmort ~ trend + temp + part)
fit4 = lm( cmort ~ trend + temp + part + temp2)
fit5 = lm( cmort ~ trend + temp + part + temp2 + temp3 )
fit6 = lm( cmort ~ trend + temp + part + temp2 + temp3 + temp4 )
fit7 = lm( cmort ~ trend + temp + part + temp2 + temp3 + temp4 + part2 )
fit8 = lm( cmort ~ trend + temp + part + temp2 + temp3 + temp4 + part2 + part3)
```

```{r}
AIC(fit1, fit2, fit3, fit4, fit5, fit6, fit7, fit8)
BIC(fit1, fit2, fit3, fit4, fit5, fit6, fit7, fit8)

```

Both AIC and BIC suggest that the preferred model is fit5, which includes squared and cubed temperature.











```
