This function generates demand points to characterize a distribution of points.

make.DemandPoints(
  points,
  n = 100L,
  quantile = 0.5,
  kernel.method = c("ks", "hypervolume")[1],
  ...
)

Arguments

points

base::matrix() object containing points.

n

integer number of demand points to use for each attribute space for each species. Defaults to 100L.

quantile

numeric quantile to generate demand points within. If 0 then demand points are generated across the full range of values the points intersect. Defaults to 0.5.

kernel.method

character name of kernel method to use to generate demand points. Defaults to 'ks'.

...

arguments passed to kernel density estimating functions

Value

DemandPoints() object.

Details

Broadly speaking, demand points are generated by fitting a kernal to the input points. A shape is then fit to the extent of the kernal, and then points are randomly generated inside the shape. The demand points are generated as random points inside the shape. The weights for each demand point are calculated the estimated density of input points at the demand point. By supplying 'ks' as an argument to method in kernel.method, the shape is defined using a minimum convex polygon adehabitatHR::mcp() and ks::kde() is used to fit the kernel. Note this can only be used when the data is low-dimensional (d < 3). By supplying "hypervolume" as an argument to method, the hypervolume::hypervolume() function is used to create the demand points. This method can be used for hyper-dimensional data (\(d << 3\)).

See also

Examples

# set random number generator seed set.seed(500) # load data data(cs_spp, cs_space) # generate species points species.points <- randomPoints(cs_spp[[1]], n = 100, prob = TRUE) env.points <- raster::extract(cs_space, species.points) # generate demand points for a 1d space using ks dps1 <- make.DemandPoints(points = env.points[, 1], kernel.method = "ks") # print object print(dps1)
#> An object of class "DemandPoints" #> Slot "coords": #> [,1] #> [1,] 0.0808103965 #> [2,] -0.0046110220 #> [3,] 0.0668303872 #> [4,] -0.0041704372 #> [5,] 0.0967735148 #> [6,] 0.0861980940 #> [7,] 0.0132235371 #> [8,] 0.0310942531 #> [9,] 0.0825810501 #> [10,] -0.0060209785 #> [11,] 0.0564411165 #> [12,] 0.0481650725 #> [13,] 0.0344428694 #> [14,] 0.0926038712 #> [15,] -0.0147107140 #> [16,] 0.0756575648 #> [17,] 0.0369092063 #> [18,] 0.0799855539 #> [19,] -0.0117221542 #> [20,] 0.0577459375 #> [21,] 0.0920794479 #> [22,] 0.0952088934 #> [23,] -0.0037990803 #> [24,] 0.0305098018 #> [25,] 0.0693633653 #> [26,] 0.0298491904 #> [27,] -0.0151671063 #> [28,] 0.0661814398 #> [29,] 0.0964706920 #> [30,] 0.0960502611 #> [31,] 0.0230169779 #> [32,] -0.0062315867 #> [33,] 0.0466713173 #> [34,] 0.0430020562 #> [35,] -0.0034828316 #> [36,] 0.0139532329 #> [37,] 0.0610430386 #> [38,] 0.0638028609 #> [39,] 0.0141869346 #> [40,] 0.0614487429 #> [41,] 0.0174622277 #> [42,] 0.0569979267 #> [43,] 0.0758035877 #> [44,] 0.0911338269 #> [45,] 0.0613651952 #> [46,] 0.0712111251 #> [47,] -0.0153747193 #> [48,] 0.0053567867 #> [49,] 0.0001290641 #> [50,] 0.0748831151 #> [51,] 0.0913816999 #> [52,] 0.0696987094 #> [53,] 0.0081708489 #> [54,] -0.0165420546 #> [55,] 0.0685402103 #> [56,] 0.0458259356 #> [57,] 0.0473664530 #> [58,] 0.0598048637 #> [59,] 0.0029895715 #> [60,] 0.0134756199 #> [61,] 0.0898856664 #> [62,] 0.0962462809 #> [63,] 0.0379707443 #> [64,] 0.0634802594 #> [65,] 0.0808849064 #> [66,] 0.0236644932 #> [67,] 0.0044193706 #> [68,] 0.0343277188 #> [69,] 0.0193473450 #> [70,] 0.0633850620 #> [71,] -0.0002382388 #> [72,] 0.0894711454 #> [73,] 0.0148280822 #> [74,] 0.0381031305 #> [75,] -0.0069926641 #> [76,] 0.0202786370 #> [77,] 0.0664897503 #> [78,] -0.0106829767 #> [79,] 0.0283130895 #> [80,] 0.0461905186 #> [81,] 0.0069314659 #> [82,] 0.0376396247 #> [83,] 0.0641600909 #> [84,] 0.0807674019 #> [85,] 0.0180828540 #> [86,] -0.0002938120 #> [87,] 0.0006463103 #> [88,] 0.0537719354 #> [89,] 0.0851661386 #> [90,] 0.0983258658 #> [91,] 0.0782045448 #> [92,] 0.0684126645 #> [93,] 0.0848222982 #> [94,] -0.0010883922 #> [95,] -0.0058721566 #> [96,] 0.0018729637 #> [97,] 0.0066104837 #> [98,] 0.0284932295 #> [99,] -0.0145268795 #> [100,] 0.0098583588 #> #> Slot "weights": #> [1] 0.3010606 0.3850167 0.3296584 0.3854821 0.2703865 0.2904376 0.3967625 #> [8] 0.3896309 0.2975354 0.3834467 0.3506640 0.3660383 0.3861334 0.2781870 #> [15] 0.3723192 0.3114736 0.3831519 0.3027107 0.3764002 0.3480990 0.2791764 #> [22] 0.2733036 0.3858744 0.3901590 0.3244229 0.3907559 0.3716687 0.3309954 #> [29] 0.2709490 0.2717331 0.3953379 0.3832109 0.3686019 0.3745554 0.3862085 #> [36] 0.3968460 0.3414976 0.3358828 0.3968727 0.3406761 0.3968743 0.3495757 #> [43] 0.3111759 0.2809656 0.3408453 0.3206091 0.3713728 0.3936252 0.3896931 #> [50] 0.3130564 0.2804945 0.3237301 0.3951657 0.3696947 0.3261238 0.3700298 #> [57] 0.3674278 0.3439926 0.3920070 0.3967913 0.2833381 0.2713672 0.3817864 #> [64] 0.3365415 0.3009117 0.3950104 0.3930144 0.3862627 0.3965723 0.3367357 #> [71] 0.3893554 0.2841316 0.3969455 0.3816087 0.3823203 0.3963328 0.3303602 #> [78] 0.3777600 0.3920285 0.3694140 0.3945385 0.3822290 0.3351498 0.3011465 #> [85] 0.3968180 0.3893043 0.3901301 0.3558121 0.2924465 0.2675060 0.3062967 #> [92] 0.3263876 0.2931186 0.3885737 0.3836134 0.3911561 0.3943711 0.3918831 #> [99] 0.3725805 0.3958686 #>
# \dontrun{ # generate demand points for a 2d space using hypervolume dps2 <- make.DemandPoints(points = env.points, kernel.method = "hypervolume", samples.per.point = 50, verbose = FALSE) # print object print(dps2)
#> An object of class "DemandPoints" #> Slot "coords": #> dc1 dc2 #> [1,] 0.0191236353 -0.1364313154 #> [2,] 0.0202995947 -0.0292215526 #> [3,] 0.0183381825 -0.0547221260 #> [4,] -0.0271537479 -0.0043238100 #> [5,] 0.0550490247 -0.1479757648 #> [6,] 0.1139715193 -0.2841913814 #> [7,] -0.0696353849 -0.0149520002 #> [8,] 0.0037754892 -0.2517531033 #> [9,] 0.0233087450 -0.1238921830 #> [10,] 0.0012030139 -0.2545046876 #> [11,] 0.0938738918 -0.3410015677 #> [12,] 0.0791126670 -0.3199645044 #> [13,] 0.0667568109 -0.1409402783 #> [14,] 0.0179274597 -0.2055789800 #> [15,] -0.0138899159 -0.1652881134 #> [16,] 0.0502357516 -0.0746435807 #> [17,] -0.0623169891 -0.0708688850 #> [18,] 0.0259813301 -0.1187499806 #> [19,] 0.0515652006 -0.1699165923 #> [20,] -0.0157870699 -0.0498496832 #> [21,] 0.0191720324 -0.2000051589 #> [22,] -0.0468165101 -0.1664341184 #> [23,] 0.0425817630 -0.0787896248 #> [24,] -0.0167106891 -0.1913820931 #> [25,] -0.0235379674 -0.0852164867 #> [26,] -0.0526682289 -0.1858602982 #> [27,] 0.0192517564 -0.2835122719 #> [28,] -0.0218888842 -0.1458078384 #> [29,] 0.0271212974 -0.1364789384 #> [30,] -0.0085100340 -0.0889632008 #> [31,] -0.0079221849 -0.1989397447 #> [32,] 0.1091361397 -0.3009164326 #> [33,] -0.0357979724 -0.1517725610 #> [34,] 0.0504223823 -0.2489086268 #> [35,] 0.0185644947 -0.2639445205 #> [36,] -0.0912110870 -0.0687928794 #> [37,] 0.0008009894 -0.1060131624 #> [38,] 0.0970596148 -0.3147978939 #> [39,] -0.0318740141 -0.1354994782 #> [40,] 0.0403892566 -0.2827989279 #> [41,] 0.1033896832 -0.3021412519 #> [42,] -0.0089336646 -0.1780929838 #> [43,] 0.0383513833 -0.0857686124 #> [44,] 0.0416374931 -0.0670750551 #> [45,] -0.0805381321 -0.0569728725 #> [46,] 0.0386911136 -0.0883821903 #> [47,] -0.0558216885 -0.1165308548 #> [48,] -0.0176716909 -0.2128810284 #> [49,] -0.0414951200 0.0112180973 #> [50,] 0.0381219920 -0.2684486406 #> [51,] -0.0661752515 -0.1155904025 #> [52,] -0.0500578407 -0.0020464207 #> [53,] -0.0298420999 -0.2239027879 #> [54,] -0.0112745837 -0.2389359138 #> [55,] -0.0513395212 -0.0137300105 #> [56,] -0.0362588378 -0.1088543582 #> [57,] -0.0641016138 -0.0925521629 #> [58,] 0.0065348681 -0.0939611307 #> [59,] 0.0107799993 -0.1131356333 #> [60,] 0.0441486508 -0.1180415764 #> [61,] 0.0340806521 -0.2891655772 #> [62,] -0.0681429696 -0.0049616190 #> [63,] -0.0309522639 -0.2410877256 #> [64,] -0.0876099217 -0.0826646592 #> [65,] 0.0386472506 -0.1427755099 #> [66,] -0.0740192052 0.0102892067 #> [67,] -0.0182106359 -0.2450749291 #> [68,] 0.0367096817 -0.0773112501 #> [69,] 0.0599292113 -0.2786022469 #> [70,] -0.0541423596 -0.0560272292 #> [71,] 0.0341746739 -0.2116757368 #> [72,] -0.0920001024 -0.0656618697 #> [73,] -0.0345744115 -0.2136102122 #> [74,] 0.0101462059 -0.2658191570 #> [75,] 0.0474707791 -0.1841814193 #> [76,] 0.0667454859 -0.2357097885 #> [77,] -0.0602454141 -0.1216449963 #> [78,] 0.0483934203 -0.1882122268 #> [79,] -0.0081431202 -0.0857835341 #> [80,] 0.0189160036 -0.0489165005 #> [81,] 0.0402771277 -0.1018654726 #> [82,] -0.0587101074 -0.1247762008 #> [83,] -0.0240781497 -0.1691827147 #> [84,] 0.0014254079 -0.2338685326 #> [85,] -0.0192175219 -0.0133326410 #> [86,] 0.0268485082 -0.0748669908 #> [87,] -0.0151771831 -0.1475814994 #> [88,] -0.0571516082 -0.0822814484 #> [89,] -0.0068204351 -0.0492331558 #> [90,] -0.0114902998 -0.0726008402 #> [91,] -0.0836560447 0.0001096449 #> [92,] 0.0462244614 -0.2688245666 #> [93,] -0.0415376742 -0.0592364370 #> [94,] 0.1171819529 -0.2956465955 #> [95,] -0.0699195681 -0.0465974500 #> [96,] 0.0008652842 -0.1619854206 #> [97,] 0.0040929280 -0.1175130381 #> [98,] -0.0091354564 -0.0230578742 #> [99,] -0.0542954178 -0.1669079724 #> [100,] 0.0492360578 -0.0689054338 #> #> Slot "weights": #> [1] 0.0012770675 0.0008721018 0.0009794199 0.0009432869 0.0010033355 #> [6] 0.0008680953 0.0010652825 0.0012588352 0.0011741423 0.0011878168 #> [11] 0.0008800972 0.0010182890 0.0008605718 0.0016623949 0.0015313514 #> [16] 0.0008323247 0.0013053389 0.0011300981 0.0011356111 0.0011809915 #> [21] 0.0016496813 0.0010909859 0.0008945415 0.0015260753 0.0013179973 #> [26] 0.0008695482 0.0009891242 0.0014235757 0.0012160952 0.0012283221 #> [31] 0.0016118394 0.0009632469 0.0013064137 0.0013594775 0.0012407198 #> [36] 0.0008509520 0.0012246838 0.0010325949 0.0013525078 0.0011767197 #> [41] 0.0010123651 0.0016014194 0.0009383535 0.0008743028 0.0010679211 #> [46] 0.0009424752 0.0011958448 0.0013991234 0.0008402363 0.0012958683 #> [51] 0.0010593237 0.0010048511 0.0010523487 0.0012229137 0.0011174664 #> [56] 0.0013535630 0.0012204302 0.0011486084 0.0011987626 0.0009917007 #> [61] 0.0010638403 0.0009994510 0.0008297930 0.0008738836 0.0011483973 #> [66] 0.0008381563 0.0010179755 0.0009291794 0.0012464868 0.0013529721 #> [71] 0.0015293234 0.0008430199 0.0010537113 0.0011330711 0.0012558668 #> [76] 0.0011803019 0.0011087982 0.0012610028 0.0012183380 0.0009588992 #> [81] 0.0009679542 0.0011117316 0.0014450712 0.0014603041 0.0009825486 #> [86] 0.0009820880 0.0014563212 0.0013284572 0.0011139472 0.0012126921 #> [91] 0.0008391471 0.0013030305 0.0013655273 0.0008730052 0.0012113548 #> [96] 0.0015482540 0.0012577089 0.0009965207 0.0009473615 0.0008264729 #>
# }