Learn R Programming

landmap (version 0.0.13)

spsample.prob,SpatialPoints,SpatialPixelsDataFrame-method: Estimate occurrence probabilities of a sampling plan (points)

Description

Estimates occurrence probabilities as an average between the kernel density estimation (spreading of points in geographical space) and MaxLike analysis (spreading of points in feature space). The output 'iprob' indicates whether the sampling plan has systematically missed some important locations / features, and can be used as an input for modelling (e.g. as weights for regression modeling).

Usage

# S4 method for SpatialPoints,SpatialPixelsDataFrame
spsample.prob(observations, covariates, quant.nndist = 0.95, n.sigma, ...)

Arguments

observations

SpatialPoints.

covariates

SpatialPixelsDataFrame.

quant.nndist

quantile used for the threshold distance.

n.sigma

sigma parameter for density estimation.

...

optional arguments.

Value

Returns a list of objects where 'iprob' ("SpatialPixelsDataFrame") is the map showing the estimated occurrence probabilities.

References

  • Baddeley, A. (2008) Analysing spatial point patterns in R. Technical report, CSIRO Australia. Version 4.

  • Royle, J.A., Chandler, R.B., Yackulic, C. and J. D. Nichols. (2012) Likelihood analysis of species occurrence probability from presence-only data for modelling species distributions. Methods in Ecology and Evolution. 10.1111/j.2041-210X.2011.00182.x

Examples

Run this code
# NOT RUN {
if(requireNamespace("plotKML", quietly = TRUE) &
   requireNamespace("maxlike", quietly = TRUE) &
   requireNamespace("spatstat", quietly = TRUE) ){
library(plotKML)
library(maxlike)
library(spatstat)
library(maptools)
data(eberg)
data(eberg_grid)
## existing sampling plan:
sel <- runif(nrow(eberg)) < .2
eberg.xy <- eberg[sel,c("X","Y")]
coordinates(eberg.xy) <- ~X+Y
proj4string(eberg.xy) <- CRS("+init=epsg:31467")
## covariates:
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
## convert to continuous independent covariates:
formulaString <- ~ PRMGEO6+DEMSRT6+TWISRT6+TIRAST6
eberg_spc <- spc(eberg_grid, formulaString)
# }
# NOT RUN {
## derive occurrence probability:
covs <- eberg_spc@predicted[1:8]
iprob <- spsample.prob(eberg.xy, covs)
## Note: obvious omission areas:
hist(iprob[[1]]@data[,1], col="gray")

## compare with random sampling:
rnd <- spsample(eberg_grid, type="random",
                n=length(iprob[["observations"]]))
iprob2 <- spsample.prob(rnd, covs)

## compare the two next to each other:
op <- par(mfrow=c(1,2))
plot(raster(iprob[[1]]), zlim=c(0,1), col=SAGA_pal[[1]])
points(iprob[["observations"]])
plot(raster(iprob2[[1]]), zlim=c(0,1), col=SAGA_pal[[1]])
points(iprob2[["observations"]])
par(op)
while (!is.null(dev.list())) dev.off()

## fit a weighted lm:
eberg.xy <- eberg[sel,c("SNDMHT_A","X","Y")]
coordinates(eberg.xy) <- ~X+Y
proj4string(eberg.xy) <- CRS("+init=epsg:31467")
eberg.xy$iprob <- over(eberg.xy, iprob[[1]])$iprob
eberg.xy@data <- cbind(eberg.xy@data, over(eberg.xy, covs))
fs <- as.formula(paste("SNDMHT_A ~ ",
                       paste(names(covs), collapse="+")))
## the lower the occurrence probability, the higher the weight:
w <- 1/eberg.xy$iprob
m <- lm(fs, eberg.xy, weights=w)
summary(m)
## compare to standard lm:
m0 <- lm(fs, eberg.xy)
summary(m)$adj.r.squared
summary(m0)$adj.r.squared
# }
# NOT RUN {
}
# }

Run the code above in your browser using DataLab