#' @title Naive one-step ahead forecast
#' @description This model forecasts the next step ahead as the current value,
#' and is a baseline model for comparison against.
#'
#' @inheritParams hindcast
#'
#' @return a data.frame of the forecasts and the observed values
#'
#' @export
#'
naive_one_step <- function(timeseries, ...)
{
f <- function(training, observed = NA, level)
{
data.frame(observed = as.numeric(observed),
predicted = utils::tail(training, 1),
naive_error = mean(abs(utils::tail(training, -1) - utils::head(training, -1))))
}
hindcast(fun = f, timeseries = timeseries, ...)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.