【发布时间】:2019-05-12 16:02:48
【问题描述】:
我的干预分析存在一些问题。我正在模拟 Nvidia (NVDA) 在 2016 年 4 月宣布深度学习超级计算机时对收盘价的影响。我添加了一个虚拟变量,在干预日期之前为 0,之后为 1,并将其添加为回归量在我的模型中。我的问题是我无法理解输出,因为我从未从干预系数中得到任何重要信息。我不知道我是否做错了什么。这是我的代码:
rm(list=ls())
library('ggplot2'); library('forecast'); library('tseries'); library('xts'); library(quantmod) ; library(lmtest)
start <- as.Date("2005-01-01")
end <- as.Date("2018-10-01")
getSymbols("NVDA", src = "yahoo", from = start, to = end)
plot(NVDA[, "NVDA.Close"], main = "NVIDIA")
# Adding dummy intervention variable
intDate<-as.Date("2016-04-05") # sets the intervention Date
closing = NVDA[, "NVDA.Close"]
closing$Intervention = 0
for (i in 1:nrow(closing)){
if (index(closing[i,1]) < intDate){
closing[i,"Intervention"] = 0
}
if(index(closing[i,1]) >= intDate){
closing[i,"Intervention"] = 1
}
}
model<-auto.arima(closing[,"NVDA.Close"], xreg = closing[,"Intervention"])
model
coeftest(model)
dates = as.Date(index(closing),"YYYY-MM-DD")
fittedVal = xts(fitted.values(model), dates)
plot(NVDA[,"NVDA.Close"], col = "blue", type = "l")
lines(fittedVal, col = "red", type = "l")
【问题讨论】:
标签: r time-series xts arima