heat_up: Convert log-likelihoods of any vegdistmod PDF to a raster...

Description Usage Arguments Author(s) Examples

View source: R/search_fun.R

Description

This is not an ENM. What it does do is provides a geographic representation of the likelihood functions that are used in CRACLE and the spatial defragmentation functions.

Usage

1
2
heat_up(clim, dens, parallel = FALSE, nclus = 4, type = ".kde",
  w = FALSE)

Arguments

clim

A raster object of climate data (matching ext_ob)

dens

A vegdistmod density object (see densform())

parallel

Make use of multicore architecture

nclus

If parallel is TRUE, how many cores should be allocated.

type

Which PDF should be used, .gauss or .kde

w

TRUE or FALSE should variable PDFs be weighted by relative niche breadth.

Author(s)

Robert Harbert, rharbert@amnh.org

Avery Hill

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## Not run: 
data(abies);
data(climondbioclim);
ext.abies = extraction(abies, climondbioclim, schema='raw', rm.outlier=TRUE, alpha = 0.005);
dens <- densform(ext.abies, climondbioclim, manip = 'condi', 
                 kern = 'gaussian', n = 128, bg.n = 1000)
h = heat_up(climondbioclim, dens, parallel=FALSE, type = '.kde', nclus =4)
hs = sum(h)
ex.h = raster::extract(hs, ext.abies[,4:3])
plot(hs>sort(ex.h)[ceiling(0.01*length(ex.h))])
points(ext.abies[,4:3], col ='green')
 
##Bootstrap: With train/test subsetting and model evaluation

binary = list();
bin.auc = list();
ev.auc = list();
data.ex = extraction(abies, climondbioclim, schema='flat', factor =2, rm.outlier=TRUE, alpha = 0.01)
for (i in 1:100){
pick = as.numeric(sample(data.ex[,1], 0.5*length(data.ex[,1]), replace =F));
train = data.ex[which(data.ex[,1] %in% pick),]
test = data.ex[-which(data.ex[,1] %in% pick),]
d.train <- densform(train, climondbioclim, 
     manip = 'condi', kern = 'gaussian', n = 128, bg.n = 1000)
h.t = heat_up(climondbioclim, d.train, parallel=TRUE, type = '.kde', nclus =4)
hs.t = sum(h.t)
ex.h = raster::extract(hs.t, test[,4:3])
binary[[i]] = hs.t>sort(ex.h)[ceiling(0.1*length(ex.h))];
plot(binary[[i]])
points(test[,4:3], col ='purple', pch = 20)

bg <- rad_bg(test[,4:3], climondbioclim[[1]], radius = 2000, n = 200)
bg.e <- raster::extract(hs.t, bg[,4:3]);
ev <- evaluate(ex.h, bg.e)
print(ev)
ev.auc[[i]] = ev@auc;

bg.bin <- raster::extract(binary[[i]], bg[,4:3]);
ex.bin <- raster::extract(binary[[i]], test[,4:3]);
ev.bin <- evaluate(ex.bin, bg.bin)
print(ev.bin)
bin.auc[[i]] = ev.bin@auc
}
bin.stack = stack(unlist(binary))
bin.sum = sum(bin.stack)
bin.weightave = sum(bin.stack * unlist(bin.auc))/sum(unlist(bin.auc))
plot(bin.sum>50); #bootstrap consensus
plot(bin.weightave>0.5); #weighted (bin.auc) consensus
points(data.ex[,4:3], pch = 20, cex =0.5)



## End(Not run)

rsh249/vegdistmod documentation built on May 28, 2019, 3:31 a.m.