data(linetran)
(dbreaksLine <- c(0, 5, 10, 15, 20))
lengths <- linetran$Length
ltUMF <- with(linetran, {
unmarkedFrameDS(y = cbind(dc1, dc2, dc3, dc4),
siteCovs = data.frame(Length, area, habitat), dist.breaks = dbreaksLine,
tlength = lengths*1000, survey = "line", unitsIn = "m")
})
# Fit a model
(fm <- distsamp(~area ~habitat, ltUMF))
# Function returning two fit-stats: sum of squared errors and population size at
# sampled plots.
fitStats <- function(fit) {
sse <- SSE(fit)
plot.area.ha <- lengths*1000 * 40 / 10000
N <- sum(predict(fit, type="state")$Predicted*plot.area.ha, na.rm=TRUE)
return(c(sse, N.hat=N))
}
(pb <- parboot(fm, fitStats, nsim=25))
plot(pb, main="")
Run the code above in your browser using DataLab