I am pretty new to the topic of time series analysis and I am trying to use the package "forecast" on daily temperature data to predict the daily temperature in the future. To be precise, I just need one day after the given time series. My data looks like this:
As you can see there is seasonality in the dataset, every 365 days the cycle repeats. Additionally, there is no trend, so the mean and variance stays approximately the same throughout the cycles. From what I can see I need a approach for a seasonal time series without a trend. I already tried to do that with a Seasonal decomposition and then an ARIMA and a SARIMA model. Here is my code:
x<-ts(dataset,start = c(2011,1,1),end = c(2020,8,31),frequency = 365)
pred<-stlf(x,h=1,method="arima")
Just to show how good it fits I visualized the model for two following years with
stlf(x,h=2*365,method="arima") %>%
autoplot()
That is not a bad fit but it is not precise enough for my purpose. so I tried to fit a SARIMA model. First of all I try to get the optimal parameters for the SARIMA model with the auto.arima() function. The problem is that it takes very long to calculate and I am not sure if this is the right approach. I wanted to continue with the parameters put in the samira.for() function and predict the future values afterwards.
fit<-auto.arima(x)
Maybe you guys could help me find the right approach. What could I change or is this even the right way to do it for my purpose? It was difficult for me to create a reproducible example but maybe you can also help me like that.
Thanks in advance!
ts
class does not support dates.start=
should be a 2 element vector with the year as the first element and a number between 1 and 365 as the second number representing the day of the year of the start if the frequency of the series is 365.end=
is not needed ifstart
is specified. Remove one day in each leap year such as Feb 29 or Dec 31 if you want this to correspond to year and day of the year. $\endgroup$inds <- seq(as.Date("2011-01-01"), as.Date("2020-08-31"), by = "day") new_x<-ts(dataset,frequency = 365,start = c(2011,as.numeric(format(inds[1], "%j"))))
. This should do it $\endgroup$