This is a convenience function that simplifies the task of appending multivariate functional observations of two datasets to a unique multivariate functional dataset.
append_mfData(mfD1, mfD2)
is the first multivariate functional dataset, stored into an mfData
object.
is the second multivariate functional dataset, stored into an mfData
object.
The function returns a mfData
object containing the union of mfD1
and mfD2
The two original datasets must be compatible, i.e. must have same number of components (dimensions) and must be defined on the same grid. If we denote with \(X_1^(i), \ldots, X_n^(i)\), \(i=0, \ldots, L\) the first dataset, defined over the grid \(I = t_1, \ldots, t_P\), and with \(Y_1^(i), \ldots, Y_m^(i)\), \(i=0, \ldots, L\) the second functional dataset, the method returns the union dataset obtained by taking all the \(n + m\) observations together.
# Creating two simple bivariate datasets
grid = seq(0, 2 * pi, length.out = 100)
values11 = matrix( c(sin(grid),
sin(2 * grid)), nrow = 2, ncol = length(grid),
byrow=TRUE)
values12 = matrix( c(sin(3 * grid),
sin(4 * grid)), nrow = 2, ncol = length(grid),
byrow=TRUE)
values21 = matrix( c(cos(grid),
cos(2 * grid)), nrow = 2, ncol = length(grid),
byrow=TRUE)
values22 = matrix( c(cos(3 * grid),
cos(4 * grid)), nrow = 2, ncol = length(grid),
byrow=TRUE)
mfD1 = mfData( grid, list(values11, values12) )
mfD2 = mfData( grid, list(values21, values22) )
# Appending them to a unique dataset
append_mfData(mfD1, mfD2)
#> $N
#> [1] 4
#>
#> $L
#> [1] 2
#>
#> $P
#> [1] 100
#>
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 6.283185
#>
#> $fDList
#> $fDList[[1]]
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 6.283185
#>
#> $h
#> [1] 0.06346652
#>
#> $P
#> [1] 100
#>
#> $N
#> [1] 4
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 0 0.06342392 0.1265925 0.1892512 0.2511480 0.3120334 0.3716625
#> [2,] 0 0.12659245 0.2511480 0.3716625 0.4861967 0.5929079 0.6900790
#> [3,] 1 0.99798668 0.9919548 0.9819287 0.9679487 0.9500711 0.9283679
#> [4,] 1 0.99195481 0.9679487 0.9283679 0.8738494 0.8052703 0.7237340
#> [,8] [,9] [,10] [,11] [,12] [,13] [,14]
#> [1,] 0.4297949 0.4861967 0.5406408 0.5929079 0.6427876 0.69007901 0.73459171
#> [2,] 0.7761465 0.8497254 0.9096320 0.9549022 0.9848078 0.99886734 0.99685478
#> [3,] 0.9029265 0.8738494 0.8412535 0.8052703 0.7660444 0.72373404 0.67850941
#> [4,] 0.6305527 0.5272255 0.4154150 0.2969204 0.1736482 0.04758192 -0.07924996
#> [,15] [,16] [,17] [,18] [,19] [,20]
#> [1,] 0.7761465 0.8145760 0.8497254 0.8814534 0.9096320 0.9341479
#> [2,] 0.9788024 0.9450008 0.8959938 0.8325699 0.7557496 0.6667690
#> [3,] 0.6305527 0.5800569 0.5272255 0.4722711 0.4154150 0.3568862
#> [4,] -0.2048067 -0.3270680 -0.4440666 -0.5539201 -0.6548607 -0.7452644
#> [,21] [,22] [,23] [,24] [,25] [,26]
#> [1,] 0.9549022 0.9718116 0.9848078 0.9938385 0.99886734 0.99987413
#> [2,] 0.5670599 0.4582265 0.3420201 0.2203105 0.09505604 -0.03172793
#> [3,] 0.2969204 0.2357589 0.1736482 0.1108382 0.04758192 -0.01586596
#> [4,] -0.8236766 -0.8888354 -0.9396926 -0.9754298 -0.99547192 -0.99949654
#> [,27] [,28] [,29] [,30] [,31] [,32]
#> [1,] 0.99685478 0.9898214 0.9788024 0.9638422 0.9450008 0.9223543
#> [2,] -0.15800140 -0.2817326 -0.4009305 -0.5136774 -0.6181590 -0.7126942
#> [3,] -0.07924996 -0.1423148 -0.2048067 -0.2664738 -0.3270680 -0.3863451
#> [4,] -0.98743889 -0.9594930 -0.9161085 -0.8579834 -0.7860531 -0.7014749
#> [,33] [,34] [,35] [,36] [,37] [,38]
#> [1,] 0.8959938 0.8660254 0.8325699 0.7957618 0.7557496 0.71269417
#> [2,] -0.7957618 -0.8660254 -0.9223543 -0.9638422 -0.9898214 -0.99987413
#> [3,] -0.4440666 -0.5000000 -0.5539201 -0.6056097 -0.6548607 -0.70147489
#> [4,] -0.6056097 -0.5000000 -0.3863451 -0.2664738 -0.1423148 -0.01586596
#> [,39] [,40] [,41] [,42] [,43] [,44]
#> [1,] 0.6667690 0.6181590 0.5670599 0.5136774 0.4582265 0.4009305
#> [2,] -0.9938385 -0.9718116 -0.9341479 -0.8814534 -0.8145760 -0.7345917
#> [3,] -0.7452644 -0.7860531 -0.8236766 -0.8579834 -0.8888354 -0.9161085
#> [4,] 0.1108382 0.2357589 0.3568862 0.4722711 0.5800569 0.6785094
#> [,45] [,46] [,47] [,48] [,49] [,50]
#> [1,] 0.3420201 0.2817326 0.2203105 0.1580014 0.09505604 0.03172793
#> [2,] -0.6427876 -0.5406408 -0.4297949 -0.3120334 -0.18925124 -0.06342392
#> [3,] -0.9396926 -0.9594930 -0.9754298 -0.9874389 -0.99547192 -0.99949654
#> [4,] 0.7660444 0.8412535 0.9029265 0.9500711 0.98192870 0.99798668
#> [,51] [,52] [,53] [,54] [,55] [,56]
#> [1,] -0.03172793 -0.09505604 -0.1580014 -0.2203105 -0.2817326 -0.3420201
#> [2,] 0.06342392 0.18925124 0.3120334 0.4297949 0.5406408 0.6427876
#> [3,] -0.99949654 -0.99547192 -0.9874389 -0.9754298 -0.9594930 -0.9396926
#> [4,] 0.99798668 0.98192870 0.9500711 0.9029265 0.8412535 0.7660444
#> [,57] [,58] [,59] [,60] [,61] [,62]
#> [1,] -0.4009305 -0.4582265 -0.5136774 -0.5670599 -0.6181590 -0.6667690
#> [2,] 0.7345917 0.8145760 0.8814534 0.9341479 0.9718116 0.9938385
#> [3,] -0.9161085 -0.8888354 -0.8579834 -0.8236766 -0.7860531 -0.7452644
#> [4,] 0.6785094 0.5800569 0.4722711 0.3568862 0.2357589 0.1108382
#> [,63] [,64] [,65] [,66] [,67] [,68]
#> [1,] -0.71269417 -0.7557496 -0.7957618 -0.8325699 -0.8660254 -0.8959938
#> [2,] 0.99987413 0.9898214 0.9638422 0.9223543 0.8660254 0.7957618
#> [3,] -0.70147489 -0.6548607 -0.6056097 -0.5539201 -0.5000000 -0.4440666
#> [4,] -0.01586596 -0.1423148 -0.2664738 -0.3863451 -0.5000000 -0.6056097
#> [,69] [,70] [,71] [,72] [,73] [,74]
#> [1,] -0.9223543 -0.9450008 -0.9638422 -0.9788024 -0.9898214 -0.99685478
#> [2,] 0.7126942 0.6181590 0.5136774 0.4009305 0.2817326 0.15800140
#> [3,] -0.3863451 -0.3270680 -0.2664738 -0.2048067 -0.1423148 -0.07924996
#> [4,] -0.7014749 -0.7860531 -0.8579834 -0.9161085 -0.9594930 -0.98743889
#> [,75] [,76] [,77] [,78] [,79] [,80]
#> [1,] -0.99987413 -0.99886734 -0.9938385 -0.9848078 -0.9718116 -0.9549022
#> [2,] 0.03172793 -0.09505604 -0.2203105 -0.3420201 -0.4582265 -0.5670599
#> [3,] -0.01586596 0.04758192 0.1108382 0.1736482 0.2357589 0.2969204
#> [4,] -0.99949654 -0.99547192 -0.9754298 -0.9396926 -0.8888354 -0.8236766
#> [,81] [,82] [,83] [,84] [,85] [,86]
#> [1,] -0.9341479 -0.9096320 -0.8814534 -0.8497254 -0.8145760 -0.7761465
#> [2,] -0.6667690 -0.7557496 -0.8325699 -0.8959938 -0.9450008 -0.9788024
#> [3,] 0.3568862 0.4154150 0.4722711 0.5272255 0.5800569 0.6305527
#> [4,] -0.7452644 -0.6548607 -0.5539201 -0.4440666 -0.3270680 -0.2048067
#> [,87] [,88] [,89] [,90] [,91] [,92]
#> [1,] -0.73459171 -0.69007901 -0.6427876 -0.5929079 -0.5406408 -0.4861967
#> [2,] -0.99685478 -0.99886734 -0.9848078 -0.9549022 -0.9096320 -0.8497254
#> [3,] 0.67850941 0.72373404 0.7660444 0.8052703 0.8412535 0.8738494
#> [4,] -0.07924996 0.04758192 0.1736482 0.2969204 0.4154150 0.5272255
#> [,93] [,94] [,95] [,96] [,97] [,98]
#> [1,] -0.4297949 -0.3716625 -0.3120334 -0.2511480 -0.1892512 -0.1265925
#> [2,] -0.7761465 -0.6900790 -0.5929079 -0.4861967 -0.3716625 -0.2511480
#> [3,] 0.9029265 0.9283679 0.9500711 0.9679487 0.9819287 0.9919548
#> [4,] 0.6305527 0.7237340 0.8052703 0.8738494 0.9283679 0.9679487
#> [,99] [,100]
#> [1,] -0.06342392 -2.449294e-16
#> [2,] -0.12659245 -4.898587e-16
#> [3,] 0.99798668 1.000000e+00
#> [4,] 0.99195481 1.000000e+00
#>
#> attr(,"class")
#> [1] "fData"
#>
#> $fDList[[2]]
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 6.283185
#>
#> $h
#> [1] 0.06346652
#>
#> $P
#> [1] 100
#>
#> $N
#> [1] 4
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 0 0.1892512 0.3716625 0.5406408 0.6900790 0.8145760 0.90963200
#> [2,] 0 0.2511480 0.4861967 0.6900790 0.8497254 0.9549022 0.99886734
#> [3,] 1 0.9819287 0.9283679 0.8412535 0.7237340 0.5800569 0.41541501
#> [4,] 1 0.9679487 0.8738494 0.7237340 0.5272255 0.2969204 0.04758192
#> [,8] [,9] [,10] [,11] [,12] [,13]
#> [1,] 0.9718116 0.99886734 0.9898214 0.9450008 0.8660254 0.75574957
#> [2,] 0.9788024 0.89599377 0.7557496 0.5670599 0.3420201 0.09505604
#> [3,] 0.2357589 0.04758192 -0.1423148 -0.3270680 -0.5000000 -0.65486073
#> [4,] -0.2048067 -0.44406661 -0.6548607 -0.8236766 -0.9396926 -0.99547192
#> [,14] [,15] [,16] [,17] [,18] [,19]
#> [1,] 0.6181590 0.4582265 0.2817326 0.09505604 -0.09505604 -0.2817326
#> [2,] -0.1580014 -0.4009305 -0.6181590 -0.79576184 -0.92235429 -0.9898214
#> [3,] -0.7860531 -0.8888354 -0.9594930 -0.99547192 -0.99547192 -0.9594930
#> [4,] -0.9874389 -0.9161085 -0.7860531 -0.60560969 -0.38634513 -0.1423148
#> [,20] [,21] [,22] [,23] [,24] [,25]
#> [1,] -0.4582265 -0.6181590 -0.7557496 -0.8660254 -0.9450008 -0.9898214
#> [2,] -0.9938385 -0.9341479 -0.8145760 -0.6427876 -0.4297949 -0.1892512
#> [3,] -0.8888354 -0.7860531 -0.6548607 -0.5000000 -0.3270680 -0.1423148
#> [4,] 0.1108382 0.3568862 0.5800569 0.7660444 0.9029265 0.9819287
#> [,26] [,27] [,28] [,29] [,30] [,31]
#> [1,] -0.99886734 -0.9718116 -0.9096320 -0.8145760 -0.6900790 -0.5406408
#> [2,] 0.06342392 0.3120334 0.5406408 0.7345917 0.8814534 0.9718116
#> [3,] 0.04758192 0.2357589 0.4154150 0.5800569 0.7237340 0.8412535
#> [4,] 0.99798668 0.9500711 0.8412535 0.6785094 0.4722711 0.2357589
#> [,32] [,33] [,34] [,35] [,36] [,37]
#> [1,] -0.37166246 -0.1892512 6.432491e-16 0.1892512 0.3716625 0.5406408
#> [2,] 0.99987413 0.9638422 8.660254e-01 0.7126942 0.5136774 0.2817326
#> [3,] 0.92836793 0.9819287 1.000000e+00 0.9819287 0.9283679 0.8412535
#> [4,] -0.01586596 -0.2664738 -5.000000e-01 -0.7014749 -0.8579834 -0.9594930
#> [,38] [,39] [,40] [,41] [,42] [,43]
#> [1,] 0.69007901 0.8145760 0.9096320 0.9718116 0.99886734 0.9898214
#> [2,] 0.03172793 -0.2203105 -0.4582265 -0.6667690 -0.83256985 -0.9450008
#> [3,] 0.72373404 0.5800569 0.4154150 0.2357589 0.04758192 -0.1423148
#> [4,] -0.99949654 -0.9754298 -0.8888354 -0.7452644 -0.55392006 -0.3270680
#> [,44] [,45] [,46] [,47] [,48] [,49]
#> [1,] 0.94500082 0.8660254 0.7557496 0.6181590 0.4582265 0.2817326
#> [2,] -0.99685478 -0.9848078 -0.9096320 -0.7761465 -0.5929079 -0.3716625
#> [3,] -0.32706796 -0.5000000 -0.6548607 -0.7860531 -0.8888354 -0.9594930
#> [4,] -0.07924996 0.1736482 0.4154150 0.6305527 0.8052703 0.9283679
#> [,50] [,51] [,52] [,53] [,54] [,55]
#> [1,] 0.09505604 -0.09505604 -0.2817326 -0.4582265 -0.6181590 -0.7557496
#> [2,] -0.12659245 0.12659245 0.3716625 0.5929079 0.7761465 0.9096320
#> [3,] -0.99547192 -0.99547192 -0.9594930 -0.8888354 -0.7860531 -0.6548607
#> [4,] 0.99195481 0.99195481 0.9283679 0.8052703 0.6305527 0.4154150
#> [,56] [,57] [,58] [,59] [,60] [,61]
#> [1,] -0.8660254 -0.94500082 -0.9898214 -0.99886734 -0.9718116 -0.9096320
#> [2,] 0.9848078 0.99685478 0.9450008 0.83256985 0.6667690 0.4582265
#> [3,] -0.5000000 -0.32706796 -0.1423148 0.04758192 0.2357589 0.4154150
#> [4,] 0.1736482 -0.07924996 -0.3270680 -0.55392006 -0.7452644 -0.8888354
#> [,62] [,63] [,64] [,65] [,66] [,67]
#> [1,] -0.8145760 -0.69007901 -0.5406408 -0.3716625 -0.1892512 1.286498e-15
#> [2,] 0.2203105 -0.03172793 -0.2817326 -0.5136774 -0.7126942 -8.660254e-01
#> [3,] 0.5800569 0.72373404 0.8412535 0.9283679 0.9819287 1.000000e+00
#> [4,] -0.9754298 -0.99949654 -0.9594930 -0.8579834 -0.7014749 -5.000000e-01
#> [,68] [,69] [,70] [,71] [,72] [,73]
#> [1,] 0.1892512 0.37166246 0.5406408 0.6900790 0.8145760 0.9096320
#> [2,] -0.9638422 -0.99987413 -0.9718116 -0.8814534 -0.7345917 -0.5406408
#> [3,] 0.9819287 0.92836793 0.8412535 0.7237340 0.5800569 0.4154150
#> [4,] -0.2664738 -0.01586596 0.2357589 0.4722711 0.6785094 0.8412535
#> [,74] [,75] [,76] [,77] [,78] [,79]
#> [1,] 0.9718116 0.99886734 0.9898214 0.9450008 0.8660254 0.7557496
#> [2,] -0.3120334 -0.06342392 0.1892512 0.4297949 0.6427876 0.8145760
#> [3,] 0.2357589 0.04758192 -0.1423148 -0.3270680 -0.5000000 -0.6548607
#> [4,] 0.9500711 0.99798668 0.9819287 0.9029265 0.7660444 0.5800569
#> [,80] [,81] [,82] [,83] [,84] [,85]
#> [1,] 0.6181590 0.4582265 0.2817326 0.09505604 -0.09505604 -0.2817326
#> [2,] 0.9341479 0.9938385 0.9898214 0.92235429 0.79576184 0.6181590
#> [3,] -0.7860531 -0.8888354 -0.9594930 -0.99547192 -0.99547192 -0.9594930
#> [4,] 0.3568862 0.1108382 -0.1423148 -0.38634513 -0.60560969 -0.7860531
#> [,86] [,87] [,88] [,89] [,90] [,91]
#> [1,] -0.4582265 -0.6181590 -0.75574957 -0.8660254 -0.9450008 -0.9898214
#> [2,] 0.4009305 0.1580014 -0.09505604 -0.3420201 -0.5670599 -0.7557496
#> [3,] -0.8888354 -0.7860531 -0.65486073 -0.5000000 -0.3270680 -0.1423148
#> [4,] -0.9161085 -0.9874389 -0.99547192 -0.9396926 -0.8236766 -0.6548607
#> [,92] [,93] [,94] [,95] [,96] [,97]
#> [1,] -0.99886734 -0.9718116 -0.90963200 -0.8145760 -0.6900790 -0.5406408
#> [2,] -0.89599377 -0.9788024 -0.99886734 -0.9549022 -0.8497254 -0.6900790
#> [3,] 0.04758192 0.2357589 0.41541501 0.5800569 0.7237340 0.8412535
#> [4,] -0.44406661 -0.2048067 0.04758192 0.2969204 0.5272255 0.7237340
#> [,98] [,99] [,100]
#> [1,] -0.3716625 -0.1892512 -7.347881e-16
#> [2,] -0.4861967 -0.2511480 -9.797174e-16
#> [3,] 0.9283679 0.9819287 1.000000e+00
#> [4,] 0.8738494 0.9679487 1.000000e+00
#>
#> attr(,"class")
#> [1] "fData"
#>
#>
#> attr(,"class")
#> [1] "mfData"