ts_random_walk_plot: Auto-Plot a Random Walk

View source: R/ts-random-walk-plot.R

ts_random_walk_plotR Documentation

Auto-Plot a Random Walk

Description

Plot a random walk with side-by-side facets showing both the random variable and cumulative product (random walk path).

Usage

ts_random_walk_plot(.data, .interactive = FALSE)

Arguments

.data

The data from ts_random_walk() function.

.interactive

The default is FALSE, TRUE will produce an interactive plotly plot.

Details

This function will take output from the ts_random_walk() function and create a side-by-side faceted plot. The left panel shows the random variable (y) over time, and the right panel shows the cumulative product (cum_y, i.e., the random walk path) over time. Each simulation run is shown as a separate line. The legend is set to "none" if the simulation count is higher than 9.

Value

A ggplot2 object or an interactive plotly plot

Author(s)

Steven P. Sanderson II, MPH

See Also

Other Plot: ts_brownian_motion_plot(), ts_event_analysis_plot(), ts_qq_plot(), ts_scedacity_scatter_plot()

Examples


df <- ts_random_walk(
  .mean = 0,
  .sd = 1,
  .num_walks = 25,
  .periods = 180,
  .initial_value = 100
)

ts_random_walk_plot(df)


healthyR.ts documentation built on Jan. 24, 2026, 1:08 a.m.