Hello all,
I tried to initate a forecast in working with tsibbles and the fable package. My forecast result is sadly not very good, and I wanted to make sure that the reason for that is the problem with my stats and the data and not my R code. In hilo i see that the outpur is the same for every row of the value which makes me think that the model might be not working.
Data source: Ethereum Price | ETH Price Index and Live Chart — CoinDesk 20
library(feasts) # working with tsibbles
library(tsibble)
library(fable) #for tsibble flow eps and so on
library(tidyverse)
#library(dplyr) included tidyverse
#library(ggplot2) included tidyverse
library(lubridate) #date transformation package
library(magrittr) # advanced pipeing
library(sweep) #helps in working with ets objects for vizulasiation and transformation brings ts in tidyworkflow
csv_data_1 <- read.csv("ETH_USD_CoinDesk.csv")
z_eth <- mutate(csv_data_1, Currency = NULL, X24h.High..USD. = NULL, X24h.Low..USD.=NULL, X24h.Open..USD.=NULL) %>%
mutate(Date = yearmonth(Date)) %>% group_by(Date) %>% summarise(avgPM = mean(Closing.Price..USD.)) %>% as_tsibble(index = Date)
z_eth %>% #TSIBBLE
autoplot() +
labs(y = "Closing price", x="Date")
z_eth %>% gg_season(avgPM)
z_eth_deco <- z_eth %>% model(STL(avgPM)) #MABLE
z_eth_test <- z_eth %>% slice(1:floor(.75nrow(z_eth)))
z_eth_out <- z_eth %>% slice((floor(.75nrow(z_eth)):n()))
z_eth_deco %>%
gg_tsresiduals()
moreDat <- z_eth_deco %>% augment
moreDat %>% features(.innov, box_pierce, lag = 10, dof = 0)
moreDat %>% autoplot(.innov) + ylab("Residuals")
xDec <- z_eth %>% features(avgPM, feat_stl)
components(z_eth_deco) %>% as_tsibble() %>% autoplot(avgPM) +
geom_line(aes(y=trend), colour = "#D55E00") + #Why it shows seasonality if there is none.
geom_line(aes(y=remainder), colour = "blue") +
geom_line(aes(y=season_year), colour = "red")
ets_mod <- z_eth_test %>%
model(ets = ETS(avgPM ~ error("N") + trend("M") + season("N")))
ets_mod_auto <- z_eth_test %>%
model(ets = ETS(avgPM))
ets_mod_auto %>% report()
forecastLen <- length(z_eth_out$avgPM)
fc <- ets_mod_auto %>% forecast(h = forecastLen) #use namespace to not confuse with other packages ::
fc %>% autoplot()
fc %>%
hilo(level = c(80, 95))
fc %>% autoplot(z_eth_test)