# Compute percentage of accumulator, neutral an repeller species (for ISAR) in Lansing woods
# In this example, against a null model of IPP.
data(lansing)
# Compute rISAR and plot envelopes for an inhomogeneous Poisson model
# of each species in San Francisco plot
# Split sfsp point pattern ppp by species
lansing.sp<- split(lansing)
# Set parameters for the simulations, estimation of intensity surface for IPP, etc.
# BEWARE: THIS is for R-TESTING ALONE. REAL TESTS SHOULD EMPLOY 199 simulations or higher
nsim<-8
r<- seq(0.01,0.25, by=0.01)
# Create list to store the results
isar.lansing<- list()
# start computation
for( i in 1: length(lansing.sp)){
print(i)
# estimate intensity of the focal species
lambda<- density(lansing.sp[[i]])
# obtain simulated patterns were all species except the focal remain fixed
# and the focal varies according to an inhomomgeneous Poiisson process
simulados<- multifocalsimulator(lansing, mimark=levels(lansing$marks)[i],
simulate=expression(rpoispp(lambda)), nsim=nsim)
# compute isar and envelopes for each species
# It is COMPULSORY that the argument "savefuns" it is set to TRUE
isar.lansing[[i]] <- envelope(lansing, isar, mimark=levels(lansing$marks)[i], r=r,
simulate=simulados,nsim=nsim, savefuns=TRUE, buffer=0)
}
prop.isar.lansing <- proportion.idar(isar.lansing)
head(prop.isar.lansing $percentage)
head(prop.isar.lansing $behaviour)
plot(prop.isar.lansing, p.legend=c(0.15,60))
if (FALSE) {
# Compute percentage of accumulator, neutral an repeller species (for ISAR) in San Francisco
# forest. In this example, against a null model of IPP.
data(SF)
# 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 ISAR and plot envelopes for an inhomogeneous Poisson model
# of each species in San Francisco plot
# Split sfsp point pattern ppp by species
sfsp.sp<- split(sfsp)
# Select species with >= 10 individuals (to get some statistical power)
sfsp10 <- sapply(sfsp.sp, function(x) x$n>=10)
#Get names of those species
nombressf<- names(sfsp10[sfsp10])
# Set parameters for the simulations, estimation of intensity surface for IPP, etc.
nsim<-199
nmin<-10
sigma <- 8
r<- seq(1,15, by=0.5)
# Create list to store the results
isar.sf<- list()
# start computation
# BEWARE: THIS TAKES QUITE A FEW MINUTES!!!
for( sp in nombressf){
print(sp)
# estimate intensity of the focal species
lambda<- density(unmark(sfsp[sfsp$marks==sp]), sigma=sigma, positive=TRUE)
# obtain simulated patterns were all species except the focal remain fixed
# and the focal varies according to an inhomomgeneous Poiisson process
simulados<- multifocalsimulator(sfsp, mimark=sp,
simulate=expression(rpoispp(lambda)), nsim=nsim,nmin=nmin)
# compute isar and envelopes for each species
# It is COMPULSORY that the argument "savefuns" it is set to TRUE
isar.sf[[sp]] <- envelope(sfsp, isar, mimark=sp, r=r,
simulate=simulados,nsim=nsim, savefuns=TRUE, buffer=0)
}
prop.isar.SF <- proportion.idar(isar.sf)
head(prop.isar.SF$percentage)
head(prop.isar.SF$behaviour)
plot(prop.isar.SF)
}
Run the code above in your browser using DataLab