Bryan Pham
Bryan Pham

Reputation: 45

Times not plotting correctly using sarima in R

I ran into an issue while trying to use sarima.for which has led to the plot displaying incorrect times. As far as I can tell, the actual data is okay, just the dates.
Here's the short of what I put into the console:

SPX <- getSymbols("GSPC", auto.assign = FALSE, from = "2010-01-01")
SPXret <- SPX$GSPC.Close
SPXret <-as.ts(SPXret, start = c(2010, 1))
acf2(SPXret, max.lag = 12)
sarima(SPXret, 1, 1, 3)

I'm sure SPXret has the right time designations (begins at 2010 ends at present) and is an xts/zoo object. The issue is that when I use the function, the x axis starts at 3840 and ends at 3940! (As shown below)

enter image description here

What am I doing wrong here?

Upvotes: 2

Views: 199

Answers (1)

Marco Sandri
Marco Sandri

Reputation: 24262

SPX$GSPC.Close is a daily series that starts on 2010-01-04.
You need to specify this characteristic when defining the SPXret time-series object.

library(quantmod)
library(astsa)   

SPX <- getSymbols("^GSPC", auto.assign = FALSE, from = "2010-01-01")
SPXret <- SPX$GSPC.Close
SPXret <- ts(SPXret, frequency=365, start=c(2010,4))
sarima.for(SPXret, 5, 1, 1, 3)

enter image description here

Upvotes: 1

Related Questions