From ceb865bed279826d5fe7128a1c6fb07efb67a977 Mon Sep 17 00:00:00 2001 From: Mohsen Sadatsafavi Date: Thu, 6 Jun 2024 20:49:48 -0700 Subject: [PATCH] CRAN comments accomodates - bug fixes in plot.cumulcalib() --- DESCRIPTION | 4 ++-- R/core.R | 27 ++++++++++++++------------- cran-comments.md | 25 +++++++++++++++++++++++++ man/cumulcalib-package.Rd | 3 +-- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8906e4c..32c511d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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) . 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) . 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: @@ -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 diff --git a/R/core.R b/R/core.R index a8d884e..685bdb4 100644 --- a/R/core.R +++ b/R/core.R @@ -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)) @@ -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) { @@ -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]) diff --git a/cran-comments.md b/cran-comments.md index 858617d..3a80f36 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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) authors (year, ISBN:...) or if those are not available: 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. + diff --git a/man/cumulcalib-package.Rd b/man/cumulcalib-package.Rd index ae7ee32..af8d09d 100644 --- a/man/cumulcalib-package.Rd +++ b/man/cumulcalib-package.Rd @@ -3,10 +3,9 @@ \docType{package} \name{cumulcalib-package} \alias{cumulcalib-package} -\alias{_PACKAGE} \title{cumulcalib: Cumulative Calibration Assessment for Prediction Models} \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(). +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(). } \seealso{ Useful links: