plotting detection function

Skip to first unread message

Aditya Ghoshal

Jun 13, 2023, 5:19:06 AMJun 13
to distance-sampling
Hi everyone, 
I have a question on how to plot the empirical detection function from the histograms of sightings in R. I want to set g(x=0.15) as my truncation distance and in order to estimate that I want to plot the g(x). I understand that the probability density function f(x) can be plotted using 'density' function. But how should I go to g(x) from there? I apologize as this might be a question more related to R. 

Till now I have used the following codes for plotting g(x)

Since I have maximal detections close to the line it throws up a plot like this 

The histogram from which it was generated is below
Once I make the density I find the point where y=0.15 (using abline) and find the distance on the x axis. I do not think this is correct. Can you please shed some light? 

Eric Rexstad

Jun 13, 2023, 5:31:48 AMJun 13
to Aditya Ghoshal, distance-sampling

You are making the problem more difficult than it is.

To view the shape of the fitted detection function superimposed upon a histogram of detection distances, simply use the plot​ function upon the object created by the ds​ function:

simplefit <- ds(minke, key="hn", adjustment = NULL)
plot(simplefit, showpoints=FALSE)
abline(h=0.15, lwd=2, col="red")


From: <> on behalf of Aditya Ghoshal <>
Sent: 13 June 2023 10:19
To: distance-sampling <>
Subject: [distance-sampling] plotting detection function
You received this message because you are subscribed to the Google Groups "distance-sampling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Aditya Ghoshal

Jun 13, 2023, 5:49:38 AMJun 13
to distance-sampling
Thanks for the prompt response Eric.  So I just fit a detection function on my data before I select the truncation distance and then go ahead to the fitting the various models?
A couple of quick questions:
1.  should I be checking this preliminary fit with other key functions as well?
2. If I plan to use a covariate like region or sampling season in my final model do I need to incorporate it in this preliminary fitting? 

Thank you, 

Eric Rexstad

Jun 13, 2023, 5:52:46 AMJun 13
to Aditya Ghoshal, distance-sampling

Remember the truncation decision guidance (truncate where g(x)=0.15) is simply that "guidance". You need not dwell upon that decision too long.

Sent: 13 June 2023 10:49
To: distance-sampling <>
Subject: Re: [distance-sampling] plotting detection function

Aditya Ghoshal

Jun 13, 2023, 5:58:11 AMJun 13
to distance-sampling
Right. Also I just saw that varying my truncation distance by even 50 m does not make any appreciable difference to my estimates or their variances. However, my dataset also has species where I may not have sufficient detections (less than 40 detections pooled over regions and two sampling seasons). In that case including outlier detections would have a greater impact on the estimates?   
Reply all
Reply to author
0 new messages