Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dht2() incorrectly handling binned distances with truncation #175

Open
erex opened this issue Dec 6, 2023 · 1 comment
Open

dht2() incorrectly handling binned distances with truncation #175

erex opened this issue Dec 6, 2023 · 1 comment

Comments

@erex
Copy link
Member

erex commented Dec 6, 2023

Email from user:

I'm having a few problems calculating density/abundance using dht2 and flatfiles that I have never had before.
dht2 doesn't seem to be choosing the right observations based on truncation distance. In the screenshot attached, it shows that there are six observations being used, but there are 7 in the file and only 5 are within the truncation distance (2km).
Additionally, in some other cases, I get this error:
Error in $<-.data.frame(*tmp*, "distance", value = 0.0709) : replacement has 1 row, data has 0
The distance value 0.0709 is specified as the left truncation distance in the detection function - but there are never detections at exactly that distance so I don't know why this error would show up in only some instances.

I'm not sure how much testing dht2 has received when using binned data with truncation.

@erex
Copy link
Member Author

erex commented Jan 15, 2024

Follow up with original user still shows challenges when taking exact distance data, specifying both cutpoints and truncation. Nothing to do with dht2, but rather an issue with ds.

Demonstration of problem:

bins <- c(0.0709, .2315, .463, .926, 1.852)
AllHWhr <- ds(data=All_HW, key="hr", adjustment=NULL, cutpoint = bins,
              truncation=list(left=0.0709, right = 3.704),
              optimizer = "MCDS")

results in

Summary for ds object
Number of observations :  64 
Distance range         :  0.0709  -  3.704 
AIC                    :  212.8108 

In contrast, the following call to ds

bins2 <- c(0.0709, .2315, .463, .926, 1.852, 3.704)
AllHWhr.bins2 <- ds(data=All_HW, key="hr", adjustment=NULL, cutpoint = bins2,
                    truncation=list(left=0.0709, right = 3.704),
                    optimizer = "MCDS")

results in

Summary for ds object
Number of observations :  81 
Distance range         :  0.0709  -  3.704 
AIC                    :  255.4857 

I presume the values labelled Distance range are taken from truncation and in the first call to ds the reported Distance range is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant