Here is a brute force method that uses what's in the
unmarkedFrameGDS (
umf) and the
gdistsamp output (
m1) . It assumes, of course, that there are no detection covariates and that you're using the default half-normal detection curve.
# Fit the model
m1 <- gdistsamp(~1, ~1, ~1, umf, output="density", K=50)
# Estimate of detection parameter
sigma <- backTransform(m1, type="det")@estimate
# Get counts for each bin
nBins <- dim(umf@y)[2]/umf@numPrimary
binNum <- rep(c(1:nBins), umf@numPrimary)
counts <- tapply(colSums(umf@y), binNum, sum)
# Determine bin widths and largest distance
binWidths <- diff(u...@dist.breaks)
maxDistance <- max(u...@dist.breaks)
# Area under detection curve (assuming half-normal detection curve)
area <- integrate(function(x) exp(-x^2/(2*sigma^2)), 0, maxDistance)$value
# Adjust counts to have same area
adjusted.counts <- area*counts/sum(binWidths * counts)
# Plot "histogram" bars with same area as detection curve
barplot(adjusted.counts, binWidths, col="white", space=0, names.arg="", ylim=c(0,1.1),
las=1, xlab="Distance (m)", ylab="Detection probability")
axis(1)
box()
# Plot detection curve
plot(function(x) exp(-(x)^2/(2*sigma^2)), 0, maxDistance, lwd=3, add=TRUE)
