Comments (17)
A note about this:
There isn't currently a way to do joint forecasts in Prophet. However, there is something you can do if you have time series that you believe are correlated, AND one of them is easier to forecast than the others. A typical setting would be that you have a top-level thing you want to forecast, but then you also want to forecast sub-groups of it (e.g., demographic breakdowns). The top-level thing is often easier to forecast because it has the most data, and noise levels are often lower. If this is the case, then you can try the following procedure:
- Forecast the top-level time series with Prophet.
- Forecast each subgroup independently, but include the top-level forecast as an extra regressor. This will encourage the subgroup forecast to track the top-level forecast unless there is clear evidence to the contrary.
Something to try, YMMV. The subgroup forecasts may also benefit from reducing the prior scales for both trend changepoints and seasonality, since especially the seasonality will likely be largely captured by the top-level extra regressor.
As a side note, I would not expect including forecast A as an extra regressor for forecast B to be beneficial unless A is somehow easier to forecast than B.
from prophet.
Thanks for the interest in taking this on! Here are my current thoughts.
Simultaneous models
y_1(t) = f_1(t) + e_1(t)
y_2(t) = f_2(t) + e_2(t)
The two ways y_1(t) and y_2(t) can be related are:
- If f_1 and f_2 are related somehow. The way to do that would be to have all of their parameters have a prior distribution so they are shrunk toward the same values. E.g. they share related seasonality, trend, and changepoints.
- If e_1(t) and e_2(t) are correlated. This is a bit harder to model and interpret.
We could do 1. pretty easily in Stan, but the benefits for sharing the parameters would be small unless you have many time series (I'd say at least 5-10).
Hierarchy of time series
y_1(t) = f_1(t) + e_1(t)
y_2(t) = f_2(t) + g(y_1(t)) + e_2(t)
In this case there's a hierarchy of time series. So it's a bit simpler (assuming you know the order):
- you fit the
y_1
model by itself - you regress
y_1(t)
ony_2(t)
and learn their relationship. - instead fitting
y_2
model, you forecast residual:[y_2(t) - g(y_1(t))]
- To forecast
y_2
, you forecasty_1
, use the model from (2) to and the forecast from (3) to construct they_2
forecast.
This strategy requires more bookkeeping and model fits, whereas the first strategy everything would be done in one fitting step.
Curious if @bletham has thoughts.
from prophet.
Hi, are there any plans to progress development on prophet handling multivariate data? I've found the package to be extremely useful for univariate time series - thanks for your recent release! - and there does seem to be some demand from other users.
from prophet.
I think that handling this with a hierarchical prior for each parameter could work really well in some situations but I see two potential complications. The first is that I do not expect MAP estimation to perform well with the hierarchical model, so we'd have to do MCMC which can be slow. The second, and more serious, is that putting a hierarchical prior on a parameter (e.g. a seasonality coefficient) implies that we think they should be similar between the two time series, i.e. they are positively correlated. We need a solution that will borrow strength across negatively correlated time series also. So maybe a joint prior for the seasonality coefficients that includes a covariance parameter? I think this would be especially challenging to extend to the changepoint deltas which have a Laplace prior.
If we fit a prophet model to y1
, and then fit a second prophet model to the residuals y2 - g(y1)
, it isn't clear to me that we have actually borrowed strength anywhere or will do any better than just forecasting y2
separately, unless we put some additional regularization on the y2-g(y1)
forecast. I think something along this line could be successful if the fit were done jointly. The model might be:
y_1(t) = f_1(t) + \eps_1
y_2(t) = a f_1(t) + b + \lambda f_2(t) + \eps_2
where f_1
and f_2
are prophet models. Here y_1
basically gets the usual prophet model, and for y_2
there would be some scalar factor a
and offset b
, and then an additional prophet model f_2
but which has a factor \lambda
that is regularized to 0. f_1
, f_2
, a
, b
, and the noise parameters are jointly estimated. b
could potentially also be something like a linear function b(t)
to allow for an unregularized constant trend difference. We'd want to get some idea of what relationship is actually needed for a useful set of multivariate problems. It may also be difficult to have a default for \lambda that 'usually works.'
from prophet.
any update on this?
from prophet.
It isn't being worked on, though I know the https://github.com/ourownstory/neural_prophet project (which is a Prophet-style model implemented in pytorch) is currently working on multivariate forecasting and so may be a good place to discuss your use case.
from prophet.
Hi @bletham @seanjtaylor , I'd appreciate your thoughts on the following sequential setup. Consider we have a number of time series m
from which there is a high correlation between subsequent series, meaning you can clearly establish the following sequence: t_1 -> t_2 -> ... -> t_m
. Would be preferable to regress based on previous forecast (i.e. t_m-1
as regressor of t_m
) or fixed the regressor to the very first series t_1
? Please note that t_1
is the top-level time series of the example.
Also, would you consider as regressor prophet's forecast or a merge of historical value plus forecasted values.
Thanks
from prophet.
Hi @bletham, can you review Vonum approach of multivariate? Maybe you can merge both repository and add multivariate capabilities of prophet? See https://github.com/vonum/multi-prophet
from prophet.
Perhaps I'm thinking about this incorrectly, but I see the outcome as a vector, not as a single value.
y(t) = f(t) + e(t)
where y(t) is a multi-dimensional vector of values (measurements) characterizing traffic levels across all freeway lanes at some point.
I think I should probably learn Stan first, and understand why it might/might not be restricted to one-dimensional observations before attempting to "tackle this feature" for prophet.
from prophet.
can anyone tell me how to implement hierarchical forecasting using PROPHET in R.i am struggling with the use of time series data frame in prophet function as it throws error.
from prophet.
These are both good questions.
For the first, I think there are two important things for the inclusion of the extra regressor to be valuable. The first is that it be correlated with the target time series. By this consideration, t_m-1
seems best. However, the second important consideration is that the extra regressor needs to somehow be easier to forecast than t_m
. Conditioning the forecast of t_m
on something that has just as high forecast uncertainty as t_m
would have if I were to forecast it by itself is clearly not useful. As a thought experiment, you can imagine including t_m
as an extra regressor for forecasting t_m
! They are perfectly correlated, but obviously I will not get any value from doing this because of the uncertainty in the forecast of the regressor.
This is the biggest challenge with having meaningful extra regressors, but is also something that may be satisfied for these sort of hierarchical time series. It seems to often be the case that the top-level time series has more data, less noise, and is easier to forecast. In this case, there can be value to including it as an extra regressor (the actual value will depend on how correlated it is).
For your second question, I suspect it would be best to use the Prophet forecast yhat
as the extra regressor for both historical values and future values so that we cut out the observation noise in both segments. But I'd be really curious if you try both to hear what you find.
As a note for the future, it will be very useful/important to incorporate the uncertainty in the regressor forecast into the prophet forecast. Conceptually, this is pretty straightforward: When sampling future uncertainty, for each sample use a different sampled draw from the regressor forecast (but ignoring the noise level, which means a change here: https://github.com/facebook/prophet/blob/master/python/fbprophet/forecaster.py#L1330 ). In terms of implementation, this means we'll have to have a way to pass along this uncertainty, or more likely have a specific interface for including a prophet model as a regressor so we can sample directly from it. Related to #442.
from prophet.
To summarize the above: at this point it's not possible/simple to use prophet to predict more than one series/feature, right? If so, any plans to add this capability?
(Example of multiple series/feature: instead of using just the temperature to forecast weather, it would be beneficial, and more accurate, to use other feature such as humidity, pressure, etc)
from prophet.
@jheffez Correct. If the other humidity and pressure are easier to forecast than temperature than you could include them (and their forecasts) as extra regressors in your forecast of temperature, but there is no way to jointly forecast all three at the same time.
This is certainly on the to-do list, but it will require a pretty substantial amount of new modeling and testing, and I don't expect to happen soon. We'll likely first focus on the hierarchical case that I describe in my Oct 16 comment above.
from prophet.
Regarding the question of hierarchical problems I recently came across this page regarding using pystan for hierarchical/multilevel modeling. I know prophet utilizes stan so perhaps this can provide some ideas? Not entirely sure as Bayesian analysis is not my primary strength.
from prophet.
Hierarchy of time series
It would be interesting to provide an example of modeling time series hierarchy in prophet.
from prophet.
Hi! I was just wondering if this is being worked on as of 2021, I would love to check the code if possible, thanks a lot for this awesome tool!
from prophet.
Yes thank you, in fact they are working on it! ourownstory/neural_prophet#235
from prophet.
Related Issues (20)
- Python3 setuptools error
- ImportError: cannot import name 'main' from 'cmdstanpy.install_cxx_toolchain' HOT 1
- Cross validation creating error when y data ends before cutoff end + horizon - appeared after update from 0.7.1 to 1.1.5
- forecaster.preprocess() may introduce unwanted behavior for NaN history values in 1.1.5 HOT 2
- How to set up an error term to follow Student t-distribution?
- Adding 2 predictions with their respective confidence intervals
- Time zone issue when fitting prophet in R HOT 1
- Minimum Supported Python version is 3.8, not 3.7
- Fitting hangs in Prophet 1.1.5
- weired x label in model.plot_components(forecast)
- ries
- Hierarchical Model
- Model fit behaves very differently between `datetime64[ns]` and `datetime64[ms]`.
- Amplifying the amplitude of seasonality
- regressor_coefficients not finding regr_names HOT 1
- sample_model() not loading
- Forecast is off by 1
- Prophet Optimization error HOT 4
- Can't seem to forecast values correctly for future dates (few values are coming zero and few are not matching the historical pattern)
- Facebook Prophet ignores manually passed changepoints
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prophet.