|
| 1 | +install.packages("data.table") |
| 2 | +library("data.table") |
| 3 | +getwd() |
| 4 | +setwd("C:/Users/anshu/Desktop/UNCC Courses/Advanced Business Analytics/Homework4 - Time Series Analysis") |
| 5 | +data <- fread("ATT_Twitter.csv", sep=",", header=T, strip.white = T, na.strings = c("NA","NaN","","?")) |
| 6 | +head(data) |
| 7 | +install.packages("ts", repos = "https://cran.r-project.org") |
| 8 | +install.packages("forecast", repos = "https://cran.r-project.org") |
| 9 | +library(forecast) |
| 10 | +x = ts(data[,2], frequency = 24) |
| 11 | +x |
| 12 | +plot(x) |
| 13 | +PP.test(x) |
| 14 | +par(mfrow = c(1,2)) |
| 15 | +acf(x,main='ACF ATT_Twitter') |
| 16 | +pacf(x,main='PACF ATT_Twitter') |
| 17 | +library(forecast) |
| 18 | +ARIMAfit = auto.arima(x, approximation=FALSE,trace=TRUE) |
| 19 | +summary(ARIMAfit) |
| 20 | +install.packages("quantmod", repos = "https://cran.r-project.org") |
| 21 | +install.packages("lattice", repos = "https://cran.r-project.org") |
| 22 | +install.packages("timeSeries", repos = "https://cran.r-project.org") |
| 23 | +install.packages("rugarch", repos = "https://cran.r-project.org") |
| 24 | + |
| 25 | +library(quantmod) |
| 26 | +library(lattice) |
| 27 | +library(timeSeries) |
| 28 | +library(rugarch) |
| 29 | +#getSymbols("^GSPC", verbose=TRUE) |
| 30 | +par(mfrow = c(1,1)) |
| 31 | +plot(x) |
| 32 | + |
| 33 | +# for (0,1) |
| 34 | +spec1=ugarchspec(variance.model=list(model="sGARCH"), |
| 35 | + mean.model=list(armaOrder=c(0,1))) |
| 36 | +fit1=ugarchfit(data=x ,spec=spec1) |
| 37 | +show(fit1) |
| 38 | + |
| 39 | +#for (0,0) |
| 40 | +spec2=ugarchspec(variance.model=list(model="sGARCH"), |
| 41 | + mean.model=list(armaOrder=c(0,0))) |
| 42 | +fit2=ugarchfit(data=x,spec=spec2) |
| 43 | +show(fit2) |
| 44 | + |
| 45 | + |
| 46 | +spec3=ugarchspec(variance.model=list(model="apARCH"), |
| 47 | + mean.model=list(armaOrder=c(0,0))) |
| 48 | +fit3=ugarchfit(data=x,spec=spec3) |
| 49 | +show(fit3) |
| 50 | + |
| 51 | +spec4=ugarchspec(variance.model=list(model="apARCH"), |
| 52 | + mean.model=list(armaOrder=c(0,1))) |
| 53 | +fit4=ugarchfit(data=x,spec=spec4) |
| 54 | +show(fit4) |
0 commit comments