Learn R Programming

healthyR.ts (version 0.3.2)

ts_random_walk_plot: 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)

Value

A ggplot2 object or an interactive plotly plot

Arguments

.data

The data from ts_random_walk() function.

.interactive

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

Author

Steven P. Sanderson II, MPH

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.

See Also

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

Examples

Run this code

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

ts_random_walk_plot(df)

Run the code above in your browser using DataLab