Skip to contents

Constructs a tidy-resampling object for time-series data.

Usage

construct_rolling_infrastructure(
  .data,
  .initial = 252,
  .assess = 1,
  .cumulative = FALSE,
  ...
)

Arguments

.data

A tabular (non-tidy) tibble.

.initial

A integer. The number of samples used for analysis/modeling in the initial resample.

.assess

A integer. The number of samples used for each assessment resample.

.cumulative

A boolean. Should the analysis resample grow beyond the size specified by .initial at each resample?.

...

Additional arguments to be passed to rolling_origin.

Value

A tibble of the snoop_rolling class. Contains 3 columns: .date, .analysis and .assessment.

Examples

stocks <- tibble::tibble(
  time = as.Date('2009-01-01') + 0:99,
  X    = rnorm(100, 0, 1),
  Y    = rnorm(100, 0, 2),
  Z    = rnorm(100, 0, 4)
)

construct_rolling_infrastructure(stocks, .initial = 50)
#> # A tibble: 50 × 3
#>    .date      .analysis         .assessment     
#>    <date>     <list>            <list>          
#>  1 2009-02-20 <tibble [50 × 3]> <tibble [1 × 3]>
#>  2 2009-02-21 <tibble [50 × 3]> <tibble [1 × 3]>
#>  3 2009-02-22 <tibble [50 × 3]> <tibble [1 × 3]>
#>  4 2009-02-23 <tibble [50 × 3]> <tibble [1 × 3]>
#>  5 2009-02-24 <tibble [50 × 3]> <tibble [1 × 3]>
#>  6 2009-02-25 <tibble [50 × 3]> <tibble [1 × 3]>
#>  7 2009-02-26 <tibble [50 × 3]> <tibble [1 × 3]>
#>  8 2009-02-27 <tibble [50 × 3]> <tibble [1 × 3]>
#>  9 2009-02-28 <tibble [50 × 3]> <tibble [1 × 3]>
#> 10 2009-03-01 <tibble [50 × 3]> <tibble [1 × 3]>
#> # … with 40 more rows