### Statistics 6871 - Time Series

### Lab 5

### Two more examples of fitting ARIMA models.

### Again note that Splus is case sensitive!

###########################################################################################

# Overshot data from a filling station in Colorado.

# Load the data.

Oshots <- rts(scan("I:\\Courswrk\\Stat\\esuess\\Stat6871\\Data_bd\\Oshorts.txt"))

ts.plot(Oshots, main="Overshots")

# Find a good ARIMA model for the data.

# Plot the ACF and PACF.

acf(Oshots)

acf(Oshots, type = "partial")

# Fit an AR(1) model and a MA(1) model, which model fits the data better?

Oshots.ar1 <- ar(Oshots, order.max = 1)

Oshots.ma1 <- arima.mle(Oshots, model=list(order=c(0,0,1)), n.cond = 2)