random_walk_forc: Random walk forecast

Description Usage Arguments Value See Also Examples

View source: R/random_walk_forc.R

Description

random_walk_forc takes a vector of realized values, an integer number of periods ahead to forecast, and an optional vector of time data associated with the realized values. In each period, the current period value of the realized_vec series is set as the h_ahead period ahead forecast. Returns a random walk forecast where the h_ahead period ahead forecast is simply the present value of the series being forecasted.

Usage

1
random_walk_forc(realized_vec, h_ahead, time_vec = NULL)

Arguments

realized_vec

Vector of realized values. This is the series that is being forecasted.

h_ahead

Integer representing the number of periods ahead that is being forecasted.

time_vec

Vector of any class that is equal in length to the realized_vec vector.

Value

Forecast object that contains the random walk forecast.

See Also

For a detailed example see the help vignette: vignette("lmForc", package = "lmForc")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
date <- as.Date(c("2010-03-31", "2010-06-30", "2010-09-30", "2010-12-31",
                  "2011-03-31", "2011-06-30", "2011-09-30", "2011-12-31", 
                  "2012-03-31", "2012-06-30"))
y  <- c(1.09, 1.71, 1.09, 2.46, 1.78, 1.35, 2.89, 2.11, 2.97, 0.99)
data <- data.frame(date, y)

random_walk_forc(
  realized_vec = data$y,
  h_ahead = 4L,
  time_vec = data$date 
)

lmForc documentation built on Jan. 4, 2022, 1:11 a.m.