using facebooks 'Prophet' package in R for forecasting. Was wondering if there is a way use it, such that it does not forecast negative values?
Thanks!
To use Prophet for forecasting, first, a Prophet() object is defined and configured, then it is fit on the dataset by calling the fit() function and passing the data. The Prophet() object takes arguments to configure the type of model you want, such as the type of growth, the type of seasonality, and more.
Calculating Forecast Error A positive value of forecast error signifies that the model has underestimated the actual value of the period. A negative value of forecast error signifies that the model has overestimated the actual value of the period.
Cross validation. Prophet includes functionality for time series cross validation to measure forecast error using historical data. This is done by selecting cutoff points in the history, and for each of them fitting the model using data only up to that cutoff point.
Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data.
This is explained in the documentation in this page.
In brief, you should use "logistic" rather than "linear" growth. You must set a cap (a maximum logically possible value), and you can set a floor (if you don't set it, it will default to zero).
Assuming you have in df
your data (a ds
column with dates, and a y
column with values).
You need to set a cap, for the past, as well as the future.
(I'm taking the 8.5 example figures included in the documentation... the value can change for each day, this should obviously be set to something meaningful for your case)
You can (but you don't need to) set a floor, for a minimum value.
df$cap <- 8.5
m <- prophet(df, growth = 'logistic')
future <- make_future_dataframe(m, periods = 1826)
future$cap <- 8.5
#future$floor <- 1.5
fcst <- predict(m, future)
plot(m, fcst)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With