## 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)
## GRTS sample of mini-grids within a rectangle
## edgemethod = 'allinside' avoids truncation at edge
minigrid <- make.grid(nx = 3, ny = 3, spacing = 50,
detector = 'proximity')
tempgrid <- trap.builder (n = 20, cluster = minigrid,
method = 'GRTS', edgemethod = 'allinside', region =
cbind(x = c(0,6000,6000,0), y = c(0,0,6000,6000)),
plt = TRUE)
## one detector in each 100-m grid cell -
## a form of stratified simple random sample
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')
plot(temp, border = 0) ## default grid is 100 m
## regular lattice of mini-arrays
tempgrid <- trap.builder (cluster = minigrid , method =
'all', frame = expand.grid(x = seq(1000, 5000, 2000),
y = seq(1000, 5000, 2000)), plt = TRUE)
## simulate some data
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)
secr.fit(tempcapt, mask = tempmask1) ## 241.52 s
tempmask2 <- make.mask(minigrid, spacing = 10)
secr.fit(mash(tempcapt), mask = tempmask2) ## 2.85 s
## density estimate is adjusted automatically
## for the number of mashed clusters (9)
## 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)Run the code above in your browser using DataLab