# Use the maximum patch size as indicator of degradation
maxpatchsize <- function(mat) {
max(patchsizes(mat))
}
# Create the indicator function
maxpatch_sews <- create_indicator(maxpatchsize)
# Then work with this function as if it were a function from the *_sews
# family.
mp_indic <- maxpatch_sews(forestgap)
summary(mp_indic)
# \donttest{
# Assess significance and display trends
mp_test <- indictest(mp_indic, nulln = 49)
plot(mp_test)
# }
# Try spatial coefficient of variation as a spatial EWS. This function can
# have arguments.
spatial_cv <- function(mat, subsize) {
matc <- coarse_grain(mat, subsize)
return( sd(matc) / mean(matc) )
}
# Create indicator function
cv_sews <- create_indicator(spatial_cv)
# Compute and display trends
cv_indic <- cv_sews(serengeti, subsize = 3)
plot(cv_indic, along = serengeti.rain)
# We can do the same work in one go using compute_indicator
cv_indic2 <- compute_indicator(serengeti, spatial_cv, subsize = 3)
plot(cv_indic2, along = serengeti.rain)
# \donttest{
indictest(cv_indic, nulln = 99)
# }
Run the code above in your browser using DataLab