Distsamp; Error when fitting detection covariate

22 views
Skip to first unread message

Wyatt Wolf

unread,
Oct 27, 2025, 6:16:34 PM (3 days ago) Oct 27
to unmarked
Hi unmarked community,

I first would like to thank everyone for posting and collaborating to keep this community active, as I have received a lot of help in my analysis browsing these pages. 

Brief overview of my research and analysis: I am using distance sampling to estimate the abundance Paddlefish counted on side scan sonar images. We find that the pelagic nature of Paddlefish causes the detection probability of these creatures on sonar to decrease as distance from the boat increases, and distsamp is showing promise in determining the abundance of these animals in this way. 

My problem: I hypothesize that the depth of the water affects the sonar image quality in the extremely deep parts of the lakes we are surveying (>15m) and subsequently I believe that the distortion of the sonar image may decrease our ability to detect Paddlefish in these areas. In order to better understand this, I am attempting to fit models where the (mean_depth) of each transect is used as a detection covariate and/or an abundance covariate (in the case Paddlefish distribution is affected by depth). What I have found is that all four keyfun fit when Mean_depth is an abundance covariate, however I receive the error "Error in .local(x, ...) : This method only works when there are no detection covars" when trying to fit mean_depth as a detection covariate using exp, halfnormal, and hazard key functions. Has anyone encountered this issue/ know where I am going wrong? I apologize if there is a simple reason why this is not working, as I am a novice user and not very good at math. Below is an excerpt of some of my models. 


exp1<-distsamp(~1~1, umf, keyfun="exp", output="density",unitsOut="ha", se=TRUE)
halfnorm1<-distsamp(~1~1, umf, keyfun="halfnorm", output="density",unitsOut="ha", se=TRUE)
hazard1<-distsamp(~1~1, umf, keyfun="hazard", output="density",unitsOut="ha", se=TRUE)
uniform1<-distsamp(~1~1, umf, keyfun="uniform", output="density",unitsOut="ha", se=TRUE)
exp_wDepth4abund<-distsamp(~1~Mean_Depth_m, umf, keyfun="exp", output="density",unitsOut="ha", se=TRUE)
halfnorm_wDepth4abund<-distsamp(~1~Mean_Depth_m, umf, keyfun="halfnorm", output="density",unitsOut="ha", se=TRUE)
hazard_wDepth4abund<-distsamp(~1~Mean_Depth_m, umf, keyfun="hazard", output="density",unitsOut="ha", se=TRUE)
uniform_wDepth4abund<-distsamp(~1~Mean_Depth_m, umf, keyfun="uniform", output="density",unitsOut="ha", se=TRUE)
exp_wDepth4det<-distsamp(~Mean_Depth_m~1, umf, keyfun="exp", output="density",unitsOut="ha", se=TRUE)
halfnorm_wDepth4det<-distsamp(~Mean_Depth_m~1, umf, keyfun="halfnorm", output="density",unitsOut="ha", se=TRUE)
hazard_wDepth4det<-distsamp(~Mean_Depth_m~1, umf, keyfun="hazard", output="density",unitsOut="ha", se=TRUE)
uniform_wDepth4det<-distsamp(~Mean_Depth_m~1, umf, keyfun="uniform", output="density",unitsOut="ha", se=TRUE)

Thank You, 

Wyatt Wolfenkoehler
Natural Resource Ecology and Management Graduate Research Assistant
Ok State Student Sub Unit AFS Vice President


"...to cultivate and care for it." 

Ken Kellner

unread,
Oct 27, 2025, 6:20:48 PM (3 days ago) Oct 27
to unmarked
Hi Wyatt,

Normally this error occurs only when you run the hist() function on a fitted distance sampling model that contains covariates on detection. This is normal - the function is currently just limited that way, it doesn't mean there's something wrong the model.

Are you actually getting this error when fitting the model, i.e., does the error appear specifically right after you run the line of code containing 'distsamp()'? Or is it possible you have another line of code that runs hist() after fitting the model?

Ken

Wyatt Wolf

unread,
Oct 27, 2025, 6:42:06 PM (3 days ago) Oct 27
to unma...@googlegroups.com
Hi Ken. I appreciate the response. As I was thinking, this was a simple problem that I was having and I simply didn’t know the fundamentals of how the package operates. After a closer look the error does appear after I run the histogram function. I thought it was related to the model itself, but knowing this is just an issue with hist() is good news! 

Best,
Wyatt 

--
*** Three hierarchical modeling email lists ***
(1) unmarked (this list): for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology: for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2021) and Schaub & Kéry (2022)
---
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 visit https://groups.google.com/d/msgid/unmarked/2e8ac028-6079-47fc-ae2b-11c337826164n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages