Uploaded by wantmypp

test.Rmd

advertisement
--title: "Homework 4"
author: "Sumit Purkayastha"
date: "3/29/2021"
output: word_document
--```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
##generate n=100 obs for the three ARMA models
```{r}
set.seed(500)
ARMA11.hat <- arima.sim(list(order=c(1,0,1), ar=0.6, ma=0.9), n=100)
set.seed(400)
ARMA10.hat <- arima.sim(list(order=c(1,0,0), ar=0.6), n=100)
set.seed(300)
ARMA01.hat <- arima.sim(list(order=c(0,0,1), ma=0.9), n=100)
```
Plots for n = 100 generated observations from ARMA(1, 1), ARMA(1, 0) and ARMA(0,
1). ($\phi$ = 0.6, $\theta$ = 0.9):
```{r}
par(mfrow = c(3, 1), mar = c(2.5, 2.5, 2, 2))
plot(ARMA11.hat, xlab = "Time", main = "ARMA (1, 1)")
plot(ARMA10.hat, xlab = "Time", main = "ARMA (1, 0)")
plot(ARMA01.hat, xlab = "Time", main = "ARMA (0, 1)")
```
#sample acfs
```{r}
ACF11.hat <- acf(ARMA11.hat, plot=F)
ACF11.hat$acf[1] <- NA
ACF10.hat <- acf(ARMA10.hat, plot=F)
ACF10.hat$acf[1] <- NA
ACF01.hat <- acf(ARMA01.hat, plot=F)
ACF01.hat$acf[1] <- NA
```
##sample acf up to lag 10
```{r}
ACF11.sam = ACF11.hat$acf[-1][1:10]
ACF10.sam = ACF10.hat$acf[-1][1:10]
ACF01.sam = ACF01.hat$acf[-1][1:10]
```
#theoretical acfs
```{r}
ACF11 <- ARMAacf(ar=0.6, ma=0.9, 100)[-1]
ACF10 <- ARMAacf(ar=0.6, ma=0, 100)[-1]
ACF01 <- ARMAacf(ar=0, ma=0.9, 100)[-1]
```
##comparison of sample acf values from population acf values
```{r}
table = cbind(ACF11.sam, ACF11[1:10], ACF10.sam,
ACF10[1:10],ACF01.sam,ACF01[1:10])
table
```
Graphical comparison of the theoretical and sample ACFs. Theoretical ACFs
plotted in red.
```{r}
This study source was downloaded by 100000861553708 from CourseHero.com on 02-06-2023 18:02:30 GMT -06:00
https://www.coursehero.com/file/86272213/testRmd/
par(mfrow=c(3,1), mar = c(2, 2.5, 3, 2.5))
plot(ACF11.hat, main="ACF, ARMA(1,1)", xlab = "Lag", ylab = "ACF", ylim=c(0.21,1))
lines(ACF11, col="red")
plot(ACF10.hat, main="ACF, ARMA(1,0)", xlab = "Lag", ylab = "ACF", ylim=c(0.21,1))
lines(ACF10, col="red")
plot(ACF01.hat, main="ACF, ARMA(0,1)", xlab = "Lag", ylab = "ACF", ylim=c(0.21,1))
lines(ACF01, col="red")
```
The ACF for the ARMA(1, 1) and ARMA(1, 0) are similar to their respective
theoretical ACFs and both exponentially decrease to 0. The ARMA(1, 1) and
ARMA(1, 0) models cannot be distinguished completely from their ACF plots. The
ARMA(0, 1) model is somewhat distinct from the other two models since it has
significant autocorrelation ar lag-1 and insignificant autocorrelation for lags
reater than 1 and is consistent with the theoretical ACF.
#sample partial acfs
```{r}
PACF11.hat <- pacf(ARMA11.hat, plot=F)
PACF10.hat <- pacf(ARMA10.hat, plot=F)
PACF01.hat <- pacf(ARMA01.hat, plot=F)
```
#theoretical pacfs
```{r}
PACF11 <- ARMAacf(ar=0.6, ma=0.9, 100, pacf=T)
PACF10 <- ARMAacf(ar=0.6, ma=0, 100, pacf=T)
PACF01 <- ARMAacf(ar=0, ma=0.9, 100, pacf=T)
```
#plots
```{r}
par(mfrow=c(3,1), mar = c(2, 2.5, 3, 2.5))
plot(PACF11.hat, main="PACF, ARMA(1,1)", ylim=c(-0.5,1))
lines(PACF11, col="red")
plot(PACF10.hat, main="PACF, ARMA(1,0)", ylim=c(-0.5,1))
lines(PACF10, col="red")
plot(PACF01.hat, main="PACF, ARMA(0,1)", ylim=c(-0.5,1))
lines(PACF01, col="red")
```
The ARMA(1, 1) and ARMA(0, 1) have PACFs decreasing exponentially to 0 and the
ARMA(1, 0) model has a non-zero PACF only at lag-1. If the ACF for any time
series data has significant non-zero ACF at lag-1 and insignificant
autocorrelations for lags greater than 1, then an ARMA(0, 1) model would be
good. If the ACF plot for any time series data has significant non-zero
autocorrelations for lags greater than or equal to 1, then either an ARMA(1, 1)
or ARMA(1, 0) model would be better. If this is the case, we can then plot the
partial ACFs and if the PACF haS a significant non-zero partial autocorrelations
only at lag-1, an ARMA(1, 0) model may be appropriate. So, the ACF plots for
both the ARMA(1, 1) and ARMA(1, 0) tails off to 0 while the ARMA(0, 1) ACF cuts
off after lag-1. The PACF plots for ARMA(1, 1) and ARMA(0, 1) tails off while
the ARMA(1, 0) PACF cuts off after lag-1.
This study source was downloaded by 100000861553708 from CourseHero.com on 02-06-2023 18:02:30 GMT -06:00
https://www.coursehero.com/file/86272213/testRmd/
Powered by TCPDF (www.tcpdf.org)
Download