## solitary detectors placed randomly within a rectangle
tempgrid <- trap.builder (n = 10, method = "SRS",
region = cbind(x = c(0,1000,1000,0),
y = c(0,0,1000,1000)), plt = TRUE)
## one detector in each 100-m grid cell -
## a form of stratified simple random sample
## see also Examples in ?make.grid
origins <- expand.grid(x = seq(0, 900, 100),
y = seq(0, 1100, 100))
XY <- origins + runif(10 * 12 * 2) * 100
temp <- trap.builder (frame = XY, method = "all",
detector = "multi")
## same as temp <- read.traps(data = XY)
plot(temp, border = 0) ## default grid is 100 m
if (FALSE) {
## simulate some data
## regular lattice of mini-arrays
minigrid <- make.grid(nx = 3, ny = 3, spacing = 50,
detector = "proximity")
tempgrid <- trap.builder (cluster = minigrid , method =
"all", frame = expand.grid(x = seq(1000, 5000, 2000),
y = seq(1000, 5000, 2000)), plt = TRUE)
tempcapt <- sim.capthist(tempgrid, popn = list(D = 10))
cluster.counts(tempcapt)
cluster.centres(tempgrid)
## "mash" the CH
summary(mash(tempcapt))
## compare timings (estimates are near identical)
tempmask1 <- make.mask(tempgrid, type = "clusterrect",
buffer = 200, spacing = 10)
fit1 <- secr.fit(tempcapt, mask = tempmask1, trace = FALSE)
tempmask2 <- make.mask(minigrid, spacing = 10)
fit2 <- secr.fit(mash(tempcapt), mask = tempmask2, trace = FALSE)
## density estimate is adjusted automatically
## for the number of mashed clusters (9)
predict(fit1)
predict(fit2)
fit1$proctime
fit2$proctime
## SRS excluding detectors from a polygon
region <- cbind(x = c(0,6000,6000,0,0), y = c(0,0,6000,6000,0))
exclude <- cbind(x = c(3000,7000,7000,3000,3000), y = c(2000,2000,4000,4000,2000))
newgrid <- trap.builder (n = 40, cluster = minigrid,
method = "SRS", edgemethod = "allinside", region = region,
exclude = exclude, exclmethod = "alloutside",
plt = TRUE)
## two-phase design: preliminary sample across region,
## followed by selection of sites for intensive grids
arena <- data.frame(x = c(0,2000,2000,0), y = c(0,0,2500,2500))
t1 <- make.grid(nx = 1, ny = 1)
t4 <- make.grid(nx = 4, ny = 4, spacing = 50)
singletraps <- make.systematic (n = c(8,10), cluster = t1,
region = arena)
CH <- sim.capthist(singletraps, popn = list(D = 2))
plot(CH, type = "n.per.cluster", title = "Number per cluster")
temp <- trap.builder(10, frame = traps(CH), cluster = t4,
ranks = cluster.counts(CH), method = "rank",
edgemethod = "allowoverlap", plt = TRUE, add = TRUE)
## GRTS sample of mini-grids within a rectangle
## GRTS uses package 'spsurvey' >= 5.3.0
minigrid <- make.grid(nx = 3, ny = 3, spacing = 50,
detector = "proximity")
region <- cbind(x = c(0,6000,6000,0,0), y = c(0,0,6000,6000,0))
if (requireNamespace("spsurvey", versionCheck = list(version = ">=5.3.0"))) {
tempgrid <- trap.builder (n = 20, cluster = minigrid, region = region,
plt = TRUE, method = "GRTS")
# specifying minimum distance between cluster origins
tempgrid2 <- trap.builder (n = 20, cluster = minigrid, region = region,
plt = TRUE, method = "GRTS", mindis = 500, maxtry = 10)
# use spsurvey::warnprnt() to view warnings (e.g., maxtry inadequate)
}
}
Run the code above in your browser using DataLab