LSCV.spattemp.Rd
Bandwidth selection for standalone spatiotemporal density/intensity based on either unbiased least squares cross-validation (LSCV) or likelihood (LIK) cross-validation, providing an isotropic scalar spatial bandwidth and a scalar temporal bandwidth.
An object of class ppp
giving the spatial coordinates of the observations to be smoothed. Possibly marked with the time of each event; see argument tt
.
A numeric vector of equal length to the number of points in pp
, giving the time corresponding to each spatial observation. If unsupplied, the function attempts to use the values in the marks
attribute of the ppp.object
in pp
.
A numeric vector of length 2 giving the limits of the temporal domain over which to smooth. If supplied, all times in tt
must fall within this interval (equality with limits allowed). If unsupplied, the function simply uses the range of the observed temporal values.
Character string dictating spatial edge correction. "uniform"
(default) corrects based on evaluation grid coordinate. Setting sedge="none"
requests no edge correction.
As sedge
, for temporal edge correction.
Numeric value > 0. Resolution of the [sres
\(\times\) sres
] evaluation grid in the spatial margin.
Numeric value > 0. Resolution of the evaluation points in the temporal margin as defined by the tlim
interval. If unsupplied, the density is evaluated at integer values between tlim[1]
and tlim[2]
.
Optional numeric argument to invoke parallel processing, by giving the number of CPU cores to use optimisation. This is only useful for larger data sets of many thousand observations. Experimental. Test your system first using parallel::detectCores()
to identify the number of cores available to you.
Optional positive numeric vector of length 2 giving starting values for the internal call to optim
, in the order of (<spatial bandwidth>, <temporal bandwidth>).
Logical value indicating whether to print a function progress bar to the console during evaluation.
A numeric vector of length 2 giving the jointly optimised spatial and temporal bandwidths (named h
and lambda
respectively).
Silverman, B.W. (1986), Density Estimation for Statistics and Data Analysis, Chapman & Hall, New York.
Leave-one-out CV for bandwidth selection in kernel density estimation is notoriously unstable in practice and has a tendency to produce rather small bandwidths in the fixed bandwidth case. Satisfactory bandwidths are not guaranteed for every application. This method can also be computationally expensive for large data sets and fine evaluation grid resolutions.
# \donttest{
data(burk) # Burkitt's Uganda lymphoma data
burkcas <- burk$cases
hlam1 <- LSCV.spattemp(burkcas) #~9 secs
#> h = 11.24394 ; lambda = 459.5736
#> h = 57.2013 ; lambda = 459.5736
#> h = 11.24394 ; lambda = 505.5309
#> h = 34.22262 ; lambda = 471.0629
#> h = 22.73328 ; lambda = 476.8076
#> h = 16.98861 ; lambda = 479.6799
#> h = 5.499275 ; lambda = 485.4246
#> h = 5.499275 ; lambda = 439.4672
#> h = 6.935442 ; lambda = 455.9831
#> h = 8.371609 ; lambda = 461.0097
#> h = 2.62694 ; lambda = 463.8821
#> h = 6.935442 ; lambda = 461.7278
#> h = 4.063107 ; lambda = 463.164
#> h = 4.781191 ; lambda = 462.8049
#> h = 4.781191 ; lambda = 508.7623
#> h = 4.422149 ; lambda = 543.4098
#> h = 4.063107 ; lambda = 486.1426
#> h = 5.140233 ; lambda = 485.6041
#> h = 5.140233 ; lambda = 531.5614
#> h = 5.319754 ; lambda = 565.9397
#> h = 4.781191 ; lambda = 554.7196
#> h = 4.60167 ; lambda = 589.2774
#> h = 4.960712 ; lambda = 612.0766
#> h = 4.915832 ; lambda = 586.248
#> h = 4.377269 ; lambda = 643.964
#> h = 3.995787 ; lambda = 700.1652
#> h = 4.063107 ; lambda = 646.9934
#> h = 4.702651 ; lambda = 601.4343
#> h = 4.478249 ; lambda = 656.1209
#> h = 4.416539 ; lambda = 689.5427
#> h = 4.091157 ; lambda = 732.0723
#> h = 4.549777 ; lambda = 634.0938
#> h = 4.589047 ; lambda = 679.6725
#> h = 4.536103 ; lambda = 670.7454
#> h = 4.402865 ; lambda = 726.1942
#> h = 4.439593 ; lambda = 703.1691
#> h = 4.559157 ; lambda = 684.3718
#> h = 4.452193 ; lambda = 688.2499
#> h = 4.355683 ; lambda = 720.6737
#> h = 4.490998 ; lambda = 683.2275
#> h = 4.503599 ; lambda = 668.3083
#> h = 4.455594 ; lambda = 694.4539
#> h = 4.494399 ; lambda = 689.4314
#> h = 4.515501 ; lambda = 690.0221
#> h = 4.458995 ; lambda = 700.6579
#> h = 4.482997 ; lambda = 687.5851
#> h = 4.521802 ; lambda = 682.5626
#> h = 4.472146 ; lambda = 691.4811
#> h = 4.460745 ; lambda = 689.6347
#> h = 4.485985 ; lambda = 689.4822
#> h = 4.475134 ; lambda = 693.3782
#> h = 4.4771 ; lambda = 691.93
#> h = 4.490939 ; lambda = 689.9311
#> h = 4.476844 ; lambda = 691.0936
#> h = 4.467959 ; lambda = 693.5413
#> h = 4.481479 ; lambda = 690.497
#> h = 4.481734 ; lambda = 691.3334
#> h = 4.480512 ; lambda = 691.2734
#> h = 4.484891 ; lambda = 689.8405
#> h = 4.479048 ; lambda = 691.4076
#> h = 4.478081 ; lambda = 692.184
#> h = 4.480629 ; lambda = 690.9188
#> h = 4.479165 ; lambda = 691.0529
#> h = 4.478492 ; lambda = 690.9427
hlam2 <- LSCV.spattemp(burkcas,tlim=c(400,5800))
#> h = 11.24394 ; lambda = 459.5736
#> h = 57.2013 ; lambda = 459.5736
#> h = 11.24394 ; lambda = 505.5309
#> h = 34.22262 ; lambda = 471.0629
#> h = 22.73328 ; lambda = 476.8076
#> h = 16.98861 ; lambda = 479.6799
#> h = 5.499275 ; lambda = 485.4246
#> h = 5.499275 ; lambda = 439.4672
#> h = 6.935442 ; lambda = 455.9831
#> h = 8.371609 ; lambda = 461.0097
#> h = 2.62694 ; lambda = 463.8821
#> h = 6.935442 ; lambda = 461.7278
#> h = 4.063107 ; lambda = 463.164
#> h = 4.781191 ; lambda = 462.8049
#> h = 4.781191 ; lambda = 508.7623
#> h = 4.422149 ; lambda = 543.4098
#> h = 5.499275 ; lambda = 531.3819
#> h = 5.319754 ; lambda = 514.2377
#> h = 4.60167 ; lambda = 537.5754
#> h = 4.152868 ; lambda = 563.6508
#> h = 4.063107 ; lambda = 532.1
#> h = 5.005592 ; lambda = 518.7033
#> h = 4.826071 ; lambda = 547.5164
#> h = 4.848511 ; lambda = 566.8934
#> h = 5.252433 ; lambda = 548.0213
#> h = 4.764361 ; lambda = 540.1869
#> h = 4.60728 ; lambda = 588.377
#> h = 4.408124 ; lambda = 623.2139
#> h = 4.492274 ; lambda = 649.9204
#> h = 4.356231 ; lambda = 704.7872
#> h = 4.051887 ; lambda = 706.2409
#> h = 4.649355 ; lambda = 601.7303
#> h = 4.733506 ; lambda = 628.4368
#> h = 4.65216 ; lambda = 627.1311
#> h = 4.495079 ; lambda = 675.3212
#> h = 4.417942 ; lambda = 712.1167
#> h = 4.335194 ; lambda = 698.1106
#> h = 4.414435 ; lambda = 680.3657
#> h = 4.41724 ; lambda = 705.7665
#> h = 4.435999 ; lambda = 691.805
#> h = 4.516643 ; lambda = 686.7605
#> h = 4.567747 ; lambda = 689.9579
#> h = 4.575724 ; lambda = 670.2768
#> h = 4.540792 ; lambda = 675.6588
#> h = 4.562356 ; lambda = 687.0981
#> h = 4.511899 ; lambda = 678.2655
#> h = 4.536048 ; lambda = 667.1638
#> h = 4.521494 ; lambda = 681.8613
#> h = 4.4926 ; lambda = 684.468
#> h = 4.528744 ; lambda = 677.8611
#> h = 4.53834 ; lambda = 681.457
#> h = 4.518509 ; lambda = 679.0633
#> h = 4.525759 ; lambda = 675.0631
#> h = 4.52256 ; lambda = 680.1618
#> h = 4.512325 ; lambda = 681.364
#> h = 4.52464 ; lambda = 678.7368
#> h = 4.520588 ; lambda = 677.6384
#> h = 4.522067 ; lambda = 679.5309
#> h = 4.515937 ; lambda = 679.8574
#> h = 4.522464 ; lambda = 679.017
#> h = 4.518905 ; lambda = 678.5494
#> h = 4.521277 ; lambda = 679.2855
#> h = 4.525232 ; lambda = 679.2392
#> h = 4.52019 ; lambda = 679.1073
#> h = 4.519003 ; lambda = 679.3759
#> h = 4.519868 ; lambda = 679.2861
hlam3 <- LSCV.spattemp(burkcas,start=c(7,400))
#> h = 7 ; lambda = 400
#> h = 47 ; lambda = 400
#> h = 7 ; lambda = 440
#> h = 27 ; lambda = 410
#> h = 17 ; lambda = 415
#> h = 12 ; lambda = 417.5
#> h = 2 ; lambda = 422.5
#> h = 9.5 ; lambda = 418.75
#> h = 4.5 ; lambda = 421.25
#> h = 2 ; lambda = 422.5
#> h = 4.5 ; lambda = 381.25
#> h = 5.125 ; lambda = 395.9375
#> h = 2.625 ; lambda = 417.1875
#> h = 5.90625 ; lambda = 404.2969
#> h = 6.53125 ; lambda = 378.9844
#> h = 5.007812 ; lambda = 410.6836
#> h = 4.226562 ; lambda = 402.3242
#> h = 5.486328 ; lambda = 403.8037
#> h = 5.369141 ; lambda = 418.5498
#> h = 5.491211 ; lambda = 429.856
#> h = 5.847656 ; lambda = 411.6699
#> h = 5.217773 ; lambda = 410.9302
#> h = 5.100586 ; lambda = 425.6763
#> h = 4.907715 ; lambda = 436.6125
#> h = 5.251953 ; lambda = 433.2959
#> h = 5.269043 ; lambda = 444.4788
#> h = 5.000488 ; lambda = 451.6052
#> h = 4.816162 ; lambda = 468.1329
#> h = 5.168945 ; lambda = 470.4077
#> h = 5.203125 ; lambda = 492.7734
#> h = 4.93457 ; lambda = 499.8999
#> h = 4.767334 ; lambda = 527.6105
#> h = 4.969971 ; lambda = 568.7787
#> h = 4.954712 ; lambda = 627.3654
#> h = 4.518921 ; lambda = 662.2025
#> h = 4.176819 ; lambda = 746.917
#> h = 4.706299 ; lambda = 761.9574
#> h = 4.721558 ; lambda = 703.3707
#> h = 4.285767 ; lambda = 738.2077
#> h = 4.453003 ; lambda = 710.4971
#> h = 4.250366 ; lambda = 669.3289
#> h = 4.60376 ; lambda = 694.8602
#> h = 4.368164 ; lambda = 677.8394
#> h = 4.544861 ; lambda = 690.605
#> h = 4.478943 ; lambda = 738.8997
#> h = 4.508926 ; lambda = 681.3768
#> h = 4.417068 ; lambda = 701.2689
#> h = 4.449017 ; lambda = 698.6029
#> h = 4.50494 ; lambda = 669.4825
#> h = 4.465987 ; lambda = 700.2435
#> h = 4.406077 ; lambda = 717.4696
#> h = 4.483214 ; lambda = 690.4
#> h = 4.466244 ; lambda = 688.7594
#> h = 4.466179 ; lambda = 691.6304
#> h = 4.500377 ; lambda = 683.4275
#> h = 4.487537 ; lambda = 687.2214
#> h = 4.504572 ; lambda = 685.9909
#> h = 4.475777 ; lambda = 690.2205
#> h = 4.471455 ; lambda = 693.3992
#> h = 4.475475 ; lambda = 691.8547
#> h = 4.482912 ; lambda = 692.0342
#> h = 4.481128 ; lambda = 691.5808
#> h = 4.488867 ; lambda = 690.126
#> h = 4.478823 ; lambda = 691.4225
#> h = 4.480909 ; lambda = 690.2418
#> h = 4.480964 ; lambda = 690.5765
#> h = 4.476573 ; lambda = 691.5991
#> h = 4.478233 ; lambda = 691.2993
rbind(hlam1,hlam2,hlam3)
#> h lambda
#> hlam1 4.479165 691.0529
#> hlam2 4.520190 679.1073
#> hlam3 4.478823 691.4225
hlam1 <- LIK.spattemp(burkcas) #~3 secs
#> h = 11.24394 ; lambda = 459.5736
#> h = 57.2013 ; lambda = 459.5736
#> h = 11.24394 ; lambda = 505.5309
#> h = 34.22262 ; lambda = 471.0629
#> h = 22.73328 ; lambda = 476.8076
#> h = 16.98861 ; lambda = 479.6799
#> h = 5.499275 ; lambda = 485.4246
#> h = 8.371609 ; lambda = 483.9884
#> h = 8.371609 ; lambda = 529.9458
#> h = 6.935442 ; lambda = 565.1319
#> h = 4.063107 ; lambda = 543.5893
#> h = 9.448735 ; lambda = 515.0455
#> h = 5.858316 ; lambda = 534.0747
#> h = 8.55113 ; lambda = 519.8028
#> h = 7.114963 ; lambda = 600.9463
#> h = 6.48664 ; lambda = 659.4252
#> h = 4.870951 ; lambda = 704.7542
#> h = 7.631086 ; lambda = 566.0407
#> h = 7.182283 ; lambda = 660.334
#> h = 7.305704 ; lambda = 707.9351
#> h = 6.161258 ; lambda = 801.3197
#> h = 6.528715 ; lambda = 742.4999
#> h = 7.347779 ; lambda = 791.0098
#> h = 7.778349 ; lambda = 856.8022
#> h = 6.57079 ; lambda = 825.5746
#> h = 6.203333 ; lambda = 884.3944
#> h = 7.389854 ; lambda = 874.0846
#> h = 7.174569 ; lambda = 841.1884
#> h = 6.39758 ; lambda = 875.7532
#> h = 5.922481 ; lambda = 918.1249
#> h = 5.793801 ; lambda = 860.1394
#> h = 6.829377 ; lambda = 845.9262
#> h = 6.656168 ; lambda = 896.1047
#> h = 6.698857 ; lambda = 931.3697
#> h = 7.130653 ; lambda = 901.5427
#> h = 6.580849 ; lambda = 882.2006
#> h = 6.450328 ; lambda = 967.6442
#> h = 6.54509 ; lambda = 937.2147
#> h = 6.663098 ; lambda = 986.3838
#> h = 6.642536 ; lambda = 960.338
#> h = 6.796302 ; lambda = 954.4931
#> h = 6.607893 ; lambda = 941.5343
#> h = 6.664214 ; lambda = 912.566
#> h = 6.658794 ; lambda = 924.509
#> h = 6.567831 ; lambda = 934.6735
#> h = 6.6661 ; lambda = 932.1957
#> h = 6.717001 ; lambda = 915.1704
#> h = 6.63517 ; lambda = 934.9433
#> h = 6.642476 ; lambda = 942.63
#> h = 6.654715 ; lambda = 929.0392
#> h = 6.623785 ; lambda = 931.7869
#> h = 6.655521 ; lambda = 932.0935
#> h = 6.635977 ; lambda = 937.9975
#> h = 6.65003 ; lambda = 931.2788
#> h = 6.629679 ; lambda = 934.1286
#> h = 6.649061 ; lambda = 932.6023
hlam2 <- LIK.spattemp(burkcas,tlim=c(400,5800))
#> h = 11.24394 ; lambda = 459.5736
#> h = 57.2013 ; lambda = 459.5736
#> h = 11.24394 ; lambda = 505.5309
#> h = 34.22262 ; lambda = 471.0629
#> h = 22.73328 ; lambda = 476.8076
#> h = 16.98861 ; lambda = 479.6799
#> h = 5.499275 ; lambda = 485.4246
#> h = 8.371609 ; lambda = 483.9884
#> h = 8.371609 ; lambda = 529.9458
#> h = 6.935442 ; lambda = 565.1319
#> h = 4.063107 ; lambda = 543.5893
#> h = 9.448735 ; lambda = 515.0455
#> h = 5.858316 ; lambda = 534.0747
#> h = 8.55113 ; lambda = 519.8028
#> h = 7.114963 ; lambda = 600.9463
#> h = 6.48664 ; lambda = 659.4252
#> h = 4.870951 ; lambda = 704.7542
#> h = 7.631086 ; lambda = 566.0407
#> h = 7.182283 ; lambda = 660.334
#> h = 7.305704 ; lambda = 707.9351
#> h = 6.161258 ; lambda = 801.3197
#> h = 6.528715 ; lambda = 742.4999
#> h = 7.347779 ; lambda = 791.0098
#> h = 7.778349 ; lambda = 856.8022
#> h = 6.57079 ; lambda = 825.5746
#> h = 6.203333 ; lambda = 884.3944
#> h = 7.389854 ; lambda = 874.0846
#> h = 7.174569 ; lambda = 841.1884
#> h = 6.39758 ; lambda = 875.7532
#> h = 5.922481 ; lambda = 918.1249
#> h = 5.793801 ; lambda = 860.1394
#> h = 6.829377 ; lambda = 845.9262
#> h = 6.656168 ; lambda = 896.1047
#> h = 6.698857 ; lambda = 931.3697
#> h = 7.130653 ; lambda = 901.5427
#> h = 6.580849 ; lambda = 882.2006
#> h = 6.450328 ; lambda = 967.6442
#> h = 6.54509 ; lambda = 937.2147
#> h = 6.663098 ; lambda = 986.3838
#> h = 6.642536 ; lambda = 960.338
#> h = 6.601411 ; lambda = 908.2464
#> h = 6.632255 ; lambda = 947.3151
#> h = 6.786021 ; lambda = 941.4702
#> h = 6.605323 ; lambda = 938.2785
#> h = 6.671925 ; lambda = 922.3332
#> h = 6.69176 ; lambda = 909.8422
#> h = 6.578391 ; lambda = 929.242
#> h = 6.66874 ; lambda = 930.8378
#> h = 6.735342 ; lambda = 914.8924
#> h = 6.637828 ; lambda = 932.432
#> h = 6.634643 ; lambda = 940.9366
#> h = 6.662604 ; lambda = 926.984
#> h = 6.631692 ; lambda = 928.5783
#> h = 6.640954 ; lambda = 929.1431
#> h = 6.616177 ; lambda = 934.5911
#> h = 6.650998 ; lambda = 928.8858
#> h = 6.654124 ; lambda = 925.5969
#> h = 6.65005 ; lambda = 927.3057
#> h = 6.660094 ; lambda = 927.0484
#> h = 6.645739 ; lambda = 928.6194
#> h = 6.646687 ; lambda = 930.1995
#> h = 6.647527 ; lambda = 929.4761
hlam3 <- LIK.spattemp(burkcas,start=c(7,400))
#> h = 7 ; lambda = 400
#> h = 47 ; lambda = 400
#> h = 7 ; lambda = 440
#> h = 27 ; lambda = 410
#> h = 17 ; lambda = 415
#> h = 12 ; lambda = 417.5
#> h = 2 ; lambda = 422.5
#> h = 9.5 ; lambda = 418.75
#> h = 9.5 ; lambda = 458.75
#> h = 8.875 ; lambda = 444.0625
#> h = 6.375 ; lambda = 465.3125
#> h = 7.15625 ; lambda = 453.6719
#> h = 5.28125 ; lambda = 449.6094
#> h = 7.976562 ; lambda = 445.4492
#> h = 8.132812 ; lambda = 459.1211
#> h = 8.699219 ; lambda = 468.6816
#> h = 7.3125 ; lambda = 467.3438
#> h = 6.980469 ; lambda = 478.291
#> h = 7.957031 ; lambda = 483.7402
#> h = 8.357422 ; lambda = 498.7744
#> h = 7.205078 ; lambda = 517.9443
#> h = 6.741211 ; lambda = 547.356
#> h = 8.118164 ; lambda = 567.8394
#> h = 8.687012 ; lambda = 612.6135
#> h = 6.501953 ; lambda = 616.4209
#> h = 5.574219 ; lambda = 675.2441
#> h = 7.878906 ; lambda = 636.9043
#> h = 8.447754 ; lambda = 681.6785
#> h = 6.262695 ; lambda = 685.4858
#> h = 5.334961 ; lambda = 744.3091
#> h = 7.639648 ; lambda = 705.9692
#> h = 8.208496 ; lambda = 750.7434
#> h = 6.023438 ; lambda = 754.5508
#> h = 6.487305 ; lambda = 725.1392
#> h = 7.864258 ; lambda = 745.6226
#> h = 7.463867 ; lambda = 730.5884
#> h = 6.311523 ; lambda = 749.7583
#> h = 6.643555 ; lambda = 738.811
#> h = 7.620117 ; lambda = 744.2603
#> h = 7.336914 ; lambda = 739.48
#> h = 6.516602 ; lambda = 747.7026
#> h = 6.753418 ; lambda = 743.4241
#> h = 7.446777 ; lambda = 744.093
#> h = 6.84436 ; lambda = 740.1315
#> h = 6.260864 ; lambda = 744.0756
#> h = 7.067902 ; lambda = 740.6289
#> h = 7.158844 ; lambda = 737.3363
#> h = 6.854774 ; lambda = 741.9021
#> h = 7.078316 ; lambda = 742.3995
#> h = 7.195293 ; lambda = 743.5335
#> h = 7.291443 ; lambda = 741.1263
#> h = 6.963942 ; lambda = 741.7082
#> h = 6.974356 ; lambda = 743.4788
#> h = 6.927583 ; lambda = 744.9037
#> h = 6.813209 ; lambda = 744.2124
#> h = 7.012039 ; lambda = 742.8527
#> h = 6.97568 ; lambda = 746.0483
#> h = 6.981549 ; lambda = 748.2183
#> h = 6.897093 ; lambda = 750.2693
#> h = 6.83962 ; lambda = 753.9776
#> h = 6.893587 ; lambda = 757.2923
#> h = 6.876589 ; lambda = 763.4865
#> h = 6.73466 ; lambda = 769.2458
#> h = 6.796382 ; lambda = 763.9889
#> h = 6.771629 ; lambda = 778.7547
#> h = 6.737633 ; lambda = 791.1432
#> h = 6.879562 ; lambda = 785.3839
#> h = 6.952013 ; lambda = 793.453
#> h = 6.813057 ; lambda = 821.1097
#> h = 6.781291 ; lambda = 849.9212
#> h = 6.995671 ; lambda = 852.231
#> h = 6.931161 ; lambda = 836.959
#> h = 6.760439 ; lambda = 893.4273
#> h = 6.664652 ; lambda = 943.4145
#> h = 6.514781 ; lambda = 956.3767
#> h = 6.618876 ; lambda = 926.5223
#> h = 6.502238 ; lambda = 1020.016
#> h = 6.572001 ; lambda = 977.492
#> h = 6.711527 ; lambda = 892.4448
#> h = 6.676646 ; lambda = 913.7066
#> h = 6.606883 ; lambda = 956.2302
#> h = 6.659205 ; lambda = 924.3375
#> h = 6.613429 ; lambda = 907.4453
#> h = 6.651846 ; lambda = 934.4222
#> h = 6.692175 ; lambda = 932.2374
#> h = 6.637201 ; lambda = 927.9511
#> h = 6.629842 ; lambda = 938.0358
#> h = 6.637183 ; lambda = 934.6112
#> h = 6.651828 ; lambda = 941.0823
#> h = 6.640858 ; lambda = 931.2339
#> h = 6.626195 ; lambda = 931.4229
#> h = 6.645433 ; lambda = 933.6724
#> h = 6.641759 ; lambda = 937.0497
#> h = 6.641083 ; lambda = 932.6878
rbind(hlam1,hlam2,hlam3)
#> h lambda
#> hlam1 6.649061 932.6023
#> hlam2 6.650998 928.8858
#> hlam3 6.641083 932.6878
# }