Solved – ARIMA: extract date/time information from ARIMA model

arimaforecastingrtime series

I create an ARIMA model for my ts-object. My data is available in seconds or even miliseconds. I didn't find a way to specify the time information for the start- and end-parameters when creating the ts object?

I need the exact time, because I want to extract the time information when I do the forecast based on the ARIMA model to return the exact times for my forecasted values. It would be enough to store the end-time information somewhere in my ARIMA model, so that I can use it later when I do the forecast.

How is this done usually with ARIMA models?

Thanks!

Best Answer

Did you see the help file for the ts function? At the bottom there are examples for quarterly and monthly time series. Perhaps you could directly extend this to second-wise series? You only need to specify the start date, not the end date.

For example, instead of using start = c(1954, 7), frequency = 12 for monthly data starting in July 1954 you could use start = c(d, s), frequency = 60*24 for second-wise data starting on day d, second s. The time attribute of your data would be given in days.

set.seed(1)
x=rnorm(10^4) # generate random data
d=1
s=1
x=ts(x,start=c(d,s),frequency=60*24)
plot(x)
print(time(x)) # extract the 'time' attribute of the 'ts' object

There might be a better solution, but perhaps this one is sufficient?