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

predict.dsmodel not exported from namespace in 1.0.8 #171

Open
erex opened this issue Aug 1, 2023 · 3 comments
Open

predict.dsmodel not exported from namespace in 1.0.8 #171

erex opened this issue Aug 1, 2023 · 3 comments

Comments

@erex
Copy link
Member

erex commented Aug 1, 2023

Email from a user:

I want to use it to obtain probability of detection for each of my sightings. However, the predict.dsmodel looks like it is not available in the newest version of the ds package. Are there other functions or packages I can use to obtain these probabilities?

Checking via an MRE, I find this is true, so offered these alternatives:

But it is easy to remedy. You can either use the "triple colon" trick to access functions within a package that are not exported. Or you can simply call the generic function predict​ that checks what type of model object it has received and call the appropriate function as a result. Here is an example of both (showing they produce identical results) using the amakihi​ dataset because I wanted a covariate in my detection function model so predict is doing something interesting:

library(Distance)
data("amakihi")
cu <- convert_units("meter", NULL, "square kilometer")
fitobs <- ds(amakihi, transect = "point", key="hr",
             truncation = 83, formula=~"OBs")
mypredict <- Distance:::predict.dsmodel(fitobs, compute=TRUE)
mypred2 <- predict(fitobs, compute = TRUE)
identical(mypredict, mypred2)
table(mypredict)

I presume the function in question should be exported in the next release.

@lenthomas
Copy link
Member

I'm no expert, but it's not clear to me that S3 methods should be in the namespace. See, for example this stackoverflow post from some years ago. I expect there's more recent and definitive advice somewhere, perhaps in the roxygen2 documentation -- @LHMarshall, do you have an opinion here?

@erex
Copy link
Member Author

erex commented Aug 3, 2023

Perhaps the confusion on the part of the user is derived from the existence of help for the function predict.dsmodel. By looking at the list of functions in the package, they thought they should be able to call that function
image
I don't know how to alleviate the confusion.

@lenthomas
Copy link
Member

Yes, seems like a reasonable expectation that a function documented in the help for a package is exported, unless noted otherwise. Let's see if @LHMarshall knows what best practice is around this general issue and the predict method in particular (as well as other "generic" methods associated with objects such as the summary method) otherwise I'll look into it.

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

2 participants