issues with ds function?

Skip to first unread message

Pamela Narváez

Jul 13, 2021, 12:55:31 PMJul 13
to distance-sampling
Hi all,

I've been trying to run some simple code with the ds function (I've used this code before with no issues) but for some reason, it doesn't work anymore (It looks like it doesn't work for any of the species I'm doing). I've tried multiple things and I've shared the code with other people and they've had the same issues as me. I'm not sure what I'm doing wrong since it was working before; any help will be greatly appreciated!

Here's the code:
sp1<-read.csv(file="ds_sp1.csv", sep=",", h=T)
conversion <- convert_units("meter", "meter", "square kilometer")
DS_sp1<- ds(data = sp1, key="hn", convert.units = conversion)

This is the error I get after running the ds():
Starting AIC adjustment term selection.
Fitting half-normal key function
Key only model: not constraining for monotonicity.

 Problems with integration. integral <=0. Setting integral to 1E-25

 Problems with integration. integral <=0. Setting integral to 1E-25

 Problems with integration. integral <=0. Setting integral to 1E-25
Error in, optim.options, bounds, misc.options, fitting = "key") : 
  No convergence.

All models failed to fit!

Error in ds(data = sp1, key = "hn", convert.units = conversion) : 
  No models could be fitted.



Eric Rexstad

Jul 13, 2021, 1:40:10 PMJul 13
to Pamela Narváez, distance-sampling


There's no reason to suspect there is something wrong with the code.  The messages you are receiving indicate the function is having a hard time with the perpendicular distances you are giving it.

Have you done a simple plot of the perpendicular distance distribution to which you are trying to fit the half normal detection function?  The data may be a sufficiently bizarre shape that a detection function cannot be fitted.  Have a look at the plot and see what it tells you.  If the data look "well behaved", then perhaps we need a conversation off-list about what else to examine.

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
Eric Rexstad
Centre for Ecological and Environmental Modelling
University of St Andrews
St Andrews is a charity registered in Scotland SC013532
Reply all
Reply to author
0 new messages