Summarise the out-of-sample stocks forecasts by asset and time periods.
get_metrics(.tbl, .group, .truth, .forecast)
.tbl | A |
---|---|
.group | The column in which the data should be grouped. This will often be a column with stock tickers or stocks names. |
.truth | The truth results of a time series realization. |
.forecast | The out-of-sample forecasts from the chosen model. |
A tibble
with the following summary statistics by asset: mse, rmse, mae, mape and mase.
library(YahooTickers) library(dplyr) library(forecast) get_tickers(dow) %>% slice(2:3) %>% get_stocks(., periodicity = "monthly") %>% get_returns(., tickers, log, TRUE, adjusted) %>% get_models(., tickers, adjusted, 100, 1, FALSE, auto.arima, seasonal = FALSE, stationary = TRUE) %>% get_forecasts(.) %>% get_metrics(., tickers, adjusted, point_forecast) #> # A tibble: 2 × 6 #> tickers mse rmse mae mape mase #> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 AXP 0.00677 0.0823 0.0539 NaN 0.177 #> 2 AMGN 0.00447 0.0669 0.0524 94.4 0.161