0

I am trying to plot a garch model in R. However my results are showing as observation numbers instead of the date. I have tried ammending my csv file and adjusting the dates here with no solution. Is there a solution in R itself as I have seen that it should pick up dates automatically?

Here is a segment of my data csv file.

enter image description here

SWA<- ugarchspec(variance.model = list(model = "sGARCH",
          garchOrder=c(1,1), external.regressors = data.matrix(dummy_x2)), mean.model = list(armaOrder=c(1,0)),
                distribution.model = "std")

# fit model
# ugarchfit(spec, data)

SWA_fit<- ugarchfit(SWA, data = r_SW)
SWA_fit


#plot volatility
SWA_rhat<-SWA_fit@fit$fitted.values
plot.ts(SWA_rhat)
SWA_hhat<-ts(SWA_fit@fit$sigma^2)
plot.ts(SWA_hhat)
Billy
  • 1
  • 1
    Please edit your question in order to 1) provide data in code format - for example, by pasting the output of `dput(head(r_SW))`, and 2) clarify which libraries you are using – Andrea M Jun 14 '22 at 12:51
  • 1
    Welcome to SO, Billy! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including attempted code (please be explicit about non-base packages), sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Jun 14 '22 at 12:54
  • Have you checked your data classes using class()? plot.ts() works best with time series objects, btw. – John Garland Jun 14 '22 at 13:16
  • Thanks for your reply John, could you explain how to implement that piece of code? I have tried adding the below code with no no improvement. ""as.Date("2019-12-30"), colNames = TRUE, rowNames = TRUE, detectDates = TRUE, skipEmptyRows = TRUE)"" – Billy Jun 15 '22 at 10:28

0 Answers0