1
$\begingroup$

I am experimenting with creating a distance matrix between time series for clustering and similarity searching. The main reference I am using is for the Similarity procedure in SAS (Paper). I would like to conduct the analysis in R using the dtw package.

What I am confused about it the application of DTW to series of different lengths.

1) Is this possible? 2) Any hints on how to do it with the R package?

Regarding question #2, trying to calculate a distance matrix on a matrix of series that differ in length immediately fails:

dist_mat<-dist(appliances_t,method="DTW")

Error in dtw(distance.only = TRUE, ...) : 
  No warping paths exists that is allowed by costraints

dput(appliances_t)

structure(c(1L, 14L, 1L, 1L, 2L, 1L, 1L, 7L, 1L, 33L, 20L, 1L, 
1L, 8L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 14L, 
0L, 1L, 0L, 1L, 1L, 6L, 1L, 32L, 20L, 1L, 2L, 8L, 0L, 0L, 2L, 
1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 19L, 0L, 3L, 6L, 1L, 1L, 
7L, 1L, 42L, 27L, 1L, 3L, 10L, 0L, 1L, 3L, 1L, 3L, 1L, 1L, 1L, 
0L, 0L, 1L, 1L, 22L, 1L, 7L, 4L, 1L, 5L, 7L, 1L, 51L, 32L, 5L, 
4L, 12L, 1L, 1L, 9L, 5L, 7L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 33L, 
1L, 6L, 4L, 3L, 5L, 5L, 1L, 80L, 49L, 5L, 5L, 19L, 1L, 1L, 9L, 
5L, 7L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 28L, 1L, 7L, 8L, 3L, 5L, 
6L, 3L, 63L, 41L, 5L, 6L, 15L, 1L, 1L, 9L, 5L, 8L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 30L, 1L, 10L, 22L, 10L, 8L, 7L, 5L, 70L, 44L, 
8L, 7L, 16L, 1L, 1L, 12L, 8L, 11L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
32L, 2L, 13L, 30L, 10L, 10L, 11L, 12L, 74L, 47L, 10L, 8L, 18L, 
2L, 1L, 16L, 10L, 14L, 1L, 1L, 1L, 1L, 2L, 1L, 5L, 23L, 4L, 6L, 
30L, 10L, 5L, 9L, 12L, 53L, 33L, 5L, 9L, 12L, 5L, 1L, 9L, 5L, 
8L, 5L, 5L, 5L, 3L, 5L, 5L, 7L, 27L, 7L, 9L, 22L, 14L, 7L, 11L, 
12L, 61L, 36L, 7L, 10L, 14L, 7L, 1L, 11L, 7L, 11L, 8L, 8L, 8L, 
6L, 7L, 8L, 14L, 27L, 14L, 13L, 38L, 19L, 10L, 7L, 15L, 61L, 
37L, 10L, 11L, 14L, 14L, 1L, 14L, 10L, 14L, 12L, 12L, 12L, 9L, 
14L, 12L, 14L, 38L, 14L, 14L, 44L, 10L, 11L, 9L, 20L, 86L, 54L, 
11L, 12L, 20L, 14L, 1L, 16L, 11L, 14L, 22L, 22L, 22L, 16L, 14L, 
22L, 14L, 27L, 14L, 16L, 42L, 13L, 13L, 12L, 11L, 61L, 39L, 13L, 
13L, 14L, 14L, 1L, 19L, 13L, 18L, 22L, 22L, 22L, 16L, 14L, 22L, 
20L, 28L, 19L, 10L, 40L, 16L, 9L, 12L, 14L, 66L, 41L, 9L, 14L, 
16L, 20L, 1L, 13L, 9L, 12L, 23L, 23L, 23L, 18L, 20L, 23L, 27L, 
16L, 27L, 10L, 60L, 19L, 8L, 11L, 20L, 39L, 23L, 8L, 15L, 9L, 
27L, 4L, 12L, 8L, 11L, 30L, 30L, 30L, 22L, 27L, 30L, 14L, 24L, 
14L, 14L, 136L, 21L, 11L, 4L, 21L, 56L, 33L, 11L, 16L, 12L, 14L, 
3L, 16L, 11L, 14L, 42L, 42L, 42L, 31L, 14L, 42L, 18L, 23L, 18L, 
16L, 206L, 14L, 14L, 3L, 25L, 54L, 33L, 14L, 17L, 12L, 18L, 2L, 
20L, 14L, 18L, 22L, 22L, 22L, 16L, 18L, 22L, 24L, 28L, 23L, 25L, 
398L, 14L, 20L, 6L, 16L, 65L, 40L, 20L, 18L, 16L, 24L, 4L, 29L, 
20L, 28L, 28L, 28L, 28L, 21L, 24L, 28L, 27L, 18L, 27L, 20L, 380L, 
19L, 16L, 5L, 16L, 40L, 25L, 16L, 19L, 10L, 27L, 3L, 25L, 16L, 
21L, 39L, 39L, 39L, 28L, 27L, 39L, 32L, 19L, 30L, 21L, 406L, 
22L, 18L, 3L, 20L, 42L, 27L, 18L, 20L, 10L, 32L, 3L, 27L, 18L, 
24L, 43L, 43L, 43L, 32L, 32L, 43L, 20L, 21L, 20L, 22L, 504L, 
33L, 19L, 7L, 27L, 49L, 31L, 19L, 21L, 12L, 20L, 2L, 28L, 19L, 
27L, 49L, 49L, 49L, 37L, 20L, 49L, 20L, 20L, 20L, 16L, 682L, 
28L, 14L, 7L, 41L, 48L, 30L, 14L, 22L, 12L, 20L, 2L, 20L, 14L, 
18L, 33L, 33L, 33L, 25L, 20L, 33L, 27L, 13L, 27L, 19L, 374L, 
30L, 14L, 8L, 32L, 29L, 19L, 14L, 23L, 6L, 27L, 3L, 21L, 14L, 
20L, 32L, 32L, 32L, 23L, 27L, 32L, 32L, 20L, 32L, 19L, 489L, 
32L, 14L, 7L, 33L, 47L, 28L, 14L, 24L, 11L, 32L, 3L, 21L, 14L, 
20L, 42L, 42L, 42L, 32L, 32L, 42L, 49L, 16L, 49L, 27L, 628L, 
23L, 21L, 13L, 36L, 35L, 21L, 21L, 25L, 8L, 49L, 4L, 32L, 21L, 
30L, 51L, 51L, 51L, 40L, 49L, 51L, 41L, 27L, 41L, 19L, 791L, 
27L, 15L, 14L, 27L, 62L, 39L, 15L, 26L, 14L, 41L, 1L, 22L, 15L, 
20L, 80L, 80L, 80L, 61L, 41L, 80L, 44L, 33L, 44L, 20L, 898L, 
27L, 16L, 16L, 29L, 77L, 48L, 16L, 27L, 18L, 44L, 1L, 25L, 16L, 
21L, 63L, 63L, 63L, 48L, 44L, 63L, 47L, 21L, 46L, 13L, 439L, 
38L, 10L, 21L, 30L, 51L, 32L, 10L, 28L, 12L, 47L, 2L, 14L, 10L, 
14L, 70L, 70L, 70L, 51L, 47L, 70L, 33L, 32L, 33L, 18L, 515L, 
27L, 14L, 22L, 43L, 75L, 47L, 14L, 29L, 18L, 33L, 2L, 20L, 14L, 
20L, 74L, 74L, 74L, 54L, 33L, 74L, 36L, 33L, 36L, 16L, 450L, 
28L, 14L, 17L, 30L, 76L, 48L, 14L, 30L, 18L, 36L, 3L, 20L, 14L, 
18L, 53L, 53L, 53L, 40L, 36L, 53L, 37L, 33L, 37L, 20L, 726L, 
16L, 16L, 14L, 32L, 78L, 48L, 16L, 31L, 19L, 37L, 3L, 24L, 16L, 
21L, 61L, 61L, 61L, 45L, 37L, 61L, 54L, 48L, 53L, 13L, 1069L, 
24L, 10L, 17L, 19L, 109L, 68L, 10L, 32L, 27L, 54L, 3L, 14L, 10L, 
14L, 61L, 61L, 61L, 45L, 54L, 61L, 39L, 51L, 37L, 13L, 889L, 
23L, 11L, 19L, 28L, 120L, 76L, 11L, 33L, 28L, 39L, 3L, 16L, 11L, 
14L, 86L, 86L, 86L, 63L, 39L, 86L, 41L, 43L, 40L, 16L, 1083L, 
28L, 13L, 22L, 28L, 97L, 62L, 13L, 34L, 22L, 41L, 3L, 19L, 13L, 
18L, 61L, 61L, 61L, 46L, 41L, 61L, 23L, 50L, 23L, 15L, 1110L, 
18L, 13L, 25L, 32L, 118L, 73L, 12L, 35L, 28L, 23L, 2L, 19L, 13L, 
17L, 66L, 66L, 66L, 49L, 23L, 66L, 33L, 80L, 33L, 10L, 803L, 
19L, 7L, 32L, 20L, 185L, 116L, 7L, 36L, 43L, 33L, 7L, 11L, 7L, 
11L, 39L, 39L, 39L, 28L, 33L, 39L, 33L, 63L, 33L, 14L, 828L, 
21L, 12L, 33L, 20L, 146L, 91L, 12L, 37L, 34L, 33L, 9L, 18L, 12L, 
16L, 56L, 56L, 56L, 42L, 33L, 56L, 40L, 68L, 40L, 11L, 1001L, 
20L, 9L, 29L, 25L, 157L, 97L, 9L, 38L, 35L, 40L, 11L, 14L, 9L, 
13L, 54L, 54L, 54L, 41L, 40L, 54L, 25L, 80L, 24L, 20L, 1281L, 
13L, 16L, 32L, 23L, 181L, 113L, 16L, 39L, 43L, 25L, 3L, 22L, 
16L, 21L, 65L, 65L, 65L, 48L, 25L, 65L, 27L, 68L, 27L, 24L, 918L, 
20L, 20L, 32L, 14L, 155L, 96L, 20L, 40L, 35L, 27L, 1L, 29L, 20L, 
27L, 40L, 40L, 40L, 29L, 27L, 40L, 31L, 85L, 30L, 16L, 974L, 
16L, 14L, 45L, 23L, 194L, 120L, 13L, 41L, 47L, 31L, 4L, 20L, 
14L, 18L, 42L, 42L, 42L, 31L, 31L, 42L, 30L, 76L, 29L, 23L, 524L, 
27L, 19L, 51L, 18L, 172L, 109L, 19L, 42L, 40L, 30L, 7L, 28L, 
19L, 27L, 49L, 49L, 49L, 36L, 30L, 49L, 19L, 74L, 19L, 23L, 486L, 
33L, 20L, 40L, 30L, 168L, 105L, 19L, 43L, 39L, 19L, 3L, 28L, 
20L, 27L, 48L, 48L, 48L, 36L, 19L, 48L, 28L, 80L, 28L, 24L, 380L, 
21L, 20L, 51L, 39L, 185L, 115L, 20L, 44L, 43L, 28L, 3L, 29L, 
20L, 28L, 29L, 29L, 29L, 21L, 28L, 29L, 21L, 131L, 21L, 33L, 
456L, 32L, 27L, 54L, 27L, 300L, 188L, 27L, 45L, 70L, 21L, 3L, 
40L, 27L, 38L, 47L, 47L, 47L, 34L, 21L, 47L, 39L, 139L, 38L, 
37L, 360L, 33L, 30L, 63L, 37L, 315L, 198L, 30L, 46L, 74L, 39L, 
3L, 47L, 30L, 41L, 35L, 35L, 35L, 27L, 39L, 35L, 48L, 197L, 48L, 
30L, 488L, 33L, 24L, 90L, 38L, 449L, 280L, 24L, 47L, 104L, 48L, 
8L, 36L, 24L, 33L, 62L, 62L, 62L, 47L, 48L, 62L, 32L, 175L, 32L, 
36L, 622L, 48L, 29L, 86L, 39L, 401L, 249L, 29L, 48L, 95L, 32L, 
3L, 44L, 29L, 40L, 77L, 77L, 77L, 58L, 32L, 77L, 47L, 147L, 47L, 
58L, 522L, 51L, 47L, 63L, 53L, 336L, 211L, 47L, 49L, 79L, 47L, 
3L, 69L, 47L, 64L, 51L, 51L, 51L, 40L, 47L, 51L, 48L, 212L, 48L, 
47L, 306L, 43L, 36L, 76L, 60L, 483L, 304L, 35L, 50L, 114L, 48L, 
3L, 54L, 36L, 50L, 75L, 75L, 75L, 56L, 48L, 75L, 48L, 175L, 48L, 
48L, 628L, 50L, 39L, 106L, 48L, 401L, 249L, 39L, 51L, 95L, 48L, 
0L, 58L, 39L, 52L, 76L, 76L, 76L, 57L, 48L, 76L, 68L, 186L, 67L, 
56L, 320L, 80L, 47L, 85L, 59L, 426L, 266L, 47L, 52L, 100L, 68L, 
1L, 68L, 47L, 63L, 78L, 78L, 78L, 59L, 68L, 78L, 76L, 144L, 75L, 
48L, 646L, 63L, 39L, 69L, 92L, 332L, 207L, 39L, 53L, 77L, 76L, 
2L, 58L, 39L, 52L, 109L, 109L, 109L, 80L, 76L, 109L, 62L, 140L, 
61L, 61L, 790L, 68L, 48L, 83L, 72L, 323L, 200L, 48L, 54L, 76L, 
62L, 3L, 72L, 48L, 66L, 120L, 120L, 120L, 91L, 62L, 120L, 73L, 
170L, 72L, 54L, 556L, 80L, 43L, 96L, 78L, 390L, 244L, 43L, 55L, 
91L, 73L, 6L, 63L, 43L, 60L, 97L, 97L, 97L, 73L, 73L, 97L, 116L, 
157L, 114L, 51L, 552L, 68L, 43L, 113L, 91L, 357L, 224L, 43L, 
56L, 84L, 116L, 7L, 63L, 43L, 58L, 118L, 118L, 118L, 88L, 116L, 
118L, 91L, 225L, 91L, 58L, 806L, 85L, 47L, 96L, 78L, 512L, 321L, 
47L, 57L, 119L, 91L, 5L, 68L, 47L, 65L, 185L, 185L, 185L, 138L, 
91L, 185L, 97L, 103L, 96L, 95L, 855L, 76L, 75L, 108L, 96L, 236L, 
148L, 75L, 58L, 56L, 97L, NA, 112L, 76L, 104L, 146L, 146L, 146L, 
109L, 97L, 146L, 113L, 128L, 112L, 97L, 1050L, 74L, 78L, 116L, 
86L, 294L, 184L, 78L, 59L, 69L, 113L, NA, 118L, 78L, 110L, 157L, 
157L, 157L, 117L, 113L, 157L, 96L, 140L, 96L, 140L, 1120L, 80L, 
112L, 123L, 83L, 321L, 199L, 112L, 60L, 75L, 96L, NA, 167L, 112L, 
155L, 181L, 181L, 181L, 137L, 96L, 181L, 120L, 146L, 119L, 126L, 
908L, 131L, 99L, 192L, 92L, 334L, 209L, 99L, 61L, 78L, 120L, 
NA, 150L, 99L, 138L, 155L, 155L, 155L, 117L, 120L, 155L, 109L, 
150L, 107L, 105L, 1068L, 139L, 84L, 373L, 150L, 343L, 214L, 83L, 
62L, 80L, 109L, NA, 126L, 84L, 117L, 194L, 194L, 194L, 146L, 
109L, 194L, 105L, 158L, 104L, 151L, 1696L, 197L, 120L, 195L, 
158L, 363L, 227L, 120L, 63L, 84L, 105L, NA, 181L, 121L, 168L, 
172L, 172L, 172L, 129L, 105L, 172L, 115L, 160L, 115L, 125L, 1658L, 
175L, 99L, 213L, 224L, 366L, 228L, 99L, 64L, 86L, 115L, NA, 150L, 
100L, 138L, 168L, 168L, 168L, 126L, 115L, 168L, 188L, 179L, 186L, 
132L, 1872L, 147L, 106L, 215L, 199L, 408L, 256L, 106L, 65L, 96L, 
188L, NA, 160L, 106L, 149L, 185L, 185L, 185L, 138L, 188L, 185L, 
198L, 148L, 195L, 103L, 2262L, 212L, 81L, 232L, 167L, 338L, 212L, 
81L, 66L, 80L, 198L, NA, 125L, 81L, 115L, 300L, 300L, 300L, 226L, 
198L, 300L, 280L, 145L, 278L, 100L, 2120L, 175L, 80L, 318L, 242L, 
332L, 209L, 80L, 67L, 138L, 280L, NA, 120L, 80L, 112L, 315L, 
315L, 315L, 236L, 280L, 315L, 249L, 151L, 248L, 122L, 2215L, 
186L, 97L, 184L, 199L, 348L, 226L, 97L, 68L, 137L, 249L, NA, 
146L, 97L, 137L, 449L, 449L, 449L, 337L, 249L, 449L, 211L, 166L, 
208L, 111L, 1756L, 144L, 91L, 195L, 213L, 402L, 434L, 91L, 69L, 
190L, 211L, NA, 134L, 91L, 124L, 401L, 401L, 401L, 299L, 211L, 
401L, 304L, 159L, 299L, 160L, 2010L, 140L, 128L, 243L, 165L, 
422L, 380L, 128L, 70L, 149L, 304L, NA, 192L, 128L, 177L, 336L, 
336L, 336L, 253L, 304L, 336L, 249L, 188L, 248L, 74L, 2278L, 170L, 
60L, 242L, 160L, 492L, 501L, 59L, 71L, 127L, 249L, NA, 89L, 60L, 
81L, 483L, 483L, 483L, 364L, 249L, 483L, 266L, 119L, 263L, 92L, 
3064L, 157L, 74L, 264L, 195L, 403L, 359L, 74L, 72L, 128L, 266L, 
NA, 110L, 74L, 102L, 401L, 401L, 401L, 300L, 266L, 401L, 207L, 
237L, 206L, 99L, 3001L, 225L, 80L, 199L, 177L, 892L, 719L, 80L, 
73L, 291L, 207L, NA, 119L, 80L, 112L, 426L, 426L, 426L, 319L, 
207L, 426L, 200L, 383L, 199L, 104L, 4429L, 103L, 83L, 173L, 256L, 
1418L, 710L, 82L, 74L, 342L, 200L, NA, 126L, 83L, 117L, 332L, 
332L, 332L, 247L, 200L, 332L, 244L, 163L, 242L, 109L, 4118L, 
128L, 86L, 207L, 118L, 1011L, 541L, 86L, 75L, 223L, 244L, NA, 
128L, 86L, 118L, 323L, 323L, 323L, 241L, 244L, 323L, 224L, 463L, 
221L, 113L, 3112L, 140L, 91L, 152L, 145L, 1268L, 436L, 91L, 76L, 
276L, 224L, NA, 137L, 91L, 125L, 390L, 390L, 390L, 293L, 224L, 
390L, 321L, 325L, 318L, 115L, 3968L, 146L, 92L, 173L, 160L, 1112L, 
286L, 92L, 77L, 278L, 321L, NA, 138L, 92L, 125L, 357L, 357L, 
357L, 268L, 321L, 357L, 148L, 579L, 145L, 127L, 3395L, 150L, 
102L, 146L, 166L, 1606L, 382L, 102L, 78L, 253L, 148L, NA, 151L, 
102L, 141L, 512L, 512L, 512L, 385L, 148L, 512L, 184L, 431L, 181L, 
106L, 3693L, 158L, 84L, 158L, 171L, 1221L, 432L, 83L, 79L, 324L, 
184L, NA, 126L, 85L, 118L, 236L, 236L, 236L, 178L, 184L, 236L, 
199L, 833L, 198L, 103L, 3038L, 160L, 82L, 145L, 179L, 814L, 210L, 
81L, 80L, 243L, 199L, NA, 125L, 82L, 115L, 294L, 294L, 294L, 
220L, 199L, 294L, 209L, 580L, 207L, 109L, 2303L, 179L, 87L, 156L, 
182L, 952L, 280L, 87L, 81L, 244L, 209L, NA, 131L, 88L, 120L, 
321L, 321L, 321L, 240L, 209L, 321L, 1063L, 654L, 212L, 118L, 
2959L, 148L, 95L, 162L, 202L, 920L, 332L, 95L, 82L, 202L, 214L, 
NA, 142L, 95L, 130L, 334L, 334L, 334L, 249L, 214L, 334L, 1535L, 
950L, 225L, 113L, 2509L, 306L, 91L, 297L, 167L, 907L, 393L, 91L, 
83L, 201L, 227L, NA, 137L, 91L, 125L, 343L, 343L, 343L, 258L, 
227L, 343L, 1705L, 1252L, 227L, 135L, 2718L, 397L, 109L, 332L, 
166L, 804L, 320L, 108L, 84L, 121L, 228L, NA, 162L, 109L, 150L, 
363L, 363L, 363L, 271L, 228L, 363L, 1203L, 1192L, 253L, 95L, 
1813L, 481L, 76L, 451L, 174L, 869L, 308L, 75L, 85L, 91L, 256L, 
NA, 113L, 76L, 104L, 366L, 366L, 366L, 275L, 256L, 366L, 1176L, 
1127L, 210L, 140L, 2103L, 441L, 111L, 425L, 188L, 872L, 447L, 
111L, 86L, 160L, 212L, NA, 167L, 111L, 154L, 408L, 408L, 408L, 
306L, 212L, 408L, 943L, 1168L, 206L, 176L, 2156L, 600L, 141L, 
346L, 179L, 980L, 478L, 141L, 87L, 169L, 209L, NA, 213L, 141L, 
197L, 338L, 338L, 338L, 256L, 209L, 338L, 685L, 1469L, 215L, 
129L, 2212L, 414L, 104L, 373L, 214L, 1195L, 764L, 104L, 88L, 
234L, 217L, NA, 157L, 104L, 143L, 332L, 332L, 332L, 248L, 217L, 
332L, 951L, 690L, 234L, 164L, 1995L, 358L, 130L, 522L, 150L, 
849L, 441L, 129L, 89L, 145L, 236L, NA, 196L, 130L, 182L, 348L, 
348L, 348L, 261L, 236L, 348L, 779L, NA, 227L, 147L, 1995L, 648L, 
118L, 398L, 222L, NA, NA, 118L, 90L, NA, 228L, NA, 178L, 118L, 
165L, 378L, 378L, 378L, 283L, 228L, 378L, 853L, NA, 266L, 167L, 
2252L, 352L, 133L, 437L, 282L, NA, NA, 135L, 91L, NA, 270L, NA, 
202L, 136L, 188L, 364L, 364L, 364L, 274L, 270L, 364L, 593L, NA, 
186L, 213L, 2142L, 415L, 160L, 346L, 208L, NA, NA, 170L, 92L, 
NA, 188L, NA, 257L, 170L, 236L, 430L, 430L, 430L, 324L, 188L, 
430L, 844L, NA, 276L, 129L, 1933L, 584L, 135L, 423L, 261L, NA, 
NA, 104L, 93L, NA, 280L, NA, 157L, 104L, 143L, 301L, 301L, 301L, 
227L, 280L, 301L, 1055L, NA, 352L, 150L, 1973L, 606L, 177L, 507L, 
236L, NA, NA, 119L, 94L, NA, 354L, NA, 180L, 119L, 167L, 447L, 
447L, 447L, 334L, 354L, 447L, 773L, NA, 258L, 159L, 1656L, 1012L, 
281L, 399L, 269L, NA, NA, 126L, 95L, NA, 261L, NA, 191L, 127L, 
175L, 567L, 567L, 567L, 424L, 261L, 567L, 722L, NA, 324L, 167L, 
1883L, 617L, 267L, 430L, 340L, NA, NA, 134L, 96L, NA, 326L, NA, 
202L, 134L, 187L, 417L, 417L, 417L, 311L, 326L, 417L, 687L, NA, 
293L, 169L, 1788L, 530L, 275L, 444L, 206L, NA, NA, 136L, 97L, 
NA, 295L, NA, 205L, 136L, 189L, 521L, 521L, 521L, 392L, 295L, 
521L, 711L, NA, 334L, 186L, 1763L, 597L, 234L, 460L, 240L, NA, 
NA, 147L, 98L, NA, 338L, NA, 222L, 147L, 205L, 473L, 473L, 473L, 
354L, 338L, 473L, 889L, NA, 422L, 198L, 1337L, 446L, 303L, 584L, 
253L, NA, NA, 166L, 99L, NA, 427L, NA, 237L, 158L, 220L, 540L, 
540L, 540L, 405L, 427L, 540L, 635L, NA, 258L, 310L, 1749L, 558L, 
396L, 600L, 269L, NA, NA, 239L, 100L, NA, 261L, NA, 373L, 247L, 
345L, 683L, 683L, 683L, 512L, 261L, 683L, 669L, NA, 298L, 359L, 
1960L, 590L, 608L, 588L, 271L, NA, NA, 372L, 101L, NA, 303L, 
NA, 431L, 288L, 398L, 416L, 416L, 416L, 311L, 303L, 416L, 712L, 
NA, 315L, 214L, 1383L, 576L, 355L, 893L, 295L, NA, NA, 256L, 
102L, NA, 319L, NA, 257L, 170L, 236L, 482L, 482L, 482L, 361L, 
319L, 482L, 727L, NA, 334L, NA, 1631L, 730L, NA, 864L, 316L, 
NA, NA, NA, 103L, NA, 336L, NA, NA, NA, NA, 509L, 509L, 509L, 
382L, 336L, 509L, 887L, NA, 339L, NA, 1513L, 736L, NA, 580L, 
496L, NA, NA, NA, 104L, NA, 340L, NA, NA, NA, NA, 539L, 539L, 
539L, 403L, 340L, 539L, 794L, NA, 369L, NA, 1687L, 647L, NA, 
632L, 572L, NA, NA, NA, 105L, NA, 264L, NA, NA, NA, NA, 546L, 
546L, 546L, 408L, 325L, 546L, 838L, NA, 392L, NA, 2145L, NA, 
NA, 712L, 340L, NA, NA, NA, 106L, NA, 357L, NA, NA, NA, NA, 594L, 
594L, 382L, 443L, 462L, 594L, 880L, NA, 616L, NA, 1522L, NA, 
NA, 700L, NA, NA, NA, NA, 107L, NA, 456L, NA, NA, NA, NA, 634L, 
634L, 424L, 476L, 447L, 634L, 1030L, NA, 712L, NA, 1578L, NA, 
NA, 703L, NA, NA, NA, NA, 108L, NA, 873L, NA, NA, NA, NA, 996L, 
996L, 497L, 746L, 518L, 996L, 842L, NA, 256L, NA, 1546L, NA, 
NA, 753L, NA, NA, NA, NA, 109L, NA, 337L, NA, NA, NA, NA, 1151L, 
1151L, 515L, 862L, 465L, 1151L, NA, NA, NA, NA, 1685L, NA, NA, 
699L, NA, NA, NA, NA, 110L, NA, NA, NA, NA, NA, NA, 685L, 685L, 
310L, 512L, NA, 685L, NA, NA, NA, NA, 1726L, NA, NA, 857L, NA, 
NA, NA, NA, 111L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, 1561L, NA, NA, 1099L, NA, NA, NA, NA, 112L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
1411L, NA, NA, 1156L, NA, NA, NA, NA, 113L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1714L, NA, NA, 3876L, 
NA, NA, NA, NA, 114L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 2258L, NA, NA, 1507L, NA, NA, NA, NA, 
115L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 1442L, NA, NA, 1524L, NA, NA, NA, NA, 116L, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
2073L, NA, NA, NA, NA, 117L, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2725L, NA, NA, NA, 
NA, 118L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, 2255L, NA, NA, NA, NA, 119L, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, 1634L, NA, NA, NA, NA, 120L, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1360L, NA, NA, 
NA, NA, 121L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, 1270L, NA, NA, NA, NA, 122L, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, 1328L, NA, NA, NA, NA, 123L, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1470L, NA, 
NA, NA, NA, 124L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, 1040L, NA, NA, NA, NA, 125L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1095L, NA, NA, NA, NA, 126L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1823L, 
NA, NA, NA, NA, 127L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 3221L, NA, NA, NA, NA, 128L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 3986L, NA, NA, NA, NA, 129L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3632L, 
NA, NA, NA, NA, 130L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 3760L, NA, NA, NA, NA, 131L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 3225L, NA, NA, NA, NA, 132L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3473L, 
NA, NA, NA, NA, 133L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 3359L, NA, NA, NA, NA, 134L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 2032L, NA, NA, NA, NA, 135L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 3337L, 
NA, NA, NA, NA, 136L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 2474L, NA, NA, NA, NA, 137L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1748L, NA, NA, NA, NA, 138L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1581L, 
NA, NA, NA, NA, 139L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 2590L, NA, NA, NA, NA, 140L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 2769L, NA, NA, NA, NA, 141L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2134L, 
NA, NA, NA, NA, 142L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 2312L, NA, NA, NA, NA, 143L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1822L, NA, NA, NA, NA, 144L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1890L, 
NA, NA, NA, NA, 145L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1770L, NA, NA, NA, NA, 146L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1664L, NA, NA, NA, NA, 147L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1533L, 
NA, NA, NA, NA, 148L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1628L, NA, NA, NA, NA, 149L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1682L, NA, NA, NA, NA, 150L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1416L, 
NA, NA, NA, NA, 151L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1721L, NA, NA, NA, NA, 152L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1732L, NA, NA, NA, NA, 153L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1748L, 
NA, NA, NA, NA, 154L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, 1312L, NA, NA, NA, NA, 155L, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, 1659L, NA, NA, NA, NA, 156L, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA), .Dim = c(25L, 156L), .Dimnames = list(
    c("units_1", "units_2", "units_3", "units_4", "units_5", 
    "units_6", "units_7", "units_8", "units_9", "units_10", "units_11", 
    "units_12", "units_13", "units_14", "units_15", "units_16", 
    "units_17", "units_18", "units_19", "units_20", "units_21", 
    "units_22", "units_23", "units_24", "units_25"), NULL))
$\endgroup$
  • 1
    $\begingroup$ Please post only the necessary amount of numerical information. There is no value in the endless string of numbers you included. $\endgroup$ – Anony-Mousse May 12 '13 at 13:30
4
$\begingroup$

This feels like a hack, but I can get the dtw function to work as follows.

#this shows how to register a distance function with proxy

install.packages("proxy")
require("proxy")


DWT.DIST<-function (x,y)
{

  a<-na.omit(x)
  b<-na.omit(y)

  return(dtw(a,b)$normalizedDistance)
}


## create a new entry in the registry with two aliases
pr_DB$set_entry(FUN = DWT.DIST, names = c("DWT.DIST"))

d<-dist(appliances_t, method = "DWT.DIST")
hc<-hclust(d,"ave")
plot(hc)

pr_DB$delete_entry("DWT.DIST")
$\endgroup$
  • 1
    $\begingroup$ I received confirmation from the package author that this is indeed the properly method to use to deal with series of differing lengths (to obtain a distance matrix). $\endgroup$ – B_Miner May 13 '13 at 12:55
0
$\begingroup$

It looks like you should be using the open.end=TRUE flag to enable variable-length matching, but unfortunately I still get errors.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.