rforecastinggammultivariate-testing

Adding Independent Variables to Prophet Package


There is an R package called prophet which is very good. It is a generalized additive model. The dependent variable is the the metric you are trying to solve and the independent variables are: the growth function, seasonality function, and a variable that will account for things not found in those two variables. I want to be able to add another independent variable. For example:

Let's say I want to solve for Page Views. I have the past nine years worth of data and in this package it will take the seasonality and growth rate into account to solve for this. How would I include another independent variable such as "Temperature"?

This is what the equation looks like behind the scenes:

Page_Views = g(t) + s(t) + e(t)

I want to add another variable:

Page_Views = g(t) + s(t) + Beta(Temperature) + e(t)

How would I do this in the prophet package?

Here is a tutorial on how to use the package: https://cran.r-project.org/web/packages/prophet/vignettes/quick_start.html

Data is found here: https://github.com/facebookincubator/prophet/blob/master/examples/example_wp_peyton_manning.csv

library(prophet)
m<-prophet(df)
future <- make_future_dataframe(m, period = 365)
forecast <- prophet:::predict.prophet(m, future)
plot(m, forecast)

The main question I want to know is: "Is there a way to add an additional independent variable to my generalized additive model in the prophet package?

Thanks, any help would be great!


Solution

  • Currently library developers have added an add_regressor function, which models external regressors in the linear part of the model. See the documentation.