`RetornosS&P` <- read.delim("~/catedraeconometria/RetornosS&P.txt")
View(`RetornosS&P`)
attach(`RetornosS&P`)
library(tseries)
## Warning: package 'tseries' was built under R version 3.2.4
plot(Log.Return, type = "l")

Log.Return2 <-c(Log.Return[2:794])
adf.test(Log.Return2, alternative="stationary", k=0)#Dickey-Fuller Test
## Warning in adf.test(Log.Return2, alternative = "stationary", k = 0): p-
## value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Log.Return2
## Dickey-Fuller = -26.824, Lag order = 0, p-value = 0.01
## alternative hypothesis: stationary
acf(Log.Return2)#Autocorrelation Function Of The Sample

pacf(Log.Return2)#Partial Autocorrelation Function of The Sample

arima(Log.Return2, order = c(1,0,0))#AR process
##
## Call:
## arima(x = Log.Return2, order = c(1, 0, 0))
##
## Coefficients:
## ar1 intercept
## 0.0470 -0.6012
## s.e. 0.0355 0.1553
##
## sigma^2 estimated as 17.37: log likelihood = -2257.07, aic = 4520.14
arima(Log.Return2, order = c(0,0,1))#MA process
##
## Call:
## arima(x = Log.Return2, order = c(0, 0, 1))
##
## Coefficients:
## ma1 intercept
## 0.0519 -0.6011
## s.e. 0.0374 0.1556
##
## sigma^2 estimated as 17.36: log likelihood = -2256.98, aic = 4519.96
acfar1 <-ARMAacf(c(0.0470), 0.0, lag.max = 25)
acf(acfar1);acf(Log.Return2)


pacf(acfar1)

acfma1 <-ARMAacf(c(0.0), 0.0519, lag.max = 25)
acf(acfma1)

pacf(acfma1)

arima(Log.Return2, order = c(2,0,0))
##
## Call:
## arima(x = Log.Return2, order = c(2, 0, 0))
##
## Coefficients:
## ar1 ar2 intercept
## 0.0491 -0.0461 -0.6009
## s.e. 0.0355 0.0355 0.1483
##
## sigma^2 estimated as 17.33: log likelihood = -2256.23, aic = 4520.45
arima(Log.Return2, order = c(0,0,2))
##
## Call:
## arima(x = Log.Return2, order = c(0, 0, 2))
##
## Coefficients:
## ma1 ma2 intercept
## 0.0532 -0.0452 -0.601
## s.e. 0.0355 0.0347 0.149
##
## sigma^2 estimated as 17.33: log likelihood = -2256.13, aic = 4520.25