a graph of the detection function fit to the data

262 views
Skip to first unread message

Ngwe Lwin

unread,
Sep 21, 2021, 11:53:22 AM9/21/21
to unmarked
Hello everyone,

I am using gdistamp for analyzing of the gibbon density.
I can plot detection probability with distance but I would like to show a graph of the detection function fit to the data. 
Can any of you let me know how to do it?
best regards,
Ngwe Lwin

 

Ngwe Lwin

unread,
Sep 24, 2021, 9:59:39 AM9/24/21
to unmarked
Dear All,
I am a beginner for using unmarked package. I am currently analyzing Gibbon density with gdistsamp. 
I can plot detection probability with distance (please see upper graph). But I would like to show a graph of detection function fit to the data as like lower graph.
I would like to request someone to let me know how to do it. 
 best regards,
Ngwe Lwin
graph1.jpggraph2.jpg

Jim Baldwin

unread,
Sep 24, 2021, 10:57:13 AM9/24/21
to unma...@googlegroups.com
Just to clarify:  are you wanting the equivalent of the histogram provided by PROGRAM DISTANCE (https://distancesampling.org/) which is a histogram of the observed distances (or rather the frequencies of the observed distance classes) vertically scaled to "match" the predicted detection function?  (As in the example that you give, those heights can be larger than 1.)  The scaling is such that the area under the detection curve is the same as the area of the histogram bars.

Jim


--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/e33ceae6-0e21-4e8d-b1e1-eb5906b02fadn%40googlegroups.com.

Ngwe Lwin

unread,
Sep 24, 2021, 12:07:50 PM9/24/21
to unmarked
Dear Jim,
Thank you for the quick reply. I would like to get  histogram of the observed distances vertically scaled to "match" the predicted detection function.
best regards,
Ngwe Lwin

Jim Baldwin

unread,
Sep 24, 2021, 4:39:49 PM9/24/21
to unma...@googlegroups.com
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)

  
image.png

Jim



Ngwe Lwin

unread,
Sep 24, 2021, 11:16:16 PM9/24/21
to unmarked
Dear Jim,
Thank you very much for your quick reply and kind support to solve my issues. 
best regards,
Ngwe Lwin

Ngwe Lwin

unread,
Sep 27, 2021, 12:38:32 PM9/27/21
to unmarked
Dear Jim,
I would like to ask one more question on the script. 
We are now able to do the detection graph (please see below script and figure). 
Our data is from the point count. I would like to ask you whether the script for point count and line transect to make a detection graph is the same or there will be different script for point count. 
Thank you for your support.  


best regards, 
Ngwe Lwindetection graph_25Sep.jpg
Reply all
Reply to author
Forward
0 new messages