-1

i have multivariate time series data and want to do sliding window and dtw for graph matching : there is any example i can refer . Thank you in advance

1 Answers1

0

For a sliding window, you could use the tsibble package (timeseries tibbles) per the minimal example below.

(I haven't used dynamic time warping, but see there is a DTW R package you could take a look at.)

library(tidyverse)
library(tsibble)

df <- tribble(
  ~timestep, ~var1, ~var2,
  1, 2, 3,
  2, 3, 4,
  3, 4, 5,
  4, 5, 6,
  5, 6, 7
)

df |> 
  tsibble(index = timestep) |> 
  slide_tsibble(.size = 3) # window size

#> # A tsibble: 9 x 4 [1]
#> # Key:       .id [3]
#>   timestep  var1  var2   .id
#>      <dbl> <dbl> <dbl> <int>
#> 1        1     2     3     1
#> 2        2     3     4     1
#> 3        3     4     5     1
#> 4        2     3     4     2
#> 5        3     4     5     2
#> 6        4     5     6     2
#> 7        3     4     5     3
#> 8        4     5     6     3
#> 9        5     6     7     3

Created on 2022-06-30 by the reprex package (v2.0.1)

Carl
  • 4,232
  • 2
  • 12
  • 24