Skip to contents

This function mimics dplyr bind. It's useful if you have different ffp objects and want to stack them in the tidy (long) format.

Usage

bind_probs(...)

Arguments

...

ffp objects to combine.

Value

A tidy tibble.

The output adds two new columns:

  • rowid (an integer) with the row number of each realization;

  • key (a factor) that keeps track of the ffp inputs as separated objects.

Examples

library(ggplot2)
library(dplyr, warn.conflicts = FALSE)

x <- exp_decay(EuStockMarkets, lambda = 0.001)
y <- exp_decay(EuStockMarkets, lambda = 0.002)

bind_probs(x, y)
#> # A tibble: 3,720 × 3
#>    rowid        probs fn                                           
#>    <int>        <ffp> <fct>                                        
#>  1     1 0.0001844669 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  2     2 0.0001846515 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  3     3 0.0001848363 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  4     4 0.0001850212 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  5     5 0.0001852063 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  6     6 0.0001853916 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  7     7 0.0001855771 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  8     8 0.0001857627 exp_decay(x = EuStockMarkets, lambda = 0.001)
#>  9     9 0.0001859486 exp_decay(x = EuStockMarkets, lambda = 0.001)
#> 10    10 0.0001861346 exp_decay(x = EuStockMarkets, lambda = 0.001)
#> # … with 3,710 more rows

bind_probs(x, y) %>%
  ggplot(aes(x = rowid, y = probs, color = fn)) +
  geom_line() +
  scale_color_viridis_d() +
  theme(legend.position="bottom")
#> Don't know how to automatically pick scale for object of type ffp/vctrs_vctr. Defaulting to continuous.