Difference distance sampling software for Windows and R package

49 views
Skip to first unread message

Nadia C.

unread,
Dec 14, 2022, 7:18:41 AM12/14/22
to distance-sampling
Hello everyone. 

Some years ago (2018) I did my PhD thesis about abundance of dolphins using both distance software for windows and R packages. First I selected the detection function using Distance software and then I programmed the function selected in R studio and I run the density surface models there and all went well.

Now I need to run the models again, using the same data and the result is not the same. I can not run with the R package the hazard rate function selected for a specific truncation distance and with bins, but I can do it with the distance software and this function is still the better one for this software.
In R studio the error is: 
"Error in integrate: the integral is probably divergent. All models failed to fit."
This error only happens with binned data for a determined truncation distance.

I tried doing first  the truncation and then the bins but it is also not working. Maybe, something changed in the packages of R and because of that I can not run the function again? Any help is appreciated.

Thanks! Nadia
 

Eric Rexstad

unread,
Dec 14, 2022, 9:07:53 AM12/14/22
to Nadia C., distance-sampling
Nadia

The Distance R package has received lots of coding attention in the past four years. It was quite new in 2018 and considerable attention has been devoted to the detection function fitting algorithm.

Do I correctly understand your description: for a specific truncation distance and combination of cutpoints for the bins, fitting a hazard rate detection function to your data set fails. Fitting the model to exact distances and binned data with different truncation distances produces a fitted model.  Is that correct?

Seems the challenge is specific to your data set. To diagnose the challenge further, I would need to look at the data in question. Are you willing to send along your data (off list) so I could see what I discover?

From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Nadia C. <nscu...@gmail.com>
Sent: 14 December 2022 12:18
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} [distance-sampling] Difference distance sampling software for Windows and R package
 
--
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/dfcd6ada-4ab7-4e95-9fc6-ec22086dff53n%40googlegroups.com.

Eric Rexstad

unread,
Dec 15, 2022, 7:16:29 AM12/15/22
to Nadia C., distance-sampling
Nadia

Adding to my comment from yesterday. If you wish to replicate the detection function modelling you performed in 2018, it is possible to "go back in time" by installing older versions of R packages. This is the spirit of reproducible analyses.  The details of installing old versions can be found at this website:

Why install an older version of a package? You may need to install an older version of a package if the package has changed in a way that is incompatible with the version of R you have installed, ...
The trick is to know which version of the package you need to install. You indicated your thesis was done in 2018, based upon that, I went back into the R-project archives associated with R version 3.3, released in 2018:

From this I learned the version of the Distance package in use in 2018 was probably version 0.9.7. However, to reproduce your detection function modelling, you would also need the version of the mrds​ package in existence at that time.  Using the same archive website as above, I deduced you were likely using version 2.1.18 of mrds.

Those two packages would need to be installed on your computer using the devtools::install_version()​ function as shown on the Posit website instructions. However, they will need to be "built from source". To do that, you will need to install the "RTools" toolchain onto your computer prior​ to downloading the two packages. Instructions for downloading/installing the "RTools" software can be found at this link and depends upon what version of R you currently have installed on your computer:


Having done that (considerable) setup, you can then analyse your data using the same version of the software you (probably) used in 2018.  When I did so, I was able to successfully fit a hazard rate detection function to your binned data. I'll write a separate note to you about the data.
General take-away from this message, it is important to document the version numbers of the R packages used for analyses you may repeat in the future. With the version numbers and instructions provided in this email, it is possible to install archived versions of R packages from CRAN to replicate past analyses.


From: distance...@googlegroups.com <distance...@googlegroups.com> on behalf of Nadia C. <nscu...@gmail.com>
Sent: 14 December 2022 12:18
To: distance-sampling <distance...@googlegroups.com>
Subject: {Suspected Spam} [distance-sampling] Difference distance sampling software for Windows and R package
 
--
Reply all
Reply to author
Forward
0 new messages