midar {idar} | R Documentation |
Customize the Individual Diversity-Area Relationship Function
Description
A wrapper to develop new Individual Diversity-Area Relationship functions on the fly.
Usage
midar(mippp, mippp.sp = NULL, mimark = NULL, namesmark = NULL, traits = NULL,
tree = NULL, r = NULL, buffer = 0, bfw = NULL, what = NULL)
Arguments
mippp |
A multitype (a.k.a. multivariate) marked point pattern. An object with the ppp format of spatstat. |
mippp.sp |
Univariate point pattern of the focal species. An object with the ppp format of spatstat. |
mimark |
Character. Name of the focal species in the multitype |
namesmark |
Character. If the marks in |
buffer |
One of "adapt", i.e., compute an adaptive buffer, or a number indicating the width of a fixed buffer area around the plot border |
bfw |
An owin object indicating the limits of the buffer area. |
r |
Vector of distances to compute IDAR(r) functions |
tree |
A phylogenetic tree in |
traits |
A data.frame of traits, or a distance matrix among species (in |
what |
A valid R expression or function that would accept a community matrix (sites x species) and return a unique value |
Details
midar
allows computing new IDAR(r) functions. The basis of all idar functions are the local communities defined around each point (e.g., each tree) of a focal species (mimark
) for a certain circular neighborhood of radius r. Some diversity measure is computed on each community an the average of all of them is returned as the idar value for this r, i.e., as IDAR(r). The function midar
applies the R function or expression defined by the argument what
to each of the "community data tables" (matrices) generated by mitable
(one for each r interval defined by the argument r
) and return the result as a spatial summary function like all the others in the idar package (e.g., isar
or pisar
). The R expression or function should accept a community matrix (sites x species) as input and return a unique numeric value.
Value
midar
return an object of class fv
, see fv.object, which can be plotted directly using plot.fv.
Essentially, a data frame containing a column named r with the vector of values of the argument r at which the proposed function had been estimated and another column, named "midar" which contains an estimate of the selected function.
Simulation envelopes
To compute simulation envelopes for midar
functions, use envelope
. See the examples in this help page and in multifocalsimulator
to know how to compute simulation envelopes from appropriate null models.
Author(s)
Marcelino de la Cruz marcelino.delacruz@urjc.es
See Also
isar
or pisar
in this package.
Examples
data(SF)
data(SFphylotree)
# Discard the size mark and keep the species mark in SF ppp:
sfsp<- ppp(SF$x, SF$y, window=SF$window, marks=SF$marks$species)
# compute "individual Simpsom diversity-area relationship" around sp_44
# using function diversity from package vegan
require(vegan)
simpsom_sp_44<- midar(sfsp, mimark="sp_44", what =function(x) mean(diversity(x, "simpson")),
r=1:15)
# test "individual Simpsom diversity-area relationship" against an inhomogeneous Poisson
# null modellfor sp_44.
# estimate intensityh surface for sp_44
lambda<- density.ppp(unmark(sfsp[sfsp$marks=="sp_44"]), positive=TRUE)
# generate 19 realizations of the null model, keeping all the other species fixed in their
# original coordinates.
simulados<- multifocalsimulator(sfsp, mimark="sp_44", simulate=expression(rpoispp(lambda)),
nsim=19, nmin=15)
# for simplicity define the function that we want to apply to each "local community"
# around each tree of sp_44
mean_simpsom <- function(x) mean(diversity(x, "simpson"))
# compute envelopes and plot them.
simpsom_sp_44.env<-envelope(sfsp, midar, mimark="sp_44", what =mean_simpsom ,r=1:15,
nsim=19, simulate=simulados)
plot(simpsom_sp_44.env)
# compute IPSVAR(r) "by hand"
# first, check tree as would check it ipsvar
arbol <- checktree(SFphylotree, SF, "ipsvar", correct.phylo="exclude")
# define function to obtain the averge psv from the set of local communities
# at each neigborhood radii r
mipsv <- expression(mean(psv(x, tree=tree, compute.var=FALSE)$PSVs, na.rm=TRUE))
# compute ipsvar "by hand"
sp_44_psv<- midar(sfsp, mimark="sp_44", tree=arbol, what =mipsv ,r=1:15)
plot(sp_44_psv)
# compare it with the result of the built-in function
plot(ipsvar(sfsp, mimark="sp_44", tree=arbol, r=1:15), add=TRUE, col="blue")