Using dht2 function with binned data

92 views
Skip to first unread message

Vedika Dutta

unread,
Nov 3, 2022, 2:00:01 AM11/3/22
to distance-sampling
Hi everyone,

I write to humbly request help regarding the analysis of the multi-species point count data using Multispecies covariate distance sampling. In order to estiate individual densities of birds in a landuse, I employed the dh2 function post determing the aic model and detection function.

I am being presented with the following error and am unable to figure it out.
> x <- dht2(ddf=y, flatfile=z, strat_formula = ~Species, convert_units = conversion.factor, stratification = "object")
Error in if (!(c("distend", "distbegin") %in% names(flatfile))) { :
  the condition has length > 1


For reference, my data is binned and thus rather than distance coloum I have distbegin and distend coloums. Please suggest solutions for the same.

Thanking you
Regards,
Vedika


Eric Rexstad

unread,
Nov 3, 2022, 5:00:16 AM11/3/22
to Vedika Dutta, distance-sampling
Vedika

We will look into this and get back to you quickly.  Thanks for reporting this.

From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Vedika Dutta <dutta...@gmail.com>
Sent: 03 November 2022 06:00
To: distance-sampling <distance...@googlegroups.com>
Subject: [distance-sampling] Using dht2 function with binned data
 
--
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 distance-sampl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/e968155e-99b5-454f-85e0-b116e920b5ban%40googlegroups.com.

Laura Marshall

unread,
Nov 3, 2022, 5:41:44 AM11/3/22
to Vedika Dutta, distance-sampling, Eric Rexstad
Hi Vedika,

This looks like it might be a bug, could you please send me your data and code and I will take a look and make sure we get it working for you.
You can send it off list privately to l...@st-andrews.ac.uk please.

Best wishes,
Laura


Dr. L Marshall

Centre for Research into Ecological & Environmental Modelling

University of St. Andrews

Tel: +44 (0)1334 461808


Please note that my core working hours are now concentrated between 9am Tuesday and 1pm Thursday. There may be a delay in my response to E-mails outwith these times.




From: 'Eric Rexstad' via distance-sampling <distance...@googlegroups.com>
Sent: 03 November 2022 09:00
To: Vedika Dutta <dutta...@gmail.com>; distance-sampling <distance...@googlegroups.com>
Subject: Re: [distance-sampling] Using dht2 function with binned data
 

vaughn...@gmail.com

unread,
Dec 6, 2022, 11:40:32 AM12/6/22
to distance-sampling
Hi 
I am getting errors using the bootdht function with binned distance data. Possibly related to the above issue.. I am able to get my code to work using the dht2 function but would like to use the bootstrap.

Here is the code I ran but let me know if you need more.

code:

# Create data frame with data for the multiplier
availability = data.frame(rate = P_a, SE = Pa_se2)


#create list for multiplier  - see the example resource for notes on the terminology of 'decay'
multiplier <- list(creation = availability)

#model to estimate number of individuals

> fm_repeats0_Nhat<-bootdht(model = hn0,

+                           flatfile  = GCPA_data,

+                           convert_units= unit_conversion,

+                           summary_fun = bootdht_Nhat_summarize,

+                           nboot = 100,

+                           multipliers = multiplier,

+                           cores = 4)

Performing 100 bootstraps

Progress bars cannot be shown when using cores>1

 

> #Final estimates for number of individuals from distance sampling with availability multiplier

> summary(fm_repeats0_Nhat)

Bootstrap results

Boostraps          : 100

Successes          : 0

Failures           : 100

Eric Rexstad

unread,
Dec 6, 2022, 11:56:28 AM12/6/22
to vaughn...@gmail.com, distance-sampling
Vaughn

Thanks for your question. There has been work done on dht2​ in the past month. Can you tell us, maybe offline, what version of Distance you are using? Probably send same information regarding version of mrds​ package as well. Are you using versions from CRAN or pulling them from Github.

That will help us in the first instance; we might later want to see the rest of the code.  This is camera trap data, am I correct?

Eric Rexstad

unread,
Dec 9, 2022, 10:31:08 AM12/9/22
to distance-sampling
List:

After some investigation, we got to the bottom of Vaughn's problems with bootdht​. The work-around might be useful to others in his situation.

He had data where distances were binned and he was using distbegin​ and distend​ in his data file.  This caused bootdht​ to fail. (We have logged this as a bug).

The work-around is to replace the distbegin​ and distend​ fields in the data with the average of the two, labelling that field distance​. You can then fit your detection function (using ds​) using the cutpoints​ argument in ds​ to establish the distance intervals in which the distances were measured.

The distbegin​ and distend​ manner for recording distances in data is really only necessary in the rare situation when distance interval cutpoints change between observations, e.g. aerial surveys with changing altitude.


From: 'Eric Rexstad' via distance-sampling <distance...@googlegroups.com>
Sent: 06 December 2022 16:56
To: vaughn...@gmail.com <vaughn...@gmail.com>; distance-sampling <distance...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages