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

Randomisation for loo_pit of discrete data. #121

Merged
merged 5 commits into from
Feb 22, 2024

Conversation

TeemuSailynoja
Copy link
Contributor

Fixes issue #22

I added randomisation to the loo_pit function so that it can be used for discrete data too.

Essentially, when computing pit, we check if the posterior sample contains an exact match to the observation.
In the case an exact match is found, the pit is randomised.

I also added a check that the log weights are finite and not NULL, as well as a warning, if the loo_pit values contain values greater than 1, which can happen with non-normalized weights.

Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TeemuSailynoja! Just a few minor comments.

tests/testthat/test-default-methods.R Outdated Show resolved Hide resolved
R/loo-functions.R Show resolved Hide resolved
@jgabry
Copy link
Member

jgabry commented Feb 7, 2024

Also, can you save the new RDS files using saveRDS(..., version = 2)? That should get rid of the message in R cmd check about serialization and adding a dependency on R > 3.5 (https://github.com/stan-dev/rstantools/actions/runs/7798510507/job/21295468864?pr=121#step:6:51). Although maybe we should require R > 3.5 anyway, but we can do that later.

@TeemuSailynoja
Copy link
Contributor Author

Thank you, @jgabry. I hope to have addressed all the requested changes and additions in the last commits.
Also, I fixed an error preventing some of the documentation being parsed, as there was a line break at the > in GPL >= 3, which caused the line starting with > to be parsed as a block quote.

Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @TeemuSailynoja, this looks good!

@jgabry
Copy link
Member

jgabry commented Feb 22, 2024

@andrjohns The StanFunctions Support checks are failing due to a compilation issue with the lgpr package, but that must be unrelated to this PR (this PR doesn't touch anything relevant for that), so I will go ahead and merge and we can sort out whatever is causing those failures before we do a release.

@jgabry jgabry merged commit 79114fb into stan-dev:master Feb 22, 2024
4 of 6 checks passed
@andrjohns
Copy link
Collaborator

@andrjohns The StanFunctions Support checks are failing due to a compilation issue with the lgpr package, but that must be unrelated to this PR (this PR doesn't touch anything relevant for that), so I will go ahead and merge and we can sort out whatever is causing those failures before we do a release.

Ah yeah, unrelated to this PR. Upstream changed the type of the RNG used in Stan, so we need to update to match

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

Successfully merging this pull request may close these issues.

3 participants