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

Failure for group with single x-level #51

Closed
billdenney opened this issue Sep 12, 2023 · 2 comments · Fixed by #52
Closed

Failure for group with single x-level #51

billdenney opened this issue Sep 12, 2023 · 2 comments · Fixed by #52

Comments

@billdenney
Copy link

The default of "jenks" binning fails when there is a single value for a group. My first thought is that if there is a single x-value for a group then perhaps a narrow range around the x-range and do the VPC calculations just on that value with the binning as that value by itself, but there definitely could be other ideas.

The underlying error below comes from the classInt package, but I think that makes sense for classInt to give an error and we should probably detect single-value groups before sending it for interval selection.

library(tidyverse)
#> Warning: package 'ggplot2' was built under R version 4.3.1
#> Warning: package 'purrr' was built under R version 4.3.1
library(tidyvpc)
#> tidyvpc is part of Certara.R!
#> Follow the link below to learn more about PMx R package development at Certara.
#> https://certara.github.io/R-Certara/

d_obs <-
  data.frame(
    group = rep(c("Patient", "Healthy"), each = 5),
    conc = c(rep(0, 5), 1:5),
    value = 1:10
  )

d_sim <-
  d_obs[rep(1:nrow(d_obs), 5), ]

observed(d_obs, x = conc, yobs = value) %>%
  simulated(d_sim, xsim = conc, ysim = value) %>%
  stratify(~group) %>%
  binning(bin = "jenks") %>%
  vpcstats(qpred = c(0.1, 0.5, 0.9))
#> Error in (function (var, n, style = "quantile", rtimes = 3, ..., intervalClosure = c("left", : single unique value

Created on 2023-09-12 with reprex v2.0.2

@billdenney
Copy link
Author

FYI, I'm working on a PR that should address this.

@billdenney
Copy link
Author

Alright, the potential fixes are in the indicated PRs. I made it as two separate PRs since the calculation part seemed straight-forward and may require less thought/discussion while the plotting part seemed more opinion-based, so it may require more thought/discussion.

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 a pull request may close this issue.

1 participant