使用 plot.ts 在 x-avis 上添加日期而不是数值

问题描述

我正在 R 中编写一个脚本,我必须在其中绘制存储在矩阵中的三个估计模型作为时间图。 我使用“quantmod”包从雅虎财经中提取数据,此后创建了一个包含这些数据日期的向量,称为 vDates。

现在我想根据向量中包含的日期绘制模型的估计值。他们有

plot.ts(mSigma_DJI,plot.type = "single",col = c("green","black","blue"),main = "Filtered volatilities for Dow Jones",xlab = "Time",ylab = expression(paste(sigma[t]^2)))

我以如下方式提取了数据:

library(quantmod)

# Reading the series for DJI and S&P500:
vSP500 = getSymbols("^GSPC",from = "2007-01-03",to = "2019-01-01",auto.assign = FALSE)

vDJI = getSymbols("^DJI",auto.assign = FALSE)

# Extracting the dates of the series to use in plots:
vDates = as.Date(row.names(as.matrix(vDJI)))[-1]

# Creating the series with the percentage logarithmic returns of both series
vSP500 = diff(log(as.numeric(vSP500$GSPC.Adjusted))) * 100
vDJI = diff(log(as.numeric(vDJI$DJI.Adjusted))) * 100

.
.
.

# Then the estimated values are save here:
mSigma_SP500[,"GARCH"] = GARCH_Fit_SP500$vSigma

但是情节看起来就像在附图中看到的那样。我希望将包含日期 vDates 的向量作为 x-avis,而不是绘图上的 x-avis。似乎我无法使用“xts”包来做到这一点。

Plot with numerical values on x-axis

有什么关于如何做到这一点的建议吗?

提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)