Forecasting and back transformation with TSLM
14:14 19 Apr 2026

I have this data set (from https://fable.tidyverts.org/index.html)

library(fpp3)

 google_stock <- gafa_stock |>
  filter(Symbol == "GOOG", year(Date) >= 2015) |>
  mutate(day = row_number()) |>
  update_tsibble(index = day, regular = TRUE)

google_2015 <- google_stock |> filter(year(Date) == 2015)

# A tsibble: 252 x 9 [1]
# Key:       Symbol [1]
   Symbol Date        Open  High   Low Close Adj_Close  Volume   day
                      
 1 GOOG   2015-01-02  526.  528.  521.  522.      522. 1447600     1
 2 GOOG   2015-01-05  520.  521.  510.  511.      511. 2059800     2
 3 GOOG   2015-01-06  512.  513.  498.  499.      499. 2899900     3
 4 GOOG   2015-01-07  504.  504.  497.  498.      498. 2065100     4
 5 GOOG   2015-01-08  495.  501.  488.  500.      500. 3353600     5
 6 GOOG   2015-01-09  502.  502.  492.  493.      493. 2069400     6
 7 GOOG   2015-01-12  492.  493.  485.  490.      490. 2322400     7
 8 GOOG   2015-01-13  496.  500.  490.  493.      493. 2370500     8
 9 GOOG   2015-01-14  492.  500.  490.  498.      498. 2235700     9
10 GOOG   2015-01-15  503.  503.  495.  499.      499. 2715800    10
# ℹ 242 more rows

Additional data management to be used in forecasting with a time series linear model (TSLM):

df<-google_2015 %>%  
 mutate(lopen=log(Open), dl0pen= difference(log(Open),1), pct = log(High/ dplyr::lag(High)))  %>%
as_tsibble(index=Date)


fit <- df %>% filter(Date< "2015-12-23")  |>  model(TSLM(dl0pen ~ pct)) 
report(fit)

us_change_future <- new_data(df%>% filter(Date< "2015-12-23") , 6) |>
  mutate(df%>% filter(Date>= "2015-12-23")  %>% select(  pct)  %>%
 as.data.frame() %>% select(-Date)
)

Forecasting:

xd<-fit %>% forecast::forecast( us_change_future)

How can we obtain the values of the forecast variable in levels, that is, of the variable Open?

r forecasting fable-r