"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/_docs/seasonality,_holiday_effects,_and_regressors.md" between
prophet-0.7.tar.gz and prophet-1.0.tar.gz

About: Prophet is a tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

seasonality,_holiday_effects,_and_regressors.md  (prophet-0.7):seasonality,_holiday_effects,_and_regressors.md  (prophet-1.0)
skipping to change at line 21 skipping to change at line 21
- title: Fourier Order for Seasonalities - title: Fourier Order for Seasonalities
id: fourier-order-for-seasonalities id: fourier-order-for-seasonalities
- title: Specifying Custom Seasonalities - title: Specifying Custom Seasonalities
id: specifying-custom-seasonalities id: specifying-custom-seasonalities
- title: Seasonalities that depend on other factors - title: Seasonalities that depend on other factors
id: seasonalities-that-depend-on-other-factors id: seasonalities-that-depend-on-other-factors
- title: Prior scale for holidays and seasonality - title: Prior scale for holidays and seasonality
id: prior-scale-for-holidays-and-seasonality id: prior-scale-for-holidays-and-seasonality
- title: Additional regressors - title: Additional regressors
id: additional-regressors id: additional-regressors
- title: Coefficients of additional regressors
id: coefficients-of-additional-regressors
--- ---
<a id="modeling-holidays-and-special-events"> </a> <a id="modeling-holidays-and-special-events"> </a>
### Modeling Holidays and Special Events ### Modeling Holidays and Special Events
If you have holidays or other recurring events that you'd like to model, you mus t create a dataframe for them. It has two columns (`holiday` and `ds`) and a row for each occurrence of the holiday. It must include all occurrences of the holi day, both in the past (back as far as the historical data go) and in the future (out as far as the forecast is being made). If they won't repeat in the future, Prophet will model them and then not include them in the forecast. If you have holidays or other recurring events that you'd like to model, you mus t create a dataframe for them. It has two columns (`holiday` and `ds`) and a row for each occurrence of the holiday. It must include all occurrences of the holi day, both in the past (back as far as the historical data go) and in the future (out as far as the forecast is being made). If they won't repeat in the future, Prophet will model them and then not include them in the forecast.
You can also include columns `lower_window` and `upper_window` which extend the holiday out to `[lower_window, upper_window]` days around the date. For instance , if you wanted to include Christmas Eve in addition to Christmas you'd include `lower_window=-1,upper_window=0`. If you wanted to use Black Friday in addition to Thanksgiving, you'd include `lower_window=0,upper_window=1`. You can also inc lude a column `prior_scale` to set the prior scale separately for each holiday, as described below. You can also include columns `lower_window` and `upper_window` which extend the holiday out to `[lower_window, upper_window]` days around the date. For instance , if you wanted to include Christmas Eve in addition to Christmas you'd include `lower_window=-1,upper_window=0`. If you wanted to use Black Friday in addition to Thanksgiving, you'd include `lower_window=0,upper_window=1`. You can also inc lude a column `prior_scale` to set the prior scale separately for each holiday, as described below.
Here we create a dataframe that includes the dates of all of Peyton Manning's pl ayoff appearances: Here we create a dataframe that includes the dates of all of Peyton Manning's pl ayoff appearances:
skipping to change at line 129 skipping to change at line 131
<th></th> <th></th>
<th>ds</th> <th>ds</th>
<th>playoff</th> <th>playoff</th>
<th>superbowl</th> <th>superbowl</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th>2190</th> <th>2190</th>
<td>2014-02-02</td> <td>2014-02-02</td>
<td>1.217571</td> <td>1.223965</td>
<td>1.230312</td> <td>1.201517</td>
</tr> </tr>
<tr> <tr>
<th>2191</th> <th>2191</th>
<td>2014-02-03</td> <td>2014-02-03</td>
<td>1.898042</td> <td>1.901742</td>
<td>1.466063</td> <td>1.460471</td>
</tr> </tr>
<tr> <tr>
<th>2532</th> <th>2532</th>
<td>2015-01-11</td> <td>2015-01-11</td>
<td>1.217571</td> <td>1.223965</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2533</th> <th>2533</th>
<td>2015-01-12</td> <td>2015-01-12</td>
<td>1.898042</td> <td>1.901742</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2901</th> <th>2901</th>
<td>2016-01-17</td> <td>2016-01-17</td>
<td>1.217571</td> <td>1.223965</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2902</th> <th>2902</th>
<td>2016-01-18</td> <td>2016-01-18</td>
<td>1.898042</td> <td>1.901742</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2908</th> <th>2908</th>
<td>2016-01-24</td> <td>2016-01-24</td>
<td>1.217571</td> <td>1.223965</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2909</th> <th>2909</th>
<td>2016-01-25</td> <td>2016-01-25</td>
<td>1.898042</td> <td>1.901742</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2922</th> <th>2922</th>
<td>2016-02-07</td> <td>2016-02-07</td>
<td>1.217571</td> <td>1.223965</td>
<td>1.230312</td> <td>1.201517</td>
</tr> </tr>
<tr> <tr>
<th>2923</th> <th>2923</th>
<td>2016-02-08</td> <td>2016-02-08</td>
<td>1.898042</td> <td>1.901742</td>
<td>1.466063</td> <td>1.460471</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
The holiday effects will also show up in the components plot, where we see that there is a spike on the days around playoff appearances, with an especially larg e spike for the superbowl: The holiday effects will also show up in the components plot, where we see that there is a spike on the days around playoff appearances, with an especially larg e spike for the superbowl:
```R ```R
# R # R
prophet_plot_components(m, forecast) prophet_plot_components(m, forecast)
``` ```
```python ```python
# Python # Python
fig = m.plot_components(forecast) fig = m.plot_components(forecast)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_13_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_14_0.png)
Individual holidays can be plotted using the `plot_forecast_component` function (imported from `fbprophet.plot` in Python) like `plot_forecast_component(m, fore cast, 'superbowl')` to plot just the superbowl holiday component. Individual holidays can be plotted using the `plot_forecast_component` function (imported from `prophet.plot` in Python) like `plot_forecast_component(m, foreca st, 'superbowl')` to plot just the superbowl holiday component.
<a id="built-in-country-holidays"> </a> <a id="built-in-country-holidays"> </a>
### Built-in Country Holidays ### Built-in Country Holidays
You can use a built-in collection of country-specific holidays using the `add_co untry_holidays` method (Python) or function (R). The name of the country is spec ified, and then major holidays for that country will be included in addition to any holidays that are specified via the `holidays` argument described above: You can use a built-in collection of country-specific holidays using the `add_co untry_holidays` method (Python) or function (R). The name of the country is spec ified, and then major holidays for that country will be included in addition to any holidays that are specified via the `holidays` argument described above:
```R ```R
# R # R
m <- prophet(holidays = holidays) m <- prophet(holidays = holidays)
skipping to change at line 229 skipping to change at line 231
m = Prophet(holidays=holidays) m = Prophet(holidays=holidays)
m.add_country_holidays(country_name='US') m.add_country_holidays(country_name='US')
m.fit(df) m.fit(df)
``` ```
You can see which holidays were included by looking at the `train_holiday_names` (Python) or `train.holiday.names` (R) attribute of the model: You can see which holidays were included by looking at the `train_holiday_names` (Python) or `train.holiday.names` (R) attribute of the model:
```R ```R
# R # R
m$train.holiday.names m$train.holiday.names
``` ```
[1] "playoff" "superbowl" [1] "playoff" "superbowl"
[3] "New Year's Day" "Martin Luther King, Jr. Day" [3] "New Year's Day" "Martin Luther King Jr. Day"
[5] "Washington's Birthday" "Memorial Day" [5] "Washington's Birthday" "Memorial Day"
[7] "Independence Day" "Labor Day" [7] "Independence Day" "Labor Day"
[9] "Columbus Day" "Veterans Day" [9] "Columbus Day" "Veterans Day"
[11] "Veterans Day (Observed)" "Thanksgiving" [11] "Veterans Day (Observed)" "Thanksgiving"
[13] "Christmas Day" "Independence Day (Observed)" [13] "Christmas Day" "Independence Day (Observed)"
[15] "Christmas Day (Observed)" "New Year's Day (Observed)" [15] "Christmas Day (Observed)" "New Year's Day (Observed)"
```python ```python
# Python # Python
m.train_holiday_names m.train_holiday_names
``` ```
0 playoff 0 playoff
1 superbowl 1 superbowl
2 New Year's Day 2 New Year's Day
3 Martin Luther King, Jr. Day 3 Martin Luther King Jr. Day
4 Washington's Birthday 4 Washington's Birthday
5 Memorial Day 5 Memorial Day
6 Independence Day 6 Independence Day
7 Labor Day 7 Labor Day
8 Columbus Day 8 Columbus Day
9 Veterans Day 9 Veterans Day
10 Thanksgiving 10 Thanksgiving
11 Christmas Day 11 Christmas Day
12 Christmas Day (Observed) 12 Christmas Day (Observed)
13 Veterans Day (Observed) 13 Veterans Day (Observed)
skipping to change at line 279 skipping to change at line 280
# R # R
forecast <- predict(m, future) forecast <- predict(m, future)
prophet_plot_components(m, forecast) prophet_plot_components(m, forecast)
``` ```
```python ```python
# Python # Python
forecast = m.predict(future) forecast = m.predict(future)
fig = m.plot_components(forecast) fig = m.plot_components(forecast)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_23_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_24_0.png)
<a id="fourier-order-for-seasonalities"> </a> <a id="fourier-order-for-seasonalities"> </a>
### Fourier Order for Seasonalities ### Fourier Order for Seasonalities
Seasonalities are estimated using a partial Fourier sum. See [the paper](https:/ /peerj.com/preprints/3190/) for complete details, and [this figure on Wikipedia] (https://en.wikipedia.org/wiki/Fourier_series#/media/File:Fourier_Series.svg) fo r an illustration of how a partial Fourier sum can approximate an aribtrary peri odic signal. The number of terms in the partial sum (the order) is a parameter t hat determines how quickly the seasonality can change. To illustrate this, consi der the Peyton Manning data from the [Quickstart](https://facebook.github.io/pro phet/docs/quick_start.html). The default Fourier order for yearly seasonality is 10, which produces this fit: Seasonalities are estimated using a partial Fourier sum. See [the paper](https:/ /peerj.com/preprints/3190/) for complete details, and [this figure on Wikipedia] (https://en.wikipedia.org/wiki/Fourier_series#/media/File:Fourier_Series.svg) fo r an illustration of how a partial Fourier sum can approximate an arbitrary peri odic signal. The number of terms in the partial sum (the order) is a parameter t hat determines how quickly the seasonality can change. To illustrate this, consi der the Peyton Manning data from the [Quickstart](https://facebook.github.io/pro phet/docs/quick_start.html). The default Fourier order for yearly seasonality is 10, which produces this fit:
```R ```R
# R # R
m <- prophet(df) m <- prophet(df)
prophet:::plot_yearly(m) prophet:::plot_yearly(m)
``` ```
```python ```python
# Python # Python
from fbprophet.plot import plot_yearly from prophet.plot import plot_yearly
m = Prophet().fit(df) m = Prophet().fit(df)
a = plot_yearly(m) a = plot_yearly(m)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_26_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_27_0.png)
The default values are often appropriate, but they can be increased when the sea sonality needs to fit higher-frequency changes, and generally be less smooth. Th e Fourier order can be specified for each built-in seasonality when instantiatin g the model, here it is increased to 20: The default values are often appropriate, but they can be increased when the sea sonality needs to fit higher-frequency changes, and generally be less smooth. Th e Fourier order can be specified for each built-in seasonality when instantiatin g the model, here it is increased to 20:
```R ```R
# R # R
m <- prophet(df, yearly.seasonality = 20) m <- prophet(df, yearly.seasonality = 20)
prophet:::plot_yearly(m) prophet:::plot_yearly(m)
``` ```
```python ```python
# Python # Python
from fbprophet.plot import plot_yearly from prophet.plot import plot_yearly
m = Prophet(yearly_seasonality=20).fit(df) m = Prophet(yearly_seasonality=20).fit(df)
a = plot_yearly(m) a = plot_yearly(m)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_29_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_30_0.png)
Increasing the number of Fourier terms allows the seasonality to fit faster chan ging cycles, but can also lead to overfitting: N Fourier terms corresponds to 2N variables used for modeling the cycle Increasing the number of Fourier terms allows the seasonality to fit faster chan ging cycles, but can also lead to overfitting: N Fourier terms corresponds to 2N variables used for modeling the cycle
<a id="specifying-custom-seasonalities"> </a> <a id="specifying-custom-seasonalities"> </a>
### Specifying Custom Seasonalities ### Specifying Custom Seasonalities
Prophet will by default fit weekly and yearly seasonalities, if the time series is more than two cycles long. It will also fit daily seasonality for a sub-daily time series. You can add other seasonalities (monthly, quarterly, hourly) using the `add_seasonality` method (Python) or function (R). Prophet will by default fit weekly and yearly seasonalities, if the time series is more than two cycles long. It will also fit daily seasonality for a sub-daily time series. You can add other seasonalities (monthly, quarterly, hourly) using the `add_seasonality` method (Python) or function (R).
The inputs to this function are a name, the period of the seasonality in days, a nd the Fourier order for the seasonality. For reference, by default Prophet uses a Fourier order of 3 for weekly seasonality and 10 for yearly seasonality. An o ptional input to `add_seasonality` is the prior scale for that seasonal componen t - this is discussed below. The inputs to this function are a name, the period of the seasonality in days, a nd the Fourier order for the seasonality. For reference, by default Prophet uses a Fourier order of 3 for weekly seasonality and 10 for yearly seasonality. An o ptional input to `add_seasonality` is the prior scale for that seasonal componen t - this is discussed below.
skipping to change at line 345 skipping to change at line 346
prophet_plot_components(m, forecast) prophet_plot_components(m, forecast)
``` ```
```python ```python
# Python # Python
m = Prophet(weekly_seasonality=False) m = Prophet(weekly_seasonality=False)
m.add_seasonality(name='monthly', period=30.5, fourier_order=5) m.add_seasonality(name='monthly', period=30.5, fourier_order=5)
forecast = m.fit(df).predict(future) forecast = m.fit(df).predict(future)
fig = m.plot_components(forecast) fig = m.plot_components(forecast)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_32_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_33_0.png)
<a id="seasonalities-that-depend-on-other-factors"> </a> <a id="seasonalities-that-depend-on-other-factors"> </a>
### Seasonalities that depend on other factors ### Seasonalities that depend on other factors
In some instances the seasonality may depend on other factors, such as a weekly seasonal pattern that is different during the summer than it is during the rest of the year, or a daily seasonal pattern that is different on weekends vs. on we ekdays. These types of seasonalities can be modeled using conditional seasonalit ies. In some instances the seasonality may depend on other factors, such as a weekly seasonal pattern that is different during the summer than it is during the rest of the year, or a daily seasonal pattern that is different on weekends vs. on we ekdays. These types of seasonalities can be modeled using conditional seasonalit ies.
Consider the Peyton Manning example from the [Quickstart](https://facebook.githu b.io/prophet/docs/quick_start.html). The default weekly seasonality assumes that the pattern of weekly seasonality is the same throughout the year, but we'd exp ect the pattern of weekly seasonality to be different during the on-season (when there are games every Sunday) and the off-season. We can use conditional season alities to construct separate on-season and off-season weekly seasonalities. Consider the Peyton Manning example from the [Quickstart](https://facebook.githu b.io/prophet/docs/quick_start.html). The default weekly seasonality assumes that the pattern of weekly seasonality is the same throughout the year, but we'd exp ect the pattern of weekly seasonality to be different during the on-season (when there are games every Sunday) and the off-season. We can use conditional season alities to construct separate on-season and off-season weekly seasonalities.
First we add a boolean column to the dataframe that indicates whether each date is during the on-season or the off-season: First we add a boolean column to the dataframe that indicates whether each date is during the on-season or the off-season:
skipping to change at line 402 skipping to change at line 403
m = Prophet(weekly_seasonality=False) m = Prophet(weekly_seasonality=False)
m.add_seasonality(name='weekly_on_season', period=7, fourier_order=3, condition_ name='on_season') m.add_seasonality(name='weekly_on_season', period=7, fourier_order=3, condition_ name='on_season')
m.add_seasonality(name='weekly_off_season', period=7, fourier_order=3, condition _name='off_season') m.add_seasonality(name='weekly_off_season', period=7, fourier_order=3, condition _name='off_season')
future['on_season'] = future['ds'].apply(is_nfl_season) future['on_season'] = future['ds'].apply(is_nfl_season)
future['off_season'] = ~future['ds'].apply(is_nfl_season) future['off_season'] = ~future['ds'].apply(is_nfl_season)
forecast = m.fit(df).predict(future) forecast = m.fit(df).predict(future)
fig = m.plot_components(forecast) fig = m.plot_components(forecast)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_38_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_39_0.png)
Both of the seasonalities now show up in the components plots above. We can see that during the on-season when games are played every Sunday, there are large in creases on Sunday and Monday that are completely absent during the off-season. Both of the seasonalities now show up in the components plots above. We can see that during the on-season when games are played every Sunday, there are large in creases on Sunday and Monday that are completely absent during the off-season.
<a id="prior-scale-for-holidays-and-seasonality"> </a> <a id="prior-scale-for-holidays-and-seasonality"> </a>
### Prior scale for holidays and seasonality ### Prior scale for holidays and seasonality
If you find that the holidays are overfitting, you can adjust their prior scale to smooth them using the parameter `holidays_prior_scale`. By default this param eter is 10, which provides very little regularization. Reducing this parameter d ampens holiday effects: If you find that the holidays are overfitting, you can adjust their prior scale to smooth them using the parameter `holidays_prior_scale`. By default this param eter is 10, which provides very little regularization. Reducing this parameter d ampens holiday effects:
```R ```R
skipping to change at line 456 skipping to change at line 457
<th></th> <th></th>
<th>ds</th> <th>ds</th>
<th>playoff</th> <th>playoff</th>
<th>superbowl</th> <th>superbowl</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th>2190</th> <th>2190</th>
<td>2014-02-02</td> <td>2014-02-02</td>
<td>1.205344</td> <td>1.206086</td>
<td>0.963327</td> <td>0.964914</td>
</tr> </tr>
<tr> <tr>
<th>2191</th> <th>2191</th>
<td>2014-02-03</td> <td>2014-02-03</td>
<td>1.851992</td> <td>1.852077</td>
<td>0.991010</td> <td>0.992634</td>
</tr> </tr>
<tr> <tr>
<th>2532</th> <th>2532</th>
<td>2015-01-11</td> <td>2015-01-11</td>
<td>1.205344</td> <td>1.206086</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2533</th> <th>2533</th>
<td>2015-01-12</td> <td>2015-01-12</td>
<td>1.851992</td> <td>1.852077</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2901</th> <th>2901</th>
<td>2016-01-17</td> <td>2016-01-17</td>
<td>1.205344</td> <td>1.206086</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2902</th> <th>2902</th>
<td>2016-01-18</td> <td>2016-01-18</td>
<td>1.851992</td> <td>1.852077</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2908</th> <th>2908</th>
<td>2016-01-24</td> <td>2016-01-24</td>
<td>1.205344</td> <td>1.206086</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2909</th> <th>2909</th>
<td>2016-01-25</td> <td>2016-01-25</td>
<td>1.851992</td> <td>1.852077</td>
<td>0.000000</td> <td>0.000000</td>
</tr> </tr>
<tr> <tr>
<th>2922</th> <th>2922</th>
<td>2016-02-07</td> <td>2016-02-07</td>
<td>1.205344</td> <td>1.206086</td>
<td>0.963327</td> <td>0.964914</td>
</tr> </tr>
<tr> <tr>
<th>2923</th> <th>2923</th>
<td>2016-02-08</td> <td>2016-02-08</td>
<td>1.851992</td> <td>1.852077</td>
<td>0.991010</td> <td>0.992634</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
The magnitude of the holiday effect has been reduced compared to before, especia lly for superbowls, which had the fewest observations. There is a parameter `sea sonality_prior_scale` which similarly adjusts the extent to which the seasonalit y model will fit the data. The magnitude of the holiday effect has been reduced compared to before, especia lly for superbowls, which had the fewest observations. There is a parameter `sea sonality_prior_scale` which similarly adjusts the extent to which the seasonalit y model will fit the data.
Prior scales can be set separately for individual holidays by including a column `prior_scale` in the holidays dataframe. Prior scales for individual seasonalit ies can be passed as an argument to `add_seasonality`. For instance, the prior s cale for just weekly seasonality can be set using: Prior scales can be set separately for individual holidays by including a column `prior_scale` in the holidays dataframe. Prior scales for individual seasonalit ies can be passed as an argument to `add_seasonality`. For instance, the prior s cale for just weekly seasonality can be set using:
```R ```R
skipping to change at line 578 skipping to change at line 579
m = Prophet() m = Prophet()
m.add_regressor('nfl_sunday') m.add_regressor('nfl_sunday')
m.fit(df) m.fit(df)
future['nfl_sunday'] = future['ds'].apply(nfl_sunday) future['nfl_sunday'] = future['ds'].apply(nfl_sunday)
forecast = m.predict(future) forecast = m.predict(future)
fig = m.plot_components(forecast) fig = m.plot_components(forecast)
``` ```
![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_48_0.png) ![png](/prophet/static/seasonality,_holiday_effects,_and_regressors_files/season ality,_holiday_effects,_and_regressors_49_0.png)
NFL Sundays could also have been handled using the "holidays" interface describe d above, by creating a list of past and future NFL Sundays. The `add_regressor` function provides a more general interface for defining extra linear regressors, and in particular does not require that the regressor be a binary indicator. An other time series could be used as a regressor, although its future values would have to be known. NFL Sundays could also have been handled using the "holidays" interface describe d above, by creating a list of past and future NFL Sundays. The `add_regressor` function provides a more general interface for defining extra linear regressors, and in particular does not require that the regressor be a binary indicator. An other time series could be used as a regressor, although its future values would have to be known.
[This notebook](https://nbviewer.jupyter.org/github/nicolasfauchereau/Auckland_C ycling/blob/master/notebooks/Auckland_cycling_and_weather.ipynb) shows an exampl e of using weather factors as extra regressors in a forecast of bicycle usage, a nd provides an excellent illustration of how other time series can be included a s extra regressors. [This notebook](https://nbviewer.jupyter.org/github/nicolasfauchereau/Auckland_C ycling/blob/master/notebooks/Auckland_cycling_and_weather.ipynb) shows an exampl e of using weather factors as extra regressors in a forecast of bicycle usage, a nd provides an excellent illustration of how other time series can be included a s extra regressors.
The `add_regressor` function has optional arguments for specifying the prior sca le (holiday prior scale is used by default) and whether or not the regressor is standardized - see the docstring with `help(Prophet.add_regressor)` in Python an d `?add_regressor` in R. Note that regressors must be added prior to model fitti ng. Prophet will also raise an error if the regressor is constant throughout the history, since there is nothing to fit from it. The `add_regressor` function has optional arguments for specifying the prior sca le (holiday prior scale is used by default) and whether or not the regressor is standardized - see the docstring with `help(Prophet.add_regressor)` in Python an d `?add_regressor` in R. Note that regressors must be added prior to model fitti ng. Prophet will also raise an error if the regressor is constant throughout the history, since there is nothing to fit from it.
The extra regressor must be known for both the history and for future dates. It thus must either be something that has known future values (such as `nfl_sunday` ), or something that has separately been forecasted elsewhere. The weather regre ssors used in the notebook linked above is a good example of an extra regressor that has forecasts that can be used for future values. One can also use as a reg ressor another time series that has been forecasted with a time series model, su ch as Prophet. For instance, if `r(t)` is included as a regressor for `y(t)`, Pr ophet can be used to forecast `r(t)` and then that forecast can be plugged in as the future values when forecasting `y(t)`. A note of caution around this approa ch: This will probably not be useful unless `r(t)` is somehow easier to forecast then `y(t)`. This is because error in the forecast of `r(t)` will produce error in the forecast of `y(t)`. One setting where this can be useful is in hierarchi cal time series, where there is top-level forecast that has higher signal-to-noi se and is thus easier to forecast. Its forecast can be included in the forecast for each lower-level series. The extra regressor must be known for both the history and for future dates. It thus must either be something that has known future values (such as `nfl_sunday` ), or something that has separately been forecasted elsewhere. The weather regre ssors used in the notebook linked above is a good example of an extra regressor that has forecasts that can be used for future values. One can also use as a reg ressor another time series that has been forecasted with a time series model, su ch as Prophet. For instance, if `r(t)` is included as a regressor for `y(t)`, Pr ophet can be used to forecast `r(t)` and then that forecast can be plugged in as the future values when forecasting `y(t)`. A note of caution around this approa ch: This will probably not be useful unless `r(t)` is somehow easier to forecast then `y(t)`. This is because error in the forecast of `r(t)` will produce error in the forecast of `y(t)`. One setting where this can be useful is in hierarchi cal time series, where there is top-level forecast that has higher signal-to-noi se and is thus easier to forecast. Its forecast can be included in the forecast for each lower-level series.
Extra regressors are put in the linear component of the model, so the underlying model is that the time series depends on the extra regressor as either an addit ive or multiplicative factor (see the next section for multiplicativity). Extra regressors are put in the linear component of the model, so the underlying model is that the time series depends on the extra regressor as either an addit ive or multiplicative factor (see the next section for multiplicativity).
<a id="coefficients-of-additional-regressors"> </a>
#### Coefficients of additional regressors
To extract the beta coefficients of the extra regressors, use the utility functi
on `regressor_coefficients` (`from prophet.utilities import regressor_coefficien
ts` in Python, `prophet::regressor_coefficients` in R) on the fitted model. The
estimated beta coefficient for each regressor roughly represents the increase in
prediction value for a unit increase in the regressor value (note that the coef
ficients returned are always on the scale of the original data). If `mcmc_sample
s` is specified, a credible interval for each coefficient is also returned, whic
h can help identify whether each regressor is "statistically significant".
 End of changes. 36 change blocks. 
42 lines changed or deleted 43 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)