Interpolation
Closed this issue · 4 comments
Hey Mitch.
At some point you have shown interpolation using Fable + Fasster.
I think in one of the updates we lost functionality (I don't see interpolate method in Fasster code nor in previous commits). Any chances of getting this to work again or workarounds?
library(tidyverse)
library(lubridate)
library(tsibble)
library(fable)
library(fasster)
elec <- tsibbledata::vic_elec %>%
filter(Time < ymd("2014-03-01")) %>%
mutate(WorkDay = ifelse(wday(Time, week_start = 1) > 5, 0, 1))
interpolation <- elec %>%
mutate(Demand = ifelse(Time >= ymd("2014-02-01") & Time < ymd("2014-02-14"), NA, Demand)) %>%
fasster(log(Demand) ~ WorkDay %S% (trig(48, 16) + poly(1))) %>%
interpolate()
Same problem, although I am not sure whether the method interpolate.fasster
is missing or that should be handled by interpolate.mdl_ts
from fabletools
package. @mitchelloharawild do you have an idea?
suppressWarnings(library(fabletools))
suppressWarnings(library(fable))
suppressWarnings(library(fasster))
suppressWarnings(library(tsibbledata))
fit_tslm <- olympic_running %>%
model(model = TSLM(Time ~ trend()))
fit_fasster <- olympic_running %>%
model(model = fasster(Time ~ trend()))
# work
fit_tslm %>%
interpolate(olympic_running)
#> # A tsibble: 312 x 4 [4Y]
#> # Key: Length, Sex [14]
#> Length Sex Year Time
#> <int> <chr> <int> <dbl>
#> 1 100 men 1896 12
#> 2 100 men 1900 11
#> 3 100 men 1904 11
#> 4 100 men 1908 10.8
#> 5 100 men 1912 10.8
#> 6 100 men 1916 10.8
#> 7 100 men 1920 10.8
#> 8 100 men 1924 10.6
#> 9 100 men 1928 10.8
#> 10 100 men 1932 10.3
#> # ... with 302 more rows
# does not work
fit_fasster %>%
interpolate(olympic_running)
#> Error: Problem with `mutate()` input `interpolated`.
#> x nicht anwendbare Methode für 'interpolate' auf Objekt der Klasse "FASSTER" angewendet
#> i Input `interpolated` is `map2(model, new_data, interpolate, ...)`.
# there is no interpolate.fasster method
methods(interpolate)
#> [1] interpolate.ARIMA* interpolate.mdl_df* interpolate.mdl_ts*
#> [4] interpolate.model_mean* interpolate.TSLM*
#> see '?methods' for accessing help and source code
Created on 2021-03-22 by the reprex package (v1.0.0)
An interpolate(<fasster>)
method is required for this to work. For the talk I had quickly included it as a proof of concept, but in the weeks after it was clear that this feature was better suited as a generic in {fabletools}
(c94d74f). Seemingly I didn't add the necessary method into fasster for this.
The initial interpolate()
method was simply used fitted values, however it would be better/nicer to use smoothed values instead.
Thanks for your reply. I guess same problem for fable.prophet
. Is that feature planned in the near future or do you know a work-around? I need to interpolate a multi-week gap in a district heating load (no forecast neccessary).
I've re-added an interpolate()
method that simply uses the fitted values like before. I hope to one day improve this by using smoothed values (a bit more computation, but much better results), but I expect this would take a while.