davidtedfordholt / fable.bsts

Implementation of the bsts package for use with the fable framework
8 stars 3 forks source link

BSTS doesn't seem to like yearmonth date format #19

Open bradisbrad opened 4 years ago

bradisbrad commented 4 years ago

Potential seasonal or date format issue

I think this may have to do with the seasonal special, but we're getting NULL models on yearmonth data when normal dates work. We're also seeing both return NULL models for a seasonal call of 1 month regardless of date format.

library(tidyverse)
library(fabletools)
library(fable)
devtools::install_github('bradisbrad/fable.bsts')
#> Skipping install of 'fable.bsts' from a github remote, the SHA1 (9b263921) has not changed since last install.
#>   Use `force = TRUE` to force installation

source('~/proj/pers/repo/fable.bsts/data-raw/lax_passengers.R')
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:tsibble':
#> 
#>     interval
#> The following objects are masked from 'package:base':
#> 
#>     date, intersect, setdiff, union
#> `summarise()` regrouping output by 'date' (override with `.groups` argument)

data <- lax_passengers %>% 
  mutate(date = yearmonth(date))

data %>% 
  fabletools::model(
    bsts = fable.bsts::BSTS(passengers ~ intercept() + ar() + seasonal('1 week'))
  )
#> Warning: 2 errors (1 unique) encountered for bsts
#> [2] order.by requires an appropriate time-based object
#> # A mable: 2 x 2
#> # Key:     type [2]
#>   type                  bsts
#>   <chr>              <model>
#> 1 Domestic      <NULL model>
#> 2 International <NULL model>

data <- lax_passengers 

data %>% 
  fabletools::model(
    bsts = fable.bsts::BSTS(passengers ~ intercept() + ar() + seasonal('1 week'))
  )
#> # A mable: 2 x 2
#> # Key:     type [2]
#>   type             bsts
#>   <chr>         <model>
#> 1 Domestic       <BSTS>
#> 2 International  <BSTS>

data %>% 
  fabletools::model(
    bsts = fable.bsts::BSTS(passengers ~ intercept() + ar() + seasonal('1 month'))
  )
#> Warning: 2 errors (1 unique) encountered for bsts
#> [2] nseasons == round(nseasons) is not TRUE
#> # A mable: 2 x 2
#> # Key:     type [2]
#>   type                  bsts
#>   <chr>              <model>
#> 1 Domestic      <NULL model>
#> 2 International <NULL model>

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

davidtedfordholt commented 4 years ago

Have you checked to see if it works in bsts proper?