Skip to content

Commit

Permalink
CRAN comments accomodates - bug fixes in plot.cumulcalib()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohsen Sadatsafavi committed Jun 7, 2024
1 parent f1170c3 commit ceb865b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version: 0.0.1
Authors@R:
person("Mohsen", "Sadatsafavi", , "mohsen.sadatsafavi@ubc.ca", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-0419-7862"))
Description: Tools for visualization of, and inference on, the calibration of prediction models on the cumulative calibration domain. This package implements the methodology described in Sadatsafavi and Patkau (2024) <doi:10.1002/sim.10138>. The core of the package is cumulcalib(), which takes in vectors of binary responses and predicted risks. The plot() and summary() methods are implemented for the results returned by cumulcalib().
Description: Tools for visualization of, and inference on, the calibration of prediction models on the cumulative calibration domain. This provides a method for evaluating calibration of risk prediction models without having to group the data or use tuning parameters (e.g., loess bandwidth). This package implements the methodology described in Sadatsafavi and Patkau (2024) <doi:10.1002/sim.10138>. The core of the package is cumulcalib(), which takes in vectors of binary responses and predicted risks. The plot() and summary() methods are implemented for the results returned by cumulcalib().
License: MIT + file LICENSE
URL: https://github.com/resplab/cumulcalib
Imports:
Expand All @@ -22,5 +22,5 @@ VignetteBuilder:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Language: en-US
27 changes: 14 additions & 13 deletions R/core.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ plot.cumulcalib <- function(x,...)
#' @method plot cumulcalib
plot.cumulcalib <- function(x, method=NULL, draw_stat=TRUE, stat_col=c('blue','red'), draw_sig=TRUE, sig_level=c(0.95,0.95), x2axis=TRUE, y2axis=TRUE, ...)
{
if(!(method %in% names(x$by_method)))
{
stop("Error: the requested method for plot() was not provided in the submitted cumulcalib object.")
}

oldpar <- par(no.readonly=TRUE)
on.exit(par(oldpar))

Expand All @@ -311,17 +316,20 @@ plot.cumulcalib <- function(x, method=NULL, draw_stat=TRUE, stat_col=c('blue','r
t_ <- x$data[,'t']
X <- x$data[,'X']
W <- x$data[,'S']

n <- length(W)
loc <- x$by_method[[method]]$loc

sign_p1 <- sign(W[n])
sign_p2 <- sign(W[x$by_method[[method]]$loc])

if(method=="BCI1p") #The only method that messes with S when drawing it.
if(method %in% c("BB","BB1p","BB2p"))
{
sign_p2 <- sign(W[loc]-t_[loc]*W[n])
}
else
{
W<-W-t_*W[n]
sign_p2 <- sign(W[loc])
}


sig_p1 <- sig_p2 <- 0 #0 indicates do not draw signifcance lines
if(draw_sig)
{
Expand Down Expand Up @@ -423,19 +431,12 @@ plot.cumulcalib <- function(x, method=NULL, draw_stat=TRUE, stat_col=c('blue','r
}

#P2 lines
loc <- x$by_method[[method]]$loc
if(method %in% c('BB')) #If 2p bridge test then adjust the length of the red line and draw the bridge line
{
if(draw_stat) lines(c(0,1),c(0,W[n]),col="gray", lty=2)
lines(c(0,1),c(0,W[n]),col="gray", lty=2)
if(draw_stat) lines(c(t_[loc],t_[loc]),c(t_[loc]/t_[n]*W[n],W[loc]),col=stat_col[2])
if(draw_sig) lines(c(0,1),c(sign_p2*sig_p2,sign_p2*sig_p2+W[n]),col=stat_col[2],lty=3)
}
else if(method %in% c('BCI1p'))
{
lines(c(0,1),c(0,W[n]),col="gray")
if(draw_stat) lines(c(t_[loc],t_[loc]),c(0,W[loc]),col=stat_col[2])
if(draw_sig) lines(c(0,1),c(sign_p2*sig_p2,sign_p2*sig_p2),col=stat_col[2],lty=3)
}
else #BM or BM2p
{
if(draw_stat) lines(c(t_[loc],t_[loc]),c(0,W[loc]),col=stat_col[2])
Expand Down
25 changes: 25 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
Many thanks for evaluating the package and apologies for the inconveniencs the errors have caused.

Comment: "The Description field is intended to be a (one paragraph) description of what the package does and why it may be useful. Please add more details about the package functionality and implemented methods in your Description text. If there are references describing the methods in your package, please add these in the description field of your DESCRIPTION file in the form authors (year) <doi:...> authors (year, ISBN:...) or if those are not available: <https:...> with no space after 'doi:', 'https:' and angle brackets for auto-linking. (If you want to add a title as well please put it in
quotes: "Title")


Response: Description field is now updated, with the publication added. NOTE: the publication is in production. The doi is valid but will be made available once the paper is published.


Comment: Please write TRUE and FALSE instead of T and F. Please don't use "T" or "F" as vector names.
Response: Done


Comment: Please make sure that you do not change the user's options, par or working directory. If you really have to do so within functions, please ensure with an *immediate* call of on.exit() that the settings are reset when the function is exited.

Response: Done. The oldpar <- par(no.readonly = TRUE) and on.exit(par(oldpar)) are added to the beginning of plot.cumulcalib()


Thanks again for lending your expertise to reviewing our package.

Regards,
Mohsen Sadatsafavi


## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

3 changes: 1 addition & 2 deletions man/cumulcalib-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ceb865b

Please sign in to comment.