Description Usage Arguments Examples
Uses the logistic function to transform the rdist object to a normalized expert range
with a desired proportion of the total probability inside the range.
You can set fitdist to include a buffer around the range as 'inside' for the purposes of
the prior expectation of what
Typically the user supplies prob, rate, and skew as fixparms while upper and lower are estimated.
1 2 3 |
rdist |
|
parms |
A named vector of parameter values from |
dists |
frequency table of unique distance values
(output from running |
returnRaster |
logiical indicating whether to calculate the full spatial prior and return the raster.
If |
doNormalize |
logical indicating whether to normalize the raster before returning it.
If |
verbose |
logical indicating whether to print verbose messages |
doWriteRaster |
|
doWriteMetadata |
|
... |
additional functions to be passed to |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | ## Not run:
library(raster)
library(ggplot2)
data("Tinamus_solitarius_points")
data("Tinamus_solitarius_range")
## Define global modeling grid
domain = raster(
xmn = -180,
xmx = 180,
ymn = -90,
ymx = 90,
crs = "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs",
resolution = 10 / 360,
vals = NULL
)
## turn on raster progress bar
rasterOptions(progress = "")
## calculate distance-to-range: this is slow but only has to
## be done once per species. Can speed it up by increasing
## 'fact' (at the expense of reduced accuracy).
range = Tinamus_solitarius_range
points=Tinamus_solitarius_points
rdist = rangeDist(range=range,
domain=domain,
domainkm = 100,
mask = FALSE,
fact = 10)
## Mask out undesired areas (ocean, etc.) Typically you would
## do this using your environmental data, but here we'll just
## use a coastline polygon from the maps package
# land = map(
# interior = F,
# fill = T,
# xlim = bbox(rdist)[1, ],
# ylim = bbox(rdist)[2, ]
# )
# land = map2SpatialPolygons(land, IDs = land$names)
# rdist = mask(rdist, land)
## calculate frequency table of distances
dists = freq(rdist)
### plot to visualize potential decay parameters
vars = expand.grid(
rate = c(0, 0.03, 0.05, 0.1, 10),
skew = c(0.2,
0.4),
shift = 0,
stringsAsFactors = FALSE
)
x = seq(-150, 300, len = 1000)
## Calculate all the curves
erd = do.call(rbind, lapply(1:nrow(vars), function(i) {
y = logistic(x, parms = unlist(c(
lower = 0, upper = 1, vars[i, ]
)))
return(cbind.data.frame(
group = i,
c(vars[i, ]),
x = x,
y = y
))
}))
## plot it
ggplot(erd,
aes(
x = x,
y = y,
linetype = as.factor(skew),
colour = as.factor(rate),
group = group
)) +
geom_vline(aes(xintercept=0),
colour = "red") + geom_line() +
xlab("Prior value (not normalized)") +
xlab("Distance to range edge (km)")
## calculate the expert range prior
expert = rangeOffset(
rdist,
dists = dists,
parms = c(
prob = 0.9,
rate = 0.05,
skew = 0.4,
shift = 0
),
normalize = TRUE,
verbose = TRUE
)
## View the metadata
metadata(expert)$parms
## plot it
plot(expert)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.