Description Usage Arguments Examples
A simple roll function, "rolling the window" across a series of data, applying a function, to produce a vector of results
1 |
x |
a vector passed into |
.f |
a function or formula If a function, it is used as is. If a formula, e.g. |
... |
further arguments to pass .f |
width |
the width of the window |
extend |
extend the window as it rolls (logical) |
1 2 3 4 5 6 7 8 9 10 11 | # Simulate 4 years of daily returns
x <- rnorm(1000)
# compute the historical var across a window of a year
roll(x, var_historical, conf = 0.8, width = 250)
Really the decision lies with:
if kept simple, we map(df, ~ roll(~ .f(.x)))
but this means we cannot use roll to compute
functions that require interactions like cov(x,y)
That seems like the best way to deal with dataframes
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.