Skip to contents

Use a changepoint set to break a time series into regions

Usage

cut_by_tau(x, tau)

split_by_tau(x, tau)

Arguments

x

A numeric vector

tau

a numeric vector of changepoint indices

Value

Details

A changepoint set tau of length \(k\) breaks a time series of length \(n\) into \(k+1\) non-empty regions. These non-empty regions can be defined by half-open intervals, starting with 1 and ending with \(n+1\).

cut_by_tau() splits a set of indices into a base::factor() of half-open intervals

split_by_tau() splits a time series into a named base::list() of numeric vectors

Examples

n <- length(CET)

# Return a factor of intervals
cut_by_tau(1:n, tau = pad_tau(c(42, 81, 330), n))
#>   [1] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)   
#>   [8] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)   
#>  [15] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)   
#>  [22] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)   
#>  [29] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)   
#>  [36] [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [1,42)    [42,81)  
#>  [43] [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)  
#>  [50] [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)  
#>  [57] [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)  
#>  [64] [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)  
#>  [71] [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)   [42,81)  
#>  [78] [42,81)   [42,81)   [42,81)   [81,330)  [81,330)  [81,330)  [81,330) 
#>  [85] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#>  [92] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#>  [99] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [106] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [113] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [120] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [127] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [134] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [141] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [148] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [155] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [162] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [169] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [176] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [183] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [190] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [197] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [204] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [211] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [218] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [225] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [232] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [239] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [246] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [253] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [260] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [267] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [274] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [281] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [288] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [295] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [302] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [309] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [316] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [323] [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330)  [81,330) 
#> [330] [330,367) [330,367) [330,367) [330,367) [330,367) [330,367) [330,367)
#> [337] [330,367) [330,367) [330,367) [330,367) [330,367) [330,367) [330,367)
#> [344] [330,367) [330,367) [330,367) [330,367) [330,367) [330,367) [330,367)
#> [351] [330,367) [330,367) [330,367) [330,367) [330,367) [330,367) [330,367)
#> [358] [330,367) [330,367) [330,367) [330,367) [330,367) [330,367) [330,367)
#> [365] [330,367) [330,367)
#> Levels: [1,42) [42,81) [81,330) [330,367)

# Return a list of observations
split_by_tau(DataCPSim, c(365, 826))
#> $`[1,365)`
#>   [1] 35.50961 29.00292 35.63508 32.98452 29.53557 25.40781 28.82497 50.31157
#>   [9] 24.93185 58.88063 30.35777 33.66315 32.58653 42.78788 45.23963 23.66417
#>  [17] 20.00954 31.64746 34.65507 68.49028 43.53948 25.29938 57.19244 39.51995
#>  [25] 23.79025 27.81451 42.00712 36.09812 32.74664 34.73679 60.20919 55.52211
#>  [33] 33.92043 32.48948 22.66494 24.16119 27.05582 16.09789 31.69439 27.22202
#>  [41] 20.64027 33.97673 46.71000 25.28389 24.88207 41.75347 36.50448 35.98297
#>  [49] 31.39612 44.14153 67.82557 26.81619 27.55292 30.77449 51.17371 51.34317
#>  [57] 23.10056 22.92962 29.39409 73.67531 23.46017 35.36286 29.45083 54.18062
#>  [65] 25.04895 27.47914 51.41767 32.30387 43.17916 30.11288 22.45535 33.70278
#>  [73] 34.16720 44.64931 22.60994 50.26498 50.28394 33.24944 38.73890 36.75336
#>  [81] 52.38881 36.62906 16.68155 35.12389 35.89239 61.81050 47.85419 30.26446
#>  [89] 36.93150 54.81053 30.32479 37.46579 49.93442 46.01734 24.86685 35.88435
#>  [97] 42.25720 37.78741 46.26335 38.52976 47.99867 44.28395 51.05976 50.99393
#> [105] 36.01026 37.44409 16.77029 31.05583 22.40344 27.22149 28.31583 58.06805
#> [113] 38.30690 47.26490 31.55811 47.63268 23.38334 33.30157 46.75618 30.46511
#> [121] 23.17060 31.52724 38.55479 35.54940 49.63486 38.85458 35.80205 24.50227
#> [129] 20.49025 31.59546 33.84992 30.02572 23.84156 27.92167 28.04857 55.54324
#> [137] 23.82133 46.27102 35.95369 47.65766 31.37265 37.43892 26.73598 39.78209
#> [145] 37.23990 38.69749 25.74961 15.00954 41.03282 35.55822 28.20253 34.25572
#> [153] 36.72560 25.87219 34.25647 41.05718 45.99951 35.09617 30.10936 56.29692
#> [161] 21.62607 32.16878 48.08144 27.56512 24.86829 23.20973 23.35380 24.87480
#> [169] 41.98302 43.00026 42.37708 57.59545 28.58172 35.77870 28.82814 35.31054
#> [177] 45.07452 19.92057 49.94871 42.05699 45.69919 40.55247 28.77050 34.25098
#> [185] 39.57524 27.14581 44.69057 36.14965 49.50564 49.79043 17.99559 39.65697
#> [193] 44.97010 18.31935 31.24522 31.07475 21.61906 40.06484 34.99030 21.94425
#> [201] 37.44403 40.21178 38.23743 31.80890 34.61897 47.81524 34.58307 30.49509
#> [209] 45.29616 49.07757 24.17640 35.64875 17.63070 21.61867 32.29813 26.41488
#> [217] 28.31542 25.02318 20.23520 28.13247 63.69313 42.52417 29.03129 54.03181
#> [225] 25.60167 66.22389 26.02854 43.94607 39.26708 21.90635 33.10292 31.36953
#> [233] 68.74632 49.57971 36.77692 62.23430 33.17239 34.70213 29.33086 40.40664
#> [241] 20.51693 56.48982 47.57652 18.78920 39.83695 23.57444 32.90584 23.97282
#> [249] 29.16350 33.94278 33.32760 40.39087 37.08789 34.55488 28.07540 34.55889
#> [257] 32.50873 30.26050 31.61021 29.22609 21.66017 39.99861 31.54268 54.66244
#> [265] 28.83481 50.43102 41.57023 36.52691 41.74322 29.88869 65.63664 28.92781
#> [273] 31.62743 60.02248 23.41874 30.41566 49.28914 30.75073 41.08489 35.95343
#> [281] 26.30653 30.42233 35.58619 27.11696 41.07739 32.16801 54.22658 30.58481
#> [289] 32.75808 40.14170 38.59850 34.62828 26.92407 32.65613 21.12857 21.76199
#> [297] 31.72514 32.81883 39.57492 29.56246 26.52171 33.16808 30.46846 26.71148
#> [305] 20.12177 28.85316 25.85809 73.07025 50.11722 55.60337 42.62562 53.62811
#> [313] 40.37492 36.09093 54.15097 52.48111 28.21508 44.33563 15.14660 31.77283
#> [321] 28.02836 42.85488 30.07936 32.42728 33.91356 17.04858 29.01530 31.04799
#> [329] 24.28621 35.50456 45.96182 21.99371 38.45540 25.78633 45.07985 27.04933
#> [337] 50.03548 29.92024 26.27057 24.47919 59.13347 35.87683 42.14550 29.36456
#> [345] 44.58931 30.97851 21.83860 46.47922 39.71751 20.74531 21.96494 27.95186
#> [353] 40.64999 65.79466 34.95445 33.87721 27.41981 19.67562 39.39982 45.69528
#> [361] 22.18879 37.54553 23.15847 28.45508
#> 
#> $`[365,826)`
#>   [1]  25.23477  33.00227  27.16574  34.19212  38.82416  17.26278  38.40626
#>   [8]  57.01508  40.28032  27.15082  32.21021  41.59108  44.75365  31.57659
#>  [15]  44.49800  41.11233  35.23455  24.47634  45.13415  37.24519  42.85021
#>  [22]  32.84645  37.01077  38.96790  40.08106  43.99265  32.24746  27.24075
#>  [29]  31.66613  34.98403  27.29397  34.99001  31.25752  30.07230  27.18477
#>  [36]  37.36462  34.40921  27.16085  37.36703  47.98335  43.48091  23.31231
#>  [43]  20.68531  40.72063  13.66989  27.99689  25.61063  27.89089  17.93238
#>  [50]  23.25505  69.87353  20.53952  38.76444  45.53784  43.99368  25.86236
#>  [57]  23.02465  26.68788  51.99475  31.49945  39.98303  25.96329  18.68290
#>  [64]  45.39740  41.85522  40.88774  33.13019  36.51401  43.93668  28.72223
#>  [71]  17.36850  29.80030  29.36764  33.21636  30.98314  44.00905  49.96474
#>  [78]  32.63317  34.95938  42.09920  25.98961  26.13540  40.91752  27.13926
#>  [85]  23.93415  44.34438  24.80069  39.56627  34.17161  29.33848  51.51685
#>  [92]  38.10154  17.89906  29.84155  20.73680  17.94649  20.14526  30.60828
#>  [99]  37.05229  26.99159  48.47064  29.63704  30.29811  29.44919  50.20743
#> [106]  25.22852  19.31610  49.49408  31.13921  45.04409  26.36500  21.37141
#> [113]  33.60464  39.82629  23.44417  50.85233  35.55273  31.42400  52.78349
#> [120]  46.42078  32.84158  41.58214  37.57874  92.79539  21.87917  35.86701
#> [127]  44.63170  23.67373  49.57926  37.82632  28.51937  54.19448  25.42921
#> [134]  31.42047  45.75800  26.14005  32.43037  30.31998  60.34780  35.38384
#> [141]  17.65934  49.95322  48.97623  24.37608  62.05997  17.90258  35.04199
#> [148]  25.02686  37.13100  27.42116  46.56513  14.44667  18.13457  30.41839
#> [155]  40.06058  33.26711  58.99535  23.18483  36.67044  24.95331  27.19064
#> [162]  26.76947  37.48431  37.13503  22.80870  32.98376  16.45626  25.22453
#> [169]  35.59700  24.01433  58.24541  34.09432  31.09085  29.28524  20.65437
#> [176]  24.52000  61.00638  33.59970  19.62836  30.89483  27.49646  47.74031
#> [183]  38.48854  79.28284  49.83587  41.20827  60.84168  58.74430  73.74234
#> [190]  62.99021  44.73661  66.14946  78.63431  58.85001  56.29965  49.76806
#> [197]  66.31184  77.24626  30.20323  34.36305  40.14230 115.76308  53.35118
#> [204]  56.61291  54.02821  30.86656  64.91494  51.47610  58.02405  46.19877
#> [211]  75.46288  62.38693  62.12430  29.65914  48.83256  48.45711  87.84555
#> [218]  48.89591  79.45862  45.43495  61.17216  44.15376  40.81283  28.66775
#> [225] 100.81542  80.80345  59.82787  60.46746  61.44131  33.23726  52.19624
#> [232]  83.51128  53.55938  63.91426  43.91224  55.36213  54.68760  56.36276
#> [239]  50.26803  63.36135  71.84053  44.01963  54.90876  48.05082  73.33604
#> [246]  40.86609  53.14413  59.74683  74.13609  72.72819  73.80368  46.35780
#> [253]  39.46049  69.37131  69.23278  39.48316  65.63175  50.51306  79.59284
#> [260]  43.27989  29.25963  53.94132  47.30325  89.88726  64.49022  53.12747
#> [267]  51.61317  47.72412 102.46424  79.80996  51.62739  45.94677  44.20380
#> [274]  62.47154  56.71323  45.20940  33.56516  93.76083  56.27748  43.03061
#> [281]  86.12136  66.81985 103.73717  45.81972  66.39085  43.21773  56.16747
#> [288]  59.28413  50.73493  65.26301 107.46498  68.39817  77.53655  63.00234
#> [295] 100.37694  50.08347  51.31859  47.84582  73.28803  56.60291  49.47953
#> [302]  74.14721  51.88331  72.97605  37.36928  50.55296  94.49818  85.63369
#> [309]  47.21940  51.29463  30.87699  40.99069  65.22233  84.18339  36.97547
#> [316]  67.67693 130.27515  56.50564  52.08214  36.62894  50.17403  43.98132
#> [323]  63.78818  69.71901  58.66280  34.25625  40.01212  38.51369  31.93027
#> [330]  70.08009  60.78508  51.19670  65.45439  70.13630  38.38639  46.42615
#> [337]  59.55314  49.09690  60.75484  66.66783  70.41840  77.79466  57.57120
#> [344]  66.27876  40.41878  51.19402  90.55426  28.21335  67.71025  52.72485
#> [351]  37.34428  72.43783  92.29608  55.59297  69.66448  58.30077  50.26778
#> [358]  74.61613  50.92561  51.97960  99.50324  47.12665  87.80435 119.15289
#> [365]  96.67512  27.20912  42.35955  51.36019  66.15466  50.99965  31.33727
#> [372]  29.62981  55.37496  72.04834  44.82771  46.57539  64.62869  38.82131
#> [379]  53.86127  30.62108  27.37893  85.39840  55.85290  64.89730  94.68730
#> [386]  35.15146  37.51919  45.72001  89.69830  46.13428  66.35095  37.41977
#> [393]  43.10677  40.13555  43.13188  24.73451  76.52571  36.36566  71.17790
#> [400]  56.44084  63.19831  38.86127  56.54947  83.05808  41.66112  60.14119
#> [407]  73.36839  36.83335  46.99687  68.72470  48.02621  37.04922  67.67630
#> [414]  46.78206  43.38829  79.76107  43.42811  34.89142  46.70848  85.92108
#> [421]  65.54841  39.49996  41.09837  47.97916  62.31907  75.42977  83.27070
#> [428]  73.13176  58.56810  75.03824  37.08341  57.11212  62.88590  80.01578
#> [435]  31.43220  50.27634  20.52318  57.18749  65.93147  42.64495  60.78448
#> [442]  42.12619  44.69412  58.64844  68.76875 163.36185  59.30573  44.16434
#> [449]  74.02857  42.16594  47.80402  46.06946  68.13544  58.27459  44.44837
#> [456]  49.71347  41.92370  65.10552 190.42879 100.55114  84.73240
#> 
#> $`[826,1.1e+03)`
#>   [1]  95.19440  62.62765  81.34105  62.84927 119.41128  97.69586 103.24047
#>   [8] 132.04779  63.94897  61.11686  68.83021  80.70128 118.36174  69.88491
#>  [15]  75.67939  97.87433  84.47204 167.57416 119.33953 112.87803  94.60966
#>  [22]  54.52644 134.89541  80.76840 100.86500 125.36064  80.85360  81.27602
#>  [29] 102.14881  62.87013  89.81105  90.54166  77.87923 154.26053 104.44530
#>  [36]  89.99370 137.11783 108.63313  81.65888  91.76187 153.53548  93.17887
#>  [43] 131.28943  58.95745  63.59264  86.73104 159.01308  56.48464  53.76414
#>  [50]  79.36095 104.17268  82.69108  75.47191  80.10494 123.34176 117.11018
#>  [57]  82.67987  87.24288  77.92377 105.19438  75.47461  73.26672 103.96131
#>  [64]  88.69445  67.40834 115.24510 107.64339  93.11673 129.87959 126.03289
#>  [71] 118.21727 101.24318  85.84310  83.24171  94.37437  95.52714  58.18705
#>  [78]  70.93290 135.64519 122.17646  47.94730  81.90610  71.29312  59.56557
#>  [85]  90.96883 105.27981  68.10784  62.24482 118.12494  89.29744 104.93346
#>  [92]  54.31292 118.22755  85.99992  68.28882 116.87775  59.89081  88.51994
#>  [99] 124.96078  48.99528  83.42296  39.21350 104.91602  96.76956 112.59752
#> [106]  71.12703  88.73937  68.98548  70.70640  93.68761 131.72255  82.59086
#> [113]  81.56980  80.12171 160.72231 130.68852  61.65840 175.64769 103.14938
#> [120] 133.32521 160.15746  97.61800 119.62046 125.04584 120.67301 110.96952
#> [127]  62.16252 215.10540  81.98616 110.52191  53.11782  83.00635  59.01162
#> [134] 167.43096 146.43115 136.73301  93.53995  92.63548  98.56852  59.88143
#> [141] 101.45146 102.84065 115.38549 110.87331  96.65850  70.26512  73.19904
#> [148] 204.44288 120.52524 148.47584 176.52242  72.50633  98.01507  85.07589
#> [155] 122.09749 173.47087 272.06243 114.84247 194.43547 182.95500  99.70758
#> [162] 155.32184 234.90205 149.08372 129.43951  92.17400 150.30666 127.34289
#> [169]  95.56536 183.85856 173.20963 119.36203 298.97556 239.90785 149.72990
#> [176] 145.83624 199.97769 221.71715 124.50443 127.57657 126.63670 224.84161
#> [183] 193.52027  67.17684 193.24399 163.77183 115.04808 139.80491 194.08049
#> [190] 142.56183 150.05278 112.32713 229.27074 123.95988 146.80726 185.69923
#> [197] 111.44768 148.97687 122.53709 127.37003  92.55487 106.25934 151.61132
#> [204] 166.55049 166.27216  89.84812 285.64838 210.83361 119.86280 120.26534
#> [211] 166.67314 128.77576 128.26908 203.90985 124.66021 285.09853 111.19870
#> [218] 185.07644  88.79945  97.17543 121.60783 183.18550 113.42228 234.66441
#> [225] 148.81920 127.67544 144.30028 183.15017 180.80073 212.84778  81.80066
#> [232] 156.28369 217.85070 136.70053 196.65904 155.49179 120.33784 123.21350
#> [239] 293.16047 141.29326 286.30265 137.11341 191.99534 155.88733 232.83108
#> [246] 141.37831 114.62536 154.08698 129.56200 197.71852 143.31929 155.63173
#> [253] 166.92790 151.48311 133.67364 183.79864 134.72402 108.41123 113.01052
#> [260] 145.28928  85.79995 220.96699 127.18015 215.14311 190.93505 156.44133
#> [267] 164.06449 164.81190  85.39927 179.14410 135.09159
#>