My data is the hourly number of patients that enter the Emergency unit, meaning that I have 24 points of data per day like in the table below.
str(data)
'data.frame': 21840 obs. of 2 variables:
$ Date: POSIXct, format: "2017-05-01 00:00:00""2017-05-01 01:00:00" ...
$ Freq: int 3 2 2 0 0 0 0 2 4 7 ...
data
Date Freq
1 2017-05-01 00:00:00 3
2 2017-05-01 01:00:00 2
3 2017-05-01 02:00:00 2
4 2017-05-01 03:00:00 0
5 2017-05-01 04:00:00 0
....
I'm trying to use the forecast package to predict the number of patients that enter the unit per hour with a month in advance.
I'm having some problems with the msts function and the forecast:
msts_cons<-msts(data$Freq, seasonal.periods = c(24,168))
-> my first question is about the seasonal periods: are those correct? The first corresponds to a daily seasonality and the second to a weekly pattern. Is there a function to find other seasonality? Also, how can I indicate the correct start ( 2017-05-01 00:00:00) and end date ( 2019-31-31 23:00:00) if my data is hourly?
accuracy(fmcast,teste$Freq)
ME RMSE MAE MPE MAPE MASE ACF1
Training set 0.007965302 2.468848 1.840179 NaN Inf 0.6851999 0.0009135862
Test set 0.226633926 2.622561 1.940317 -Inf Inf 0.7224869 NA
When I run auto forecast on my data the MAPE is infinitive, this happens because some of my real values are 0, right?
Also in the forecast function the value h is the number of forecasts that I want, correct? So to predict a month of hourly entries I need h=720
?
Thanks in advance.