mitchelloharawild/fable.prophet

Cannot use `xreg()` special

davidtedfordholt opened this issue · 6 comments

The xreg special can be called implicitly using a variable name, but cannot be called explicitly. Because of this, the additional arguments for xreg (type, prior_scale and standardize) are unavailable, as best I can tell.

I only discovered this because I can't get it to work in fable.bsts. I'm not sure if this is about the specific implementation in fable.prophet or the general implementation in fabletools.

library(tsibbledata)
library(tsibble)
library(fable.prophet)
library(dplyr)

data <- vic_elec %>%
    index_by(Date) %>%
    summarise(Demand = sum(Demand), Temperature = mean(Temperature))

model(data, prophet = prophet(Demand ~ Temperature))
model(data, prophet = prophet(Demand ~ xreg(Temperature, prior_scale = .1)))

I can confirm that this was not working as it should in fable.prophet, and that it should work as you expect now (tidyverts/fabletools@8b93a03). This change will be included in the next release.

Thank you! If the next release will be a little bit, I'll go ahead and work on fable.bsts using a github-installed fabletools.

The next release will coincide with the release of dplyr 1.0.0, so ~1-2 months.
I recommend pulling from the fabletools@xreg branch which is closest to the CRAN version (with only this fix).

Will do, and thanks again. If you need help at any point with the extension vignette, @bradisbrad and I are happy to help. If we get to a point where we can do it, anyone can.

Closing as this has been fixed in the latest {fabletools} CRAN release.

library(tsibbledata)
#> Warning: package 'tsibbledata' was built under R version 3.6.3
library(tsibble)
library(fable.prophet)
#> Loading required package: Rcpp
#> Loading required package: fabletools
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

data <- vic_elec %>%
  index_by(Date) %>%
  summarise(Demand = sum(Demand), Temperature = mean(Temperature))

model(data, prophet = prophet(Demand ~ Temperature))
#> # A mable: 1 x 1
#>     prophet
#>     <model>
#> 1 <prophet>
model(data, prophet = prophet(Demand ~ xreg(Temperature, prior_scale = .1)))
#> # A mable: 1 x 1
#>     prophet
#>     <model>
#> 1 <prophet>

Created on 2020-07-16 by the reprex package (v0.3.0)