plot_paths: Plot a few forecast sample paths of a 'tulip' model

View source: R/autoplot.R

plot_pathsR Documentation

Plot a few forecast sample paths of a tulip model

Description

This function requires the ggplot2. Whether its namespace is available will be checked when the function is run. ggplot2 is only suggested, not a default import.

Usage

plot_paths(object, date = NULL, date_future = NULL, n = 5, alpha = 0.75)

Arguments

object

An object of class tulip_paths as returned by predict.tulip()

date

Optional additional vector with dates in format that can be cast to YYYY-MM-DD with same length as object$y, used to create x-axis

date_future

Optional additional vector with dates in format that can be cast to YYYY-MM-DD with same length as object$y, used to create x-axis for forecast paths

n

Number of paths to add to plot, a small number is recommended to be able to see the individual paths; scalar integer between 1 and 10

alpha

The transparency parameter used when adding the paths to the plot, provided to ggplot2::geom_point() and ggplot2::geom_line()

Details

Note: This function will use base::sample() to randomly select paths that are added to the plot. Set a seed if you require reproducibility.

Examples

set.seed(4278)
y <- rt(100, df = 10) * 10 + 1:100

fitted <- tulip(y = y, m = 12, family = "norm")
paths <- predict(object = fitted, h = 12)

tulip:::plot_paths(object = paths, n = 3)


timradtke/heuristika documentation built on April 24, 2023, 1:55 a.m.