Baixe o app para aproveitar ainda mais
Prévia do material em texto
MODELO ARMA FEITO EM SALA DIA 28/08/2017 ################################### # lets use R database EuStockMarkets EuStockMarkets plot.ts(EuStockMarkets) # by plotting we notice that database has 4 columns representing # main stocks in Europe (DAX, SMI, CAC and FTSE) # DAX=alemão, SMI-Suiço, CAC-Francês, FTSE-inglês # # Now lets select the 300 first values of column 1 # which is DAX dax <- EuStockMarkets[1:300,1] dax plot.ts(dax) # lets get the returns of 300 values of DAX # use set.seed to reproduce results many times # and calculate ACF and PACF. rdax is DAX returns set.seed(123) rdax <- log(dax[2:300]) - log(dax[1:299]) rdax; plot.ts(rdax) acf(rdax) pacf(rdax) ########## ARMA ############ # arima is a command, rdax=variable, order is the order of # arma(p,q) or arima(p,0,q) and ML=maximum likelihood method armafit <- arima(rdax,order=c(1,0,1), method = "ML") # coeftest show coefficients and requires package lmtest. # If you do not have, install. coeftest(armafit) AIC(armafit) ## Residuals ## rfit <- residuals(armafit); rfit ## LB test for residuals. Requires package FitARfit ## LjungBoxTest(rfit, lag.max = 20) # ## Forecasting requires package forecast## rdaxfore <- forecast(armafit,level = 0.95) rdaxfore plot.forecast(rdaxfore,main = "Forecast Dax") # ## Testes de accuracy accuracy(armafit) ## Forecast values
Compartilhar