NITPicker

Daphne Ezer

2018-04-20

Often, researchers will conduct a few high-resolution time course experiments (or densely sample points along a spatial axis), but then they must select a subset of points to sample in follow-up experiments due to financial constraints. NITPicker is a tool to select the best points to subsample. We present three different definitions of what constitutes a `good’ set of time points:

Please note that this is not a very fast value to compute– it may take a few hours to complete on a large dataset. The precise definition and motivation for these three criteria can be found at: https://doi.org/10.1101/301796

Please note that this package relies heavily on the fdasrvf package, which is used to generate probability distributions of curves, based on a set of example functions.

References

Please cite the following if you use this R package:

Ezer, D. and Keir J.C. Selection of time points for costly experiments: a comparison between human intuition and computer-aided experimental design. bioarxiv, :10.1101/301796 (2018).


It might also be advisable to cite this paper, which presents the fdasrvf package which is an important part of this project:

Tucker, J. D., Wu, W., Srivastava, A., Generative Models for Function Data using Phase and Amplitude Separation, Computational Statistics and Data Analysis (2012), 10.1016/j.csda.2012.12.001.

For more background on why it might be useful to minimise the L2-error for finding optimal time points to sample, please see:

Michael Kleyman, Emre Sefer, Teodora Nicola, Celia Espinoza, Divya Chhabra, James S Hagood, Naftali Kaminski, Namasivayam Ambalavanan, Ziv Bar-Joseph. Selecting the most appropriate time points to profile in high-throughput studies. eLife 2017;6:e18541 (2017).

Demo of F1

In this example, we try to find 4 months to subsample that will let us estimate the shape of the curves as accurately as possible (minimise L2-error). In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
#> Loading required package: splines
#> Loading required package: Matrix
#> 
#> Attaching package: 'fda'
#> The following object is masked from 'package:graphics':
#> 
#>     matplot
library(NITPicker)
#> Loading required package: fdasrvf
#> Loading required package: fda.usc
#> Loading required package: MASS
#> Loading required package: mgcv
#> Loading required package: nlme
#> This is mgcv 1.8-23. For overview type 'help("mgcv-package")'.
#> Loading required package: rpart
 mat=CanadianWeather$monthlyTemp #load data - a matrix with 12 rows, representing months (time); and 35 columns, representing cities (experiments)
 a=findPathF1(c(1:12), mat, 4, numPerts=3) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 35 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> updating step: r=12
#> updating step: r=13
#> updating step: r=14
#> updating step: r=15
#> updating step: r=16
#> updating step: r=17
#> updating step: r=18
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>          [,1] [,2]
#> [1,] 3.621742  Inf
#> [2,]      Inf    0
#> [3,]      Inf  Inf
#> [4,]      Inf  Inf
#> [5,]      Inf  Inf
#>          [,1]     [,2]     [,3]
#> [1,] 133.3451      Inf      Inf
#> [2,]      Inf 5.668084 3.621742
#> [3,]      Inf      Inf 0.000000
#> [4,]      Inf      Inf      Inf
#> [5,]      Inf      Inf      Inf
#>          [,1]    [,2]      [,3]       [,4]
#> [1,] 748.3137     Inf       Inf        Inf
#> [2,]      Inf 28.1367 4.5472787 133.345107
#> [3,]      Inf     Inf 0.9255366   3.621742
#> [4,]      Inf     Inf       Inf   0.000000
#> [5,]      Inf     Inf       Inf        Inf
#>          [,1]     [,2]     [,3]        [,4]        [,5]
#> [1,] 2263.264      Inf      Inf         Inf         Inf
#> [2,]      Inf 69.35294 8.477366 133.6449597 748.3137091
#> [3,]      Inf      Inf 4.855624   3.9215948   4.5472787
#> [4,]      Inf      Inf      Inf   0.2998527   0.9255366
#> [5,]      Inf      Inf      Inf         Inf   0.0000000
#>          [,1]     [,2]      [,3]       [,4]        [,5]         [,6]
#> [1,] 4825.478      Inf       Inf        Inf         Inf          Inf
#> [2,]      Inf 112.3561 13.219538 134.575208 748.4339064 2263.2644594
#> [3,]      Inf      Inf  9.597795   4.851843   4.6674760    8.4773663
#> [4,]      Inf      Inf       Inf   1.230101   1.0457339    3.9215948
#> [5,]      Inf      Inf       Inf        Inf   0.1201973    0.2998527
#>          [,1]     [,2]     [,3]      [,4]       [,5]        [,6]
#> [1,] 7404.123      Inf      Inf       Inf        Inf         Inf
#> [2,]      Inf 99.70077 13.75664 143.37729 755.372079 2265.390453
#> [3,]      Inf      Inf 10.13489  13.65392  11.605649   10.603359
#> [4,]      Inf      Inf      Inf  10.03218   7.983907    6.047588
#> [5,]      Inf      Inf      Inf       Inf   7.058370    2.425846
#>             [,7]
#> [1,]         Inf
#> [2,] 4825.478228
#> [3,]   13.219538
#> [4,]    4.667476
#> [5,]    1.045734
#>          [,1]     [,2]     [,3]     [,4]     [,5]       [,6]       [,7]
#> [1,] 7056.881      Inf      Inf      Inf      Inf        Inf        Inf
#> [2,]      Inf 178.6286 223.3720 344.0645 893.9640 2330.78733 4839.28299
#> [3,]      Inf      Inf 219.7503 214.3412 150.1976   76.00024   27.02430
#> [4,]      Inf      Inf      Inf 210.7194 146.5758   71.44446   18.47224
#> [5,]      Inf      Inf      Inf      Inf 145.6503   67.82272   14.85050
#>             [,8]
#> [1,]         Inf
#> [2,] 7404.123489
#> [3,]   13.756635
#> [4,]   10.134893
#> [5,]    4.667476
#>          [,1]     [,2]     [,3]     [,4]      [,5]      [,6]      [,7]
#> [1,] 4318.885      Inf      Inf      Inf       Inf       Inf       Inf
#> [2,]      Inf 1236.897 1384.188 1303.690 1553.1187 2684.8633 4959.6385
#> [3,]      Inf      Inf 1380.566 1173.967  809.3522  430.0762  147.3798
#> [4,]      Inf      Inf      Inf 1170.345  805.7305  425.5204  138.8277
#> [5,]      Inf      Inf      Inf      Inf  804.8050  421.8987  135.2060
#>            [,8]       [,9]
#> [1,]        Inf        Inf
#> [2,] 7417.24509 7056.88056
#> [3,]   26.87823  178.62863
#> [4,]   23.25649   13.75664
#> [5,]   17.78907   10.13489
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]      [,7]
#> [1,] 3082.905      Inf      Inf      Inf      Inf      Inf       Inf
#> [2,]      Inf 3679.203 3727.011 3162.400 2821.955 3386.232 5226.4995
#> [3,]      Inf      Inf 3723.389 3032.677 2078.188 1131.445  414.2408
#> [4,]      Inf      Inf      Inf 3029.055 2074.567 1126.889  405.6887
#> [5,]      Inf      Inf      Inf      Inf 2073.641 1123.267  402.0670
#>            [,8]       [,9]      [,10]
#> [1,]        Inf        Inf        Inf
#> [2,] 7463.72923 7058.45530 4318.88463
#> [3,]   73.36237  180.20337 1236.89744
#> [4,]   69.74063   15.33138   26.87823
#> [5,]   64.27322   11.70963   13.75664
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]      [,7]
#> [1,] 4690.557      Inf      Inf      Inf      Inf      Inf       Inf
#> [2,]      Inf 6935.959 6694.838 5451.350 4347.958 4211.230 5533.5129
#> [3,]      Inf      Inf 6691.216 5321.627 3604.192 1956.442  721.2543
#> [4,]      Inf      Inf      Inf 5318.005 3600.570 1951.887  712.7022
#> [5,]      Inf      Inf      Inf      Inf 3599.644 1948.265  709.0805
#>           [,8]       [,9]      [,10]      [,11]
#> [1,]       Inf        Inf        Inf        Inf
#> [2,] 7516.2068 7060.16373 4318.97264 3082.90475
#> [3,]  125.8399  181.91180 1236.98545 2821.95469
#> [4,]  122.2182   17.03980   26.96625   73.36237
#> [5,]  116.7508   13.41806   13.84465   15.33138
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,] 9869.331      Inf      Inf      Inf      Inf      Inf      Inf
#> [2,]      Inf 11175.46 10458.46 8314.885 6242.657 5240.497 5931.348
#> [3,]      Inf      Inf 10454.84 8185.161 5498.891 2985.710 1119.089
#> [4,]      Inf      Inf      Inf 8181.539 5495.269 2981.154 1110.537
#> [5,]      Inf      Inf      Inf      Inf 5494.344 2977.533 1106.915
#>           [,8]       [,9]      [,10]      [,11]     [,12]
#> [1,]       Inf        Inf        Inf        Inf       Inf
#> [2,] 7595.4135 7066.60905 4321.06485 3084.02904 4690.5565
#> [3,]  205.0467  188.35712 1239.07766 2823.07898 3082.9047
#> [4,]  201.4249   23.48513   29.05846   74.48666  125.8399
#> [5,]  195.9575   19.86338   15.93686   16.45567   17.0398
#>      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]      [,8]
#> [1,]    0      Inf      Inf      Inf      Inf      Inf      Inf       Inf
#> [2,]  Inf 13072.04 11191.11 6930.932 3972.131 3819.494 6708.756 10488.089
#> [3,]  Inf      Inf 11187.48 6801.208 3228.365 1564.707 1896.497  3097.723
#> [4,]  Inf      Inf      Inf 6797.587 3224.743 1560.151 1887.945  3094.101
#> [5,]  Inf      Inf      Inf      Inf 3223.817 1556.529 1884.323  3088.633
#>          [,9]    [,10]     [,11]     [,12]      [,13]
#> [1,]      Inf      Inf       Inf       Inf        Inf
#> [2,] 9959.539 5774.459 3509.7067 4751.3009 9869.33147
#> [3,] 3081.287 2692.472 3248.7567 3143.6491 3084.02904
#> [4,] 2916.415 1482.453  500.1644  186.5843  188.35712
#> [5,] 2912.793 1469.331  442.1334   77.7842   23.48513
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    2    2    0    0
#>  [4,]    0    2    2    3    0
#>  [5,]    0    2    3    3    4
#>  [6,]    0    2    4    4    4
#>  [7,]    0    2    2    6    6
#>  [8,]    0    1    7    7    7
#>  [9,]    0    1    7    8    8
#> [10,]    0    4    7    8    8
#> [11,]    0   10    7    8    8
#> [12,]    0   10    8    8    9
#> [13,]    0   10    5   11   12
#>              [,1]        [,2]         [,3]        [,4]       [,5]
#>  [1,]    0.000000         Inf          Inf         Inf        Inf
#>  [2,]    3.621742    0.000000          Inf         Inf        Inf
#>  [3,]  133.345107    3.621742    0.0000000         Inf        Inf
#>  [4,]  748.313709    4.547279    0.9255366   0.0000000        Inf
#>  [5,] 2263.264459    8.477366    3.9215948   0.2998527  0.0000000
#>  [6,] 4825.478228   13.219538    4.6674760   1.0457339  0.1201973
#>  [7,] 7404.123489   13.756635   10.1348930   4.6674760  1.0457339
#>  [8,] 7056.880563  178.628628   13.7566351  10.1348930  4.6674760
#>  [9,] 4318.884625 1236.897436   26.8782331  13.7566351 10.1348930
#> [10,] 3082.904746 2821.954693   73.3623746  15.3313760 11.7096340
#> [11,] 4690.556549 3082.904746  125.8399416  17.0398025 13.4180604
#> [12,] 9869.331468 3084.029036  188.3571201  23.4851271 15.9368638
#> [13,]    0.000000 3509.706729 1564.7069898 186.5843393 23.4851271
 print(a) #indices of months to select for follow-up experiments
#> [1]  2  7  8 12
 print(rownames(CanadianWeather$monthlyTemp)[a]) #month names selected
#> [1] "Feb" "Jul" "Aug" "Dec"

Demo of F2

In this example, we consider Canadian cities to be different experimental conditions, and we consider Resolute, Canada to be the control condition. We want to find a set of points that will enable us to estimate the profile of the difference in temperature between Resolute and other cities in Canada. In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
library(NITPicker)
mat=CanadianWeather$monthlyTemp #load data - a matrix with 12 rows, representing months (time); and 35 columns, representing cities (experiments)
 y=CanadianWeather$monthlyTemp[,"Resolute"]
a=findPathF2(c(1:12), y, mat, 4, numPerts=3) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 35 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> updating step: r=12
#> updating step: r=13
#> updating step: r=14
#> updating step: r=15
#> updating step: r=16
#> updating step: r=17
#> updating step: r=18
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>          [,1] [,2]
#> [1,] 6.355158  Inf
#> [2,]      Inf    0
#> [3,]      Inf  Inf
#> [4,]      Inf  Inf
#> [5,]      Inf  Inf
#>          [,1]     [,2]     [,3]
#> [1,] 118.4347      Inf      Inf
#> [2,]      Inf 2.027377 6.355158
#> [3,]      Inf      Inf 0.000000
#> [4,]      Inf      Inf      Inf
#> [5,]      Inf      Inf      Inf
#>          [,1]     [,2]      [,3]       [,4]
#> [1,] 231.2051      Inf       Inf        Inf
#> [2,]      Inf 9.411251 12.264336 118.434700
#> [3,]      Inf      Inf  5.909178   2.027377
#> [4,]      Inf      Inf       Inf   0.000000
#> [5,]      Inf      Inf       Inf        Inf
#>          [,1]    [,2]     [,3]      [,4]       [,5]
#> [1,] 423.7435     Inf      Inf       Inf        Inf
#> [2,]      Inf 196.328 123.5027 137.94313 231.205142
#> [3,]      Inf     Inf 117.1476  21.53580   9.411251
#> [4,]      Inf     Inf      Inf  19.50843   2.027377
#> [5,]      Inf     Inf      Inf       Inf   0.000000
#>          [,1]     [,2]     [,3]      [,4]        [,5]       [,6]
#> [1,] 1389.967      Inf      Inf       Inf         Inf        Inf
#> [2,]      Inf 519.9946 296.2477 168.00575 231.3226847 423.743512
#> [3,]      Inf      Inf 289.8925  51.59843   9.5287936 123.502712
#> [4,]      Inf      Inf      Inf  49.57105   2.1449193   9.411251
#> [5,]      Inf      Inf      Inf       Inf   0.1175425   2.027377
#>        [,1]     [,2]     [,3]      [,4]      [,5]       [,6]        [,7]
#> [1,] 2114.2      Inf      Inf       Inf       Inf        Inf         Inf
#> [2,]    Inf 645.3614 343.2179 166.08117 247.52608 428.780044 1389.967041
#> [3,]    Inf      Inf 336.8628  49.67385  25.73219 128.539243  168.005755
#> [4,]    Inf      Inf      Inf  47.64647  18.34832  14.447782    9.528794
#> [5,]    Inf      Inf      Inf       Inf  16.32094   7.063908    2.144919
#>          [,1]     [,2]     [,3]     [,4]     [,5]      [,6]        [,7]
#> [1,] 1789.303      Inf      Inf      Inf      Inf       Inf         Inf
#> [2,]      Inf 555.4289 309.5598 229.3602 373.0257 480.75672 1396.430905
#> [3,]      Inf      Inf 303.2047 112.9529 151.2318 180.51592  174.469618
#> [4,]      Inf      Inf      Inf 110.9255 143.8479  66.42446   15.992657
#> [5,]      Inf      Inf      Inf      Inf 141.8205  59.04059    8.608783
#>             [,8]
#> [1,]         Inf
#> [2,] 2114.199861
#> [3,]  166.081168
#> [4,]   25.732190
#> [5,]    9.528794
#>          [,1]     [,2]     [,3]     [,4]     [,5]     [,6]       [,7]
#> [1,] 1144.156      Inf      Inf      Inf      Inf      Inf        Inf
#> [2,]      Inf 610.4569 454.5879 499.8046 670.7499 613.9047 1423.62736
#> [3,]      Inf      Inf 448.2328 383.3972 448.9560 313.6639  201.66608
#> [4,]      Inf      Inf      Inf 381.3699 441.5721 199.5724   43.18912
#> [5,]      Inf      Inf      Inf      Inf 439.5447 192.1886   35.80524
#>            [,8]       [,9]
#> [1,]        Inf        Inf
#> [2,] 2115.68638 1789.30335
#> [3,]  167.56769  229.36024
#> [4,]   27.21871  112.95292
#> [5,]   11.01532   15.99266
#>         [,1]    [,2]     [,3]     [,4]     [,5]     [,6]      [,7]
#> [1,] 848.888     Inf      Inf      Inf      Inf      Inf       Inf
#> [2,]     Inf 999.461 953.8747 1148.214 1284.524 917.3409 1513.6125
#> [3,]     Inf     Inf 947.5196 1031.807 1062.730 617.1001  291.6512
#> [4,]     Inf     Inf      Inf 1029.779 1055.346 503.0087  133.1742
#> [5,]     Inf     Inf      Inf      Inf 1053.319 495.6248  125.7904
#>            [,8]       [,9]      [,10]
#> [1,]        Inf        Inf        Inf
#> [2,] 2131.31746 1791.46860 1144.15587
#> [3,]  183.19876  231.52549  454.58793
#> [4,]   42.84978  115.11817  167.56769
#> [5,]   26.64639   18.15791   27.21871
#>          [,1]     [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
#> [1,] 1176.465      Inf      Inf      Inf      Inf       Inf       Inf
#> [2,]      Inf 1417.835 1386.389 1616.562 1682.371 1078.0452 1539.6483
#> [3,]      Inf      Inf 1380.033 1500.155 1460.577  777.8044  317.6871
#> [4,]      Inf      Inf      Inf 1498.128 1453.193  663.7129  159.2101
#> [5,]      Inf      Inf      Inf      Inf 1451.166  656.3291  151.8262
#>            [,8]       [,9]     [,10]     [,11]
#> [1,]        Inf        Inf       Inf       Inf
#> [2,] 2130.68494 1792.20633 1147.7862 848.88796
#> [3,]  182.56625  232.26322  458.2182 917.34093
#> [4,]   42.21727  115.85590  171.1980 183.19876
#> [5,]   26.01387   18.89564   30.8490  42.84978
#>         [,1]   [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
#> [1,] 1515.19    Inf      Inf      Inf      Inf       Inf       Inf
#> [2,]     Inf 1660.6 1532.703 1651.363 1651.141 1021.3012 1537.3541
#> [3,]     Inf    Inf 1526.348 1534.955 1429.347  721.0604  315.3928
#> [4,]     Inf    Inf      Inf 1532.928 1421.963  606.9689  156.9159
#> [5,]     Inf    Inf      Inf      Inf 1419.936  599.5851  149.5320
#>            [,8]       [,9]      [,10]     [,11]      [,12]
#> [1,]        Inf        Inf        Inf       Inf        Inf
#> [2,] 2195.32323 1862.91421 1198.24912 856.41686 1176.46550
#> [3,]  247.20454  302.97110  508.68118 924.86982  848.88796
#> [4,]  106.85556  186.56378  221.66094 190.72766  182.56625
#> [5,]   90.65216   89.60352   81.31196  50.37868   42.21727
#>      [,1]     [,2]     [,3]     [,4]     [,5]      [,6]      [,7]
#> [1,]    0      Inf      Inf      Inf      Inf       Inf       Inf
#> [2,]  Inf 1881.577 1798.239 2477.160 2488.608 1031.2624 1835.1374
#> [3,]  Inf      Inf 1791.884 2360.753 2266.814  731.0216  613.1761
#> [4,]  Inf      Inf      Inf 2358.725 2259.430  616.9301  454.6991
#> [5,]  Inf      Inf      Inf      Inf 2257.403  609.5463  447.3152
#>           [,8]      [,9]     [,10]     [,11]      [,12]     [,13]
#> [1,]       Inf       Inf       Inf       Inf        Inf       Inf
#> [2,] 2862.6417 2381.4535 1422.4112 890.20539 1187.14978 1515.1903
#> [3,]  914.5230  821.5104  732.8432 958.65835  859.57225  856.4169
#> [4,]  774.1741  705.1031  445.8230 224.51619  193.25053  247.2045
#> [5,]  757.9707  608.1428  305.4740  84.16721   52.90155  106.8556
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    1    2    0    0
#>  [4,]    0    1    3    3    0
#>  [5,]    0    2    4    4    4
#>  [6,]    0    3    4    4    4
#>  [7,]    0    3    4    6    6
#>  [8,]    0    3    3    6    6
#>  [9,]    0    2    7    7    7
#> [10,]    0    5    7    7    8
#> [11,]    0   10    7    7    8
#> [12,]    0   10    7    7   11
#> [13,]    0   10    6   11   11
#>              [,1]       [,2]       [,3]       [,4]       [,5]
#>  [1,]    0.000000        Inf        Inf        Inf        Inf
#>  [2,]    6.355158   0.000000        Inf        Inf        Inf
#>  [3,]  118.434700   2.027377   0.000000        Inf        Inf
#>  [4,]  231.205142   9.411251   2.027377   0.000000        Inf
#>  [5,]  423.743512 123.502712   9.411251   2.027377  0.0000000
#>  [6,] 1389.967041 168.005755   9.528794   2.144919  0.1175425
#>  [7,] 2114.199861 166.081168  25.732190   9.528794  2.1449193
#>  [8,] 1789.303348 229.360240 112.952917  15.992657  8.6087826
#>  [9,] 1144.155870 454.587928 167.567692  27.218713 11.0153172
#> [10,]  848.887963 917.340929 183.198763  42.849784 18.1579119
#> [11,] 1176.465499 848.887963 182.566250  42.217271 18.8956367
#> [12,] 1515.190253 856.416855 247.204539 106.855560 42.2172710
#> [13,]    0.000000 890.205386 613.176076 193.250533 52.9015540
print(a) #indices of months to select for follow-up experiments
#> [1]  1  4  7 11
print(rownames(CanadianWeather$monthlyTemp)[a])
#> [1] "Jan" "Apr" "Jul" "Nov"

Demo of F3

In this example, we try to identify points that can predict the shape of the curve of the difference between the temperatures of Canadian cities that are along the Atlantic with those that are Continental– however, we don’t care too much about sampling time points where there is lots of noise, so we normalise this by the variance at each point.

In this case, we sample only 3 example curves from the distribution of curves when estimating the integral– this should be much higher (100 curves is usually suitable), but we make it 3 here to speed up loading the vignette.

Note that the tables that are printed as the evaluation are the optimisation tables that are used as part of the NITPicker algorithm’s dynamic programming algorithm.

library(fda)
library(NITPicker)
#Set up data:
atlanticCities=which(CanadianWeather$region[as.character(colnames(CanadianWeather$monthlyTemp))]=="Atlantic")
 matAtlantic=CanadianWeather$monthlyTemp[, names(atlanticCities)]
 
 continentalCities=which(CanadianWeather$region[as.character(colnames(CanadianWeather$monthlyTemp))]=="Continental")
 matContinental=CanadianWeather$monthlyTemp[, names(continentalCities)]
 
 #find a set of points that helps capture the difference between Atlantic and Continental cities, normalised by the variance
 a=findPathF3(c(1:12),  matAtlantic,  matContinental, 4, numPerts=3) #find a set of points that help predict the shape of the curve
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 15 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 12 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> lambda =   0.0 
#> 
#> Initializing...
#> Computing Karcher mean of 3 functions in SRSF space...
#> updating step: r=1
#> updating step: r=2
#> updating step: r=3
#> updating step: r=4
#> updating step: r=5
#> updating step: r=6
#> updating step: r=7
#> updating step: r=8
#> updating step: r=9
#> updating step: r=10
#> updating step: r=11
#> updating step: r=12
#> updating step: r=13
#> updating step: r=14
#> updating step: r=15
#> updating step: r=16
#> updating step: r=17
#>      [,1]
#> [1,]    0
#> [2,]  Inf
#> [3,]  Inf
#> [4,]  Inf
#> [5,]  Inf
#>            [,1] [,2]
#> [1,] 0.01085616  Inf
#> [2,]        Inf    0
#> [3,]        Inf  Inf
#> [4,]        Inf  Inf
#> [5,]        Inf  Inf
#>           [,1]         [,2]       [,3]
#> [1,] 0.0882301          Inf        Inf
#> [2,]       Inf 4.398408e-06 0.01085616
#> [3,]       Inf          Inf 0.00000000
#> [4,]       Inf          Inf        Inf
#> [5,]       Inf          Inf        Inf
#>           [,1]         [,2]         [,3]         [,4]
#> [1,] 0.2954144          Inf          Inf          Inf
#> [2,]       Inf 1.226947e-05 1.085776e-02 8.823010e-02
#> [3,]       Inf          Inf 1.607228e-06 4.398408e-06
#> [4,]       Inf          Inf          Inf 0.000000e+00
#> [5,]       Inf          Inf          Inf          Inf
#>           [,1]         [,2]         [,3]         [,4]         [,5]
#> [1,] 0.6853104          Inf          Inf          Inf          Inf
#> [2,]       Inf 4.722347e-05 1.087729e-02 8.823336e-02 2.954144e-01
#> [3,]       Inf          Inf 2.112856e-05 7.663471e-06 1.226947e-05
#> [4,]       Inf          Inf          Inf 3.265062e-06 1.607228e-06
#> [5,]       Inf          Inf          Inf          Inf 0.000000e+00
#>          [,1]         [,2]         [,3]         [,4]         [,5]
#> [1,] 1.294239          Inf          Inf          Inf          Inf
#> [2,]      Inf 0.0002712687 0.0110306359 8.828748e-02 2.954240e-01
#> [3,]      Inf          Inf 0.0001744783 6.178628e-05 2.187124e-05
#> [4,]      Inf          Inf          Inf 5.738787e-05 1.120900e-05
#> [5,]      Inf          Inf          Inf          Inf 9.601768e-06
#>              [,6]
#> [1,]          Inf
#> [2,] 6.853104e-01
#> [3,] 4.722347e-05
#> [4,] 7.663471e-06
#> [5,] 1.607228e-06
#>         [,1]        [,2]         [,3]         [,4]         [,5]
#> [1,] 2.15068         Inf          Inf          Inf          Inf
#> [2,]     Inf 0.001250506 0.0117628505 0.0886603751 0.2955652136
#> [3,]     Inf         Inf 0.0009066929 0.0004346769 0.0001630451
#> [4,]     Inf         Inf          Inf 0.0004302785 0.0001523828
#> [5,]     Inf         Inf          Inf          Inf 0.0001507756
#>              [,6]         [,7]
#> [1,]          Inf          Inf
#> [2,] 6.853353e-01 1.294239e+00
#> [3,] 7.220059e-05 2.712687e-04
#> [4,] 3.264059e-05 2.187124e-05
#> [5,] 2.658435e-05 7.663471e-06
#>          [,1]        [,2]        [,3]         [,4]         [,5]
#> [1,] 3.369037         Inf         Inf          Inf          Inf
#> [2,]      Inf 0.002506565 0.012575216 0.0890486652 0.2957251227
#> [3,]      Inf         Inf 0.001719058 0.0008229670 0.0003229542
#> [4,]      Inf         Inf         Inf 0.0008185686 0.0003122919
#> [5,]      Inf         Inf         Inf          Inf 0.0003106847
#>              [,6]         [,7]         [,8]
#> [1,]          Inf          Inf          Inf
#> [2,] 6.853942e-01 1.294280e+00 2.150680e+00
#> [3,] 1.310418e-04 3.125521e-04 1.250506e-03
#> [4,] 9.148183e-05 6.315459e-05 7.220059e-05
#> [5,] 8.542558e-05 4.894682e-05 2.187124e-05
#>          [,1]        [,2]        [,3]        [,4]        [,5]         [,6]
#> [1,] 4.920554         Inf         Inf         Inf         Inf          Inf
#> [2,]      Inf 0.006144414 0.015137421 0.090566118 0.296536769 0.6857530711
#> [3,]      Inf         Inf 0.004281264 0.002340420 0.001134601 0.0004899286
#> [4,]      Inf         Inf         Inf 0.002336021 0.001123938 0.0004503686
#> [5,]      Inf         Inf         Inf         Inf 0.001122331 0.0004443124
#>              [,7]         [,8]         [,9]
#> [1,]          Inf          Inf          Inf
#> [2,] 1.2944146353 2.150698e+00 3.369037e+00
#> [3,] 0.0004470093 1.268247e-03 2.506565e-03
#> [4,] 0.0001976118 8.994168e-05 1.310418e-04
#> [5,] 0.0001834041 3.961232e-05 6.315459e-05
#>          [,1]       [,2]       [,3]       [,4]        [,5]        [,6]
#> [1,] 6.422067        Inf        Inf        Inf         Inf         Inf
#> [2,]      Inf 0.02249463 0.02752082 0.09898234 0.301824258 0.688765118
#> [3,]      Inf        Inf 0.01666466 0.01075664 0.006422090 0.003501975
#> [4,]      Inf        Inf        Inf 0.01075225 0.006411428 0.003462415
#> [5,]      Inf        Inf        Inf        Inf 0.006409820 0.003456359
#>             [,7]         [,8]         [,9]        [,10]
#> [1,]         Inf          Inf          Inf          Inf
#> [2,] 1.296066128 2.1515862802 3.3692717542 4.920554e+00
#> [3,] 0.002098502 0.0021567557 0.0027416657 6.144414e-03
#> [4,] 0.001849105 0.0009784506 0.0003661422 4.470093e-04
#> [5,] 0.001834897 0.0009281213 0.0002982550 8.994168e-05
#>          [,1]      [,2]       [,3]       [,4]       [,5]       [,6]
#> [1,] 7.029903       Inf        Inf        Inf        Inf        Inf
#> [2,]      Inf 0.1141843 0.10234348 0.15672151 0.34456938 0.71903299
#> [3,]      Inf       Inf 0.09148732 0.06849581 0.04916722 0.03376984
#> [4,]      Inf       Inf        Inf 0.06849141 0.04915655 0.03373028
#> [5,]      Inf       Inf        Inf        Inf 0.04915495 0.03372423
#>            [,7]       [,8]        [,9]       [,10]        [,11]
#> [1,]        Inf        Inf         Inf         Inf          Inf
#> [2,] 1.31667277 2.16475382 3.375170083 4.921719820 6.4220669647
#> [3,] 0.02270514 0.01532429 0.008639994 0.007310587 0.0224946338
#> [4,] 0.02245574 0.01414599 0.006264471 0.001613182 0.0020985021
#> [5,] 0.02244154 0.01409566 0.006196584 0.001256115 0.0003661422
#>          [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
#> [1,] 5.329122       Inf       Inf       Inf       Inf       Inf       Inf
#> [2,]      Inf 0.6969646 0.5992045 0.5668602 0.6734905 0.9740162 1.5063195
#> [3,]      Inf       Inf 0.5883483 0.4786345 0.3780883 0.2887530 0.2123519
#> [4,]      Inf       Inf       Inf 0.4786301 0.3780776 0.2887135 0.2121025
#> [5,]      Inf       Inf       Inf       Inf 0.3780760 0.2887074 0.2120883
#>           [,8]       [,9]      [,10]       [,11]       [,12]
#> [1,]       Inf        Inf        Inf         Inf         Inf
#> [2,] 2.2971194 3.45151528 4.95321273 6.428421120 7.029902896
#> [3,] 0.1476898 0.08498519 0.03880350 0.028848789 0.102343482
#> [4,] 0.1465115 0.08260967 0.03310610 0.008452658 0.007310587
#> [5,] 0.1464612 0.08254178 0.03274903 0.006720298 0.001613182
#>      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]      [,8]
#> [1,]    0      Inf      Inf      Inf      Inf      Inf      Inf       Inf
#> [2,]  Inf 11.88921 8.603930 6.010222 4.166324 3.056789 2.629357 2.8110388
#> [3,]  Inf      Inf 8.593074 5.921996 3.870922 2.371525 1.335389 0.6616093
#> [4,]  Inf      Inf      Inf 5.921992 3.870911 2.371486 1.335140 0.6604310
#> [5,]  Inf      Inf      Inf      Inf 3.870909 2.371480 1.335126 0.6603806
#>           [,9]      [,10]       [,11]      [,12]       [,13]
#> [1,]       Inf        Inf         Inf        Inf         Inf
#> [2,] 3.6089103 4.96819152 6.430026738 7.03848773 5.329122207
#> [3,] 0.2423802 0.05378229 0.030454407 0.11092832 0.566860224
#> [4,] 0.2400047 0.04808488 0.010058276 0.01589542 0.028848789
#> [5,] 0.2399368 0.04772782 0.008325916 0.01019802 0.007310587
#>       [,1] [,2] [,3] [,4] [,5]
#>  [1,]    0    0    0    0    0
#>  [2,]    0    1    0    0    0
#>  [3,]    0    1    2    0    0
#>  [4,]    0    1    2    3    0
#>  [5,]    0    1    3    4    4
#>  [6,]    0    1    4    5    5
#>  [7,]    0    1    5    6    6
#>  [8,]    0    1    5    6    7
#>  [9,]    0    1    6    7    7
#> [10,]    0    1    6    8    9
#> [11,]    0    2    9    9   10
#> [12,]    0    3   10   11   11
#> [13,]    0    6   10   10   12
#>             [,1]         [,2]         [,3]         [,4]         [,5]
#>  [1,] 0.00000000          Inf          Inf          Inf          Inf
#>  [2,] 0.01085616 0.000000e+00          Inf          Inf          Inf
#>  [3,] 0.08823010 4.398408e-06 0.000000e+00          Inf          Inf
#>  [4,] 0.29541444 1.226947e-05 1.607228e-06 0.000000e+00          Inf
#>  [5,] 0.68531037 4.722347e-05 7.663471e-06 1.607228e-06 0.000000e+00
#>  [6,] 1.29423889 2.712687e-04 2.187124e-05 7.663471e-06 1.607228e-06
#>  [7,] 2.15068003 1.250506e-03 7.220059e-05 2.187124e-05 7.663471e-06
#>  [8,] 3.36903665 2.506565e-03 1.310418e-04 6.315459e-05 2.187124e-05
#>  [9,] 4.92055365 6.144414e-03 4.470093e-04 8.994168e-05 3.961232e-05
#> [10,] 6.42206696 2.249463e-02 2.098502e-03 3.661422e-04 8.994168e-05
#> [11,] 7.02990290 1.023435e-01 7.310587e-03 1.613182e-03 3.661422e-04
#> [12,] 5.32912221 5.668602e-01 2.884879e-02 7.310587e-03 1.613182e-03
#> [13,] 0.00000000 2.629357e+00 3.045441e-02 1.005828e-02 7.310587e-03
 print(a) #indices of months to select for follow-up experiments
#> [1]  1  9 11 12
 print(rownames(CanadianWeather$monthlyTemp)[a]) #month names selected
#> [1] "Jan" "Sep" "Nov" "Dec"