I am working on a script in R, where I have to plot three estimated models stored in a matrix as a plot against time. I have used the "quantmod"-package to extract the data from Yahoo Finance and hereafter created a vector containing the dates of these data, called vDates.
Now I want to plot the estimated values of my model against the dates contained in the vector. They have
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)))
I have extracted the data in the following way:
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",
from = "2007-01-03",
to = "2019-01-01",
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
But the plot looks like seen on the attached picture. Instead of the x-avis on the plot, I would like to have my vector containing the dates, vDates, as the x-avis. It seems like I am not able to do this using the "xts"-package.
Any suggestions on how to do this?
Thanks in advance.