diff --git a/R/basics.R b/R/basics.R index 9209113..2cc43a5 100644 --- a/R/basics.R +++ b/R/basics.R @@ -35,6 +35,7 @@ #' - Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (`gengamma`) or shape, scale and k parameters if using the original parameterization (`gengamma.orig`). #' @seealso [flexsurv::flexsurvreg] #' @return The value of the distribution function, a numeric value. +#' @noRd # Examples # calc_pdist_par(10, "exp", 0.01) # calc_pdist_par(5, "lnorm", c(3, 1)) @@ -80,6 +81,7 @@ calc_pdist_par <- function(time, dist, pars) { #' - `scale` - Either "hazard", "odds", or "normal", as described in [flexsurv::flexsurvspline]. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. #' @seealso [flexsurv::flexsurvspline] and [flexsurv::flexsurvreg] #' @return The value of the distribution function, a numeric value. +#' @noRd # Examples # calc_pdist(time=1:5, # type="spl", @@ -114,6 +116,7 @@ calc_pdist <- function(time, type, spec){ #' @inheritParams calc_pdist #' @return The value of the survival function, a numeric value. #' @inherit calc_pdist seealso +#' @noRd # Examples # calc_surv(time=1:5, # type="spl", @@ -132,6 +135,7 @@ calc_surv <- function(time, type, spec) { #' @inheritParams calc_pdist_par #' @inherit calc_pdist_par seealso #' @return The value of a hazard function, a numeric value. +#' @noRd # Examples # calc_haz_par(10, "exp", 0.01) # calc_haz_par(5, "lnorm", c(3, 1)) @@ -163,6 +167,7 @@ calc_haz_par <- function(time, dist, pars) { #' @description Calculate the value of the hazard function, given specification as either parametric or Royston-Parmar splines model #' @inheritParams calc_surv #' @inherit calc_haz_par return +#' @noRd # Examples # calc_haz(time=1:5, # type="spl", @@ -195,6 +200,7 @@ calc_haz <- function(time, type, spec){ #' @inheritParams calc_pdist_par #' @inherit calc_pdist_par seealso #' @return The value of a density function, a numeric value. +#' @noRd # Examples # calc_dens_par(10, "exp", 0.01) # calc_dens_par(5, "lnorm", c(3, 1)) @@ -226,6 +232,7 @@ calc_dens_par <- function(time, dist, pars) { #' @description Calculate the value of the density function, given specification as either parametric or Royston-Parmar splines model #' @inheritParams calc_surv #' @inherit calc_haz_par return +#' @noRd # Examples # calc_dens(time=1:5, # type="spl", @@ -266,6 +273,7 @@ calc_dens <- function(time, type, spec){ #' @param Tw is the time period over which the restricted mean is calculated #' @inherit calc_pdist seealso #' @return the restricted mean duration, a numeric value. +#' @noRd # Examples # calc_rmd_par(20, "exp", 0.2) # calc_rmd_par(10, "lnorm", c(3, 1)) @@ -310,8 +318,8 @@ calc_rmd_par <- function(Tw, dist, pars) { #' - `knots` - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in [flexsurv::flexsurvspline], these include the two boundary knots. #' - `scale` - Either "hazard", "odds", or "normal", as described in [flexsurv::flexsurvspline]. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. #' @param discrate Discounting rate (%) per year -#' @inherit calc_haz_par seealso -#' @inherit calc_haz_par return +#' @returns Numeric +#' @seealso [flexsurv::flexsurvspline] and [flexsurv::flexsurvreg] #' @export #' @examples #' calc_rmd(Tw=200, @@ -347,6 +355,7 @@ calc_rmd <- function(Tw, type, spec, discrate=0){ #' @param dist is the statistical distribution (named per [flexsurv::flexsurvreg]) #' @return a numeric value #' @inherit calc_pdist seealso +#' @noRd # Examples # give_noparams_par("llogis") give_noparams_par <- function(dist) { @@ -365,6 +374,7 @@ give_noparams_par <- function(dist) { #' @inheritParams calc_surv #' @return a numeric value #' @inherit calc_pdist seealso +#' @noRd # Examples # give_noparams(type="par", spec=list(dist="weibullPH")) # give_noparams(type="spl", spec=list(gamma=c(1.1,2.1,3.1))) @@ -386,6 +396,7 @@ give_noparams <- function(type, spec) { #' @param weeks Number of weeks #' @return Number of years = weeks x 7 / 365.25 #' @seealso [psm3mkv::convert_yrs2wks] +#' @noRd convert_wks2yrs <- function(weeks) { weeks*7/365.25 } @@ -395,6 +406,7 @@ convert_wks2yrs <- function(weeks) { #' @param years Number of years #' @return Number of weeks = years / 7 * 365.25 #' @seealso [psm3mkv::convert_wks2yrs] +#' @noRd convert_yrs2wks <- function(years) { years*365.25/7 } \ No newline at end of file diff --git a/R/datasets.R b/R/datasets.R index 8354b82..91cf582 100644 --- a/R/datasets.R +++ b/R/datasets.R @@ -46,6 +46,7 @@ create_dummydata <- function(dsname) { #' @return Tibble dataset, for use with [psm3mkv] functions #' @seealso [create_dummydata()] #' @importFrom rlang .data +#' @noRd create_dummydata_survcan <- function() { # Declare local variables ptid <- os.durn <- os.flag <- NULL @@ -64,6 +65,7 @@ create_dummydata_survcan <- function() { #' @return Tibble dataset, for use with [psm3mkv] functions #' @seealso [create_dummydata()] #' @importFrom rlang .data +#' @noRd create_dummydata_flexbosms <- function() { # Declare local variables id <- pfs.durn <- pfs.flag <- NULL diff --git a/R/discrmd.R b/R/discrmd.R index ddaedc4..a573dd3 100644 --- a/R/discrmd.R +++ b/R/discrmd.R @@ -45,6 +45,7 @@ #' - pd: RMD in PD state #' - os: RMD in either alive state #' @seealso [drmd_stm_cf()] [drmd_stm_cr()] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -93,6 +94,7 @@ drmd_psm <- function(ptdata, dpam, psmtype="simple", Ty=10, discrate=0, lifetabl #' Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Forward structure. #' @inherit drmd_psm params return #' @seealso [drmd_psm()] [drmd_stm_cr()] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -149,6 +151,7 @@ drmd_stm_cf <- function(dpam, Ty=10, discrate=0, lifetable=NA, timestep=1) { #' Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Reset structure. #' @inherit drmd_psm params return #' @seealso [drmd_stm_cf()] [drmd_psm()] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") diff --git a/R/fitting-spl.R b/R/fitting-spl.R index 17ff198..baa60c8 100644 --- a/R/fitting-spl.R +++ b/R/fitting-spl.R @@ -33,6 +33,7 @@ #' - result: A list of class [flexsurv::flexsurvspline] containing information about the fitted model. #' - error: Any error message returned on fitting the regression (NULL indicates no error). #' @seealso [flexsurv::flexsurvspline] and [survival::Surv()] +#' @noRd fit_mods_spl <- function(durn1, durn2=NA, evflag, knot_set=1:3, scale_set=c("hazard", "odds", "normal"), diff --git a/R/fitting.R b/R/fitting.R index 763fca1..7ac3751 100644 --- a/R/fitting.R +++ b/R/fitting.R @@ -25,6 +25,7 @@ #' @description Checks whether the Hessian matrix returned in a list after fitting a survival regression with flexsurvreg is positive-definite. #' @param fitlist is a list returned after running [flexsurv::flexsurvreg()] describing a fitted survival model #' @return logical: TRUE if Hessian matrix is positive definite, FALSE if not. +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_par(bosonc) @@ -56,6 +57,7 @@ check_posdef <- function(fitlist) { #' @return A list by distribution, each containing two components: #' - result: A list of class [flexsurv::flexsurvreg] containing information about the fitted model. #' - error: Any error message returned on fitting the regression (NULL indicates no error). +#' @noRd fit_mods_par <- function(durn1, durn2=NA, evflag, dists, expvar=NA) { # Return nothing if no distributions specified if (sum(is.na(dists))!=0) {return(NA)} @@ -90,6 +92,7 @@ fit_mods_par <- function(durn1, durn2=NA, evflag, dists, expvar=NA) { #' @return A list by distribution, each containing two components: #' - result: A list containing information about the fitted model. #' - error: Any error message returned on fitting the regression (NULL indicates no error). +#' @noRd fit_mods <- function(durn1, durn2=NA, evflag, type, spec) { if (type=="spl"){ fit_mods_spl(durn1, durn2, evflag, knot_set=spec$k, scale_set=spec$scale) diff --git a/R/lhoods.R b/R/lhoods.R index 101caa7..9d91eab 100644 --- a/R/lhoods.R +++ b/R/lhoods.R @@ -28,6 +28,7 @@ #' - `spec` contains distribution (`dist`) and coefficients (`coefs`) if `type=="par"` #' - `spec` contains gamma values (`gamma`), knot locations (log scale, `knots`) and scale (`scale`) for Royston-Parmar splines model, if `type=="spl"` #' @seealso [flexsurv::flexsurvspline()] +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_spl(bosonc) @@ -53,13 +54,13 @@ convert_fit2spec <- function(fitsurv) { #' Calculate likelihood for a simple three-state partitioned survival model #' @description Calculate likelihood values and other summary output for a simple three-state partitioned survival model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by [calc_likes].x three-state partitioned survival model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by [calc_likes]. Unlike [calc_likes_psm_complex], this likelihood function assumes a progression hazard can be derived from the PFS hazard function and the ratio of progression to PFS events from PF patients. #' @param ptdata Dataset of patient level data. Must be a tibble with columns named: -#' - ptid: patient identifier -#' - pfs.durn: duration of PFS from baseline -#' - pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -#' - os.durn: duration of OS from baseline -#' - os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -#' - ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -#' - ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). +#' - `ptid`: patient identifier +#' - `pfs.durn`: duration of PFS from baseline +#' - `pfs.flag`: event flag for PFS (=1 if progression or death occurred, 0 for censoring) +#' - `os.durn`: duration of OS from baseline +#' - `os.flag`: event flag for OS (=1 if death occurred, 0 for censoring) +#' - `ttp.durn`: duration of TTP from baseline (usually should be equal to pfs.durn) +#' - `ttp.flag`: event flag for TTP (=1 if progression occurred, 0 for censoring). #' #' Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS. #' @param dpam List of survival regressions for each endpoint: @@ -81,6 +82,7 @@ convert_fit2spec <- function(fitsurv) { #' - `BIC`: Bayesian Information Criterion value for this model #' @seealso [calc_likes()], [calc_likes_psm_complex()], [calc_likes_stm_cf()], [calc_likes_stm_cr()] #' @importFrom rlang .data +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_spl(bosonc) @@ -181,6 +183,7 @@ calc_likes_psm_simple <- function(ptdata, dpam, cuttime=0) { #' @inherit calc_likes_psm_simple return #' @seealso [calc_likes()], [calc_likes_psm_simple()], [calc_likes_psm_complex()], [calc_likes_stm_cr()] #' @importFrom rlang .data +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_par(bosonc) @@ -285,6 +288,7 @@ calc_likes_psm_complex <- function(ptdata, dpam, cuttime=0) { #' @inherit calc_likes_psm_simple return #' @seealso [calc_likes()], [calc_likes_psm_simple()], [calc_likes_psm_complex()], [calc_likes_stm_cr()] #' @importFrom rlang .data +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_spl(bosonc) @@ -377,6 +381,7 @@ calc_likes_stm_cf <- function(ptdata, dpam, cuttime=0) { #' @inherit calc_likes_psm_simple return #' @seealso [calc_likes()], [calc_likes_stm_cf()], [calc_likes_psm_simple()], [calc_likes_psm_complex()] #' @importFrom rlang .data +#' @noRd # Examples # bosonc <- create_dummydata("flexbosms") # fits <- fit_ends_mods_spl(bosonc) @@ -466,7 +471,24 @@ calc_likes_stm_cr <- function(ptdata, dpam, cuttime=0) { #' Calculate likelihoods for three three-state model structures #' @description Calculate likelihood values and other summary output for the following three state models structures: partitioned survival, clock forward state transition, and clock reset state transition. The function requires appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). -#' @inheritParams calc_likes_psm_simple +#' @param ptdata Dataset of patient level data. Must be a tibble with columns named: +#' - `ptid`: patient identifier +#' - `pfs.durn`: duration of PFS from baseline +#' - `pfs.flag`: event flag for PFS (=1 if progression or death occurred, 0 for censoring) +#' - `os.durn`: duration of OS from baseline +#' - `os.flag`: event flag for OS (=1 if death occurred, 0 for censoring) +#' - `ttp.durn`: duration of TTP from baseline (usually should be equal to pfs.durn) +#' - `ttp.flag`: event flag for TTP (=1 if progression occurred, 0 for censoring). +#' +#' Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS. +#' @param dpam List of survival regressions for each endpoint: +#' - pre-progression death (PPD) +#' - time to progression (TTP) +#' - progression-free survival (PFS) +#' - overall survival (OS) +#' - post-progression survival clock forward (PPS-CF) and +#' - post-progression survival clock reset (PPS-CR). +#' @param cuttime Time cutoff - this is nonzero for two-piece models. #' @return Two outputs are returned: #' #' `results` is a tibble of values and data relating to the likelihood for this model: @@ -487,7 +509,6 @@ calc_likes_stm_cr <- function(ptdata, dpam, cuttime=0) { #' #' The number of patients for each outcome are given for each model structure. You may confirm that these are identical across model structures. #' The contribution of each patient group to the calculation of log-likelihood for each model is given in fields beginning `ll_`. This is helpful for understanding differences in likelihoods between model structures, according to patient outcomes. -#' @seealso This function calls [calc_likes_psm_simple()], [calc_likes_psm_complex()], [calc_likes_stm_cf()], and [calc_likes_stm_cr()]. #' @export #' @examples #' \donttest{ diff --git a/R/ltablesurv.R b/R/ltablesurv.R index 7c6a3fc..7a47627 100644 --- a/R/ltablesurv.R +++ b/R/ltablesurv.R @@ -33,6 +33,7 @@ #' - `arith`: Arithmetic mean, where interpolation is required between measured values #' - `geom`: Geometric mean, where interpolation is required between measured values #' @seealso [psm3mkv::vlookup] +#' @noRd vonelookup <- function(oneindexval, indexvec, valvec, method="geom") { if (is.na(oneindexval)) return(NA) # Return NA rather than error if index value lookup is NA if (oneindexval purrr::map_vec(~pickout_psmhaz(.x, endpoint, dpam, psmtype)$adj) - unadjhaz <- timevar |> purrr::map_vec(~pickout_psmhaz(.x, endpoint, dpam, psmtype)$unadj) + adjhaz <- timevar |> purrr::map_vec(~pickout_psmhaz(.x, endpoint, ptdata, dpam, psmtype)$adj) + unadjhaz <- timevar |> purrr::map_vec(~pickout_psmhaz(.x, endpoint, ptdata, dpam, psmtype)$unadj) # Create dataset for graphic result_data <- dplyr::tibble(Time=timevar, Adjusted=adjhaz, Unadjusted=unadjhaz) |> tidyr::pivot_longer(cols=c(Adjusted, Unadjusted), @@ -265,6 +268,7 @@ graph_psm_hazards <- function(timevar, endpoint, ptdata, dpam, psmtype) { #' @importFrom rlang .data #' @export #' @examples +#' \donttest{ #' bosonc <- create_dummydata("flexbosms") #' fits <- fit_ends_mods_par(bosonc) #' # Pick out best distribution according to min AIC @@ -276,29 +280,28 @@ graph_psm_hazards <- function(timevar, endpoint, ptdata, dpam, psmtype) { #' pps_cf = find_bestfit_par(fits$pps_cf, "aic")$fit, #' pps_cr = find_bestfit_par(fits$pps_cr, "aic")$fit #' ) -#' # Original OS graphic -#' graph_orig <- graph_survs(ptdata=bosonc, dpam=params) -#' graph_orig$graph$os -#' # New graphic illustrating effect of constraints on OS model -#' # psms_simple <- graph_psm_survs( -#' # timerange=6*(0:10), -#' # endpoint="OS", -#' # ptdata=bosonc, -#' # dpam=params, -#' # psmtype="simple") -#' # psms_simple$graph -graph_psm_survs <- function(timevar, endpoint, dpam, psmtype) { +#' # Graphic illustrating effect of constraints on OS model +#' psms_simple <- graph_psm_survs( +#' timevar=6*(0:10), +#' endpoint="OS", +#' ptdata=bosonc, +#' dpam=params, +#' psmtype="simple" +#' ) +#' psms_simple$graph +#' } +graph_psm_survs <- function(timevar, endpoint, ptdata, dpam, psmtype) { # Declare local variables Adjusted <- Unadjusted <- Time <- Survival <- Method <- NULL # Convert endpoint to upper case text endpoint <- toupper(endpoint) # Unadjusted hazard haz_unadj <- function(time) { - pickout_psmhaz(time, endpoint, dpam, psmtype)$unadj + pickout_psmhaz(time, endpoint, ptdata, dpam, psmtype)$unadj } # Adjusted hazard haz_adj <- function(time) { - pickout_psmhaz(time, endpoint, dpam, psmtype)$adj + pickout_psmhaz(time, endpoint, ptdata, dpam, psmtype)$adj } # Unadjusted cumulative hazard cumhaz_unadj <- function(time) { diff --git a/R/resmeans.R b/R/resmeans.R index 10a6795..418c045 100644 --- a/R/resmeans.R +++ b/R/resmeans.R @@ -39,6 +39,7 @@ #' @param discrate Discount rate (%) per year #' @return Numeric value in same time unit as patient-level data (weeks). #' @seealso Used safely as [prmd_pf_stm] by [calc_allrmds] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -79,6 +80,7 @@ rmd_pf_stm <- function(dpam, Ty=10, starting=c(1, 0, 0), discrate=0) { #' @description Calculates the mean duration in the progression-free state for both the state transition clock forward and clock reset models. Requires a carefully formatted list of fitted survival regressions for the necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of [rmd_pf_stm]. This function is called by [calc_allrmds]. #' @param ... Pass-through to [rmd_pf_stm] #' @return Numeric value in same time unit as patient-level data (weeks). +#' @noRd prmd_pf_stm <- purrr::possibly(rmd_pf_stm, otherwise=NA_real_) #' Restricted mean duration in progressed disease state for clock reset state transition model @@ -87,6 +89,7 @@ prmd_pf_stm <- purrr::possibly(rmd_pf_stm, otherwise=NA_real_) #' @return Numeric value in same time unit as patient-level data (weeks). #' @seealso [rmd_pd_stm_cr] #' @seealso Used safely as [prmd_pd_stm_cr] by [calc_allrmds] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -142,6 +145,7 @@ rmd_pd_stm_cr <- function(dpam, Ty=10, starting=c(1, 0, 0), discrate=0) { #' @description Calculates the mean duration in the progressed disease state for the clock reset state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of [rmd_pd_stm_cr]. This function is called by [calc_allrmds]. #' @param ... Pass-through to [rmd_pd_stm_cr] #' @return Numeric value in same time unit as patient-level data (weeks). +#' @noRd prmd_pd_stm_cr <- purrr::possibly(rmd_pd_stm_cr, otherwise=NA_real_) #' Restricted mean duration in progressed disease state for clock forward state transition model @@ -149,6 +153,7 @@ prmd_pd_stm_cr <- purrr::possibly(rmd_pd_stm_cr, otherwise=NA_real_) #' @inheritParams rmd_pf_stm #' @return Numeric value in same time unit as patient-level data (weeks). #' @seealso Used safely as [prmd_pd_stm_cf] by [calc_allrmds] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -204,6 +209,7 @@ rmd_pd_stm_cf <- function(dpam, Ty=10, starting=c(1, 0, 0), discrate=0) { #' @description Calculates the mean duration in the progressed disease state for the clock forward state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of [rmd_pd_stm_cf]. This function is called by [calc_allrmds]. #' @param ... Pass-through to [rmd_pd_stm_cf] #' @return Numeric value in same time unit as patient-level data (weeks). +#' @noRd prmd_pd_stm_cf <- purrr::possibly(rmd_pd_stm_cf, otherwise=NA_real_) #' Restricted mean duration in progression free state for the partitioned survival model @@ -211,6 +217,7 @@ prmd_pd_stm_cf <- purrr::possibly(rmd_pd_stm_cf, otherwise=NA_real_) #' @inheritParams rmd_pf_stm #' @return Numeric value in same time unit as patient-level data (weeks). #' @seealso Used safely as [prmd_pf_psm] by [calc_allrmds] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -251,6 +258,7 @@ rmd_pf_psm <- function(dpam, Ty=10, starting=c(1, 0, 0), discrate=0) { #' @description Calculates the mean duration in the progression free state for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of [rmd_pf_psm]. This function is called by [calc_allrmds]. #' @param ... Pass-through to [rmd_pf_psm] #' @return Numeric value in same time unit as patient-level data (weeks). +#' @noRd prmd_pf_psm <- purrr::possibly(rmd_pf_psm, otherwise=NA_real_) #' Restricted mean duration for overall survival in the partitioned survival model @@ -258,6 +266,7 @@ prmd_pf_psm <- purrr::possibly(rmd_pf_psm, otherwise=NA_real_) #' @inheritParams rmd_pf_stm #' @return Numeric value in same time unit as patient-level data (weeks). #' @seealso Used safely as [prmd_os_psm] by [calc_allrmds] +#' @noRd # Examples # # Create dataset and fit survival models (splines) # bosonc <- create_dummydata("flexbosms") @@ -296,6 +305,7 @@ rmd_os_psm <- function(dpam, Ty=10, starting=c(1, 0, 0), discrate=0) { #' @description Calculates the mean duration alive (i.e. in either progression free or progressed disease states) for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of [rmd_os_psm]. This function is called by [calc_allrmds]. #' @param ... Pass-through to [rmd_os_psm] #' @return Numeric value in same time unit as patient-level data (weeks). +#' @noRd prmd_os_psm <- purrr::possibly(rmd_os_psm, otherwise=NA_real_) #' Fit survival models to each endpoint, given type and spec @@ -307,6 +317,7 @@ prmd_os_psm <- purrr::possibly(rmd_os_psm, otherwise=NA_real_) #' - result: A list of class *flexsurvreg* containing information about the fitted model. #' - error: Any error message returned on fitting the regression (NULL indicates no error). #' @seealso [convert_fit2spec()], [fit_ends_mods_par()], [fit_ends_mods_spl()] +#' @noRd fit_ends_mods_given <- function(simdat, dpam, cuttime){ # Declare variables ds <- dspps <- ts.ppd <- fit.ppd <- ts.ttp <- fit.ttp <- NULL @@ -381,6 +392,7 @@ fit_ends_mods_given <- function(simdat, dpam, cuttime){ #' - pfarea: area under the PF survival function up to the cut-off time #' - ossurv: the OS survival function at the cut-off time #' - osarea: area under the OS survival function up to the cut-off time +#' @noRd calc_rmd_first <- function(ds, cuttime) { # Declare local variables pf_km <- os_km <- NULL @@ -436,7 +448,6 @@ calc_rmd_first <- function(ds, cuttime) { #' @return List of detailed numeric results #' - cutadj indicates the survival function and area under the curves for PFS and OS up to the cutpoint #' - results provides results of the restricted means calculations, by model and state. -#' @seealso Restricted means are provided by [rmd_pf_psm()], [rmd_os_psm()], [rmd_pf_stm()], [rmd_pd_stm_cf()] and [rmd_pd_stm_cr()]. The function [calc_allrmds_boot] provides a version for bootstrapping. #' @export #' @examples #' \donttest{ diff --git a/man/calc_allrmds.Rd b/man/calc_allrmds.Rd index 4840165..bb4865f 100644 --- a/man/calc_allrmds.Rd +++ b/man/calc_allrmds.Rd @@ -77,6 +77,3 @@ calc_allrmds(bosonc, dpam=params) calc_allrmds(bosonc, dpam=params, rmdmethod="disc", timestep=1) } } -\seealso{ -Restricted means are provided by \code{\link[=rmd_pf_psm]{rmd_pf_psm()}}, \code{\link[=rmd_os_psm]{rmd_os_psm()}}, \code{\link[=rmd_pf_stm]{rmd_pf_stm()}}, \code{\link[=rmd_pd_stm_cf]{rmd_pd_stm_cf()}} and \code{\link[=rmd_pd_stm_cr]{rmd_pd_stm_cr()}}. The function \link{calc_allrmds_boot} provides a version for bootstrapping. -} diff --git a/man/calc_dens.Rd b/man/calc_dens.Rd deleted file mode 100644 index 9b8ff27..0000000 --- a/man/calc_dens.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_dens} -\alias{calc_dens} -\title{Calculate the value of the density function} -\usage{ -calc_dens(time, type, spec) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{type}{is either "par" for regular parametric form (exponential, weibull etc) or "spl" for Royston-Parmar splines.} - -\item{spec}{is a list comprising: -If type=="par": \code{dist} is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}) and \code{pars} is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -If type=="spl": -\item \code{gamma} - Vector of parameters describing the baseline spline function, as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. This may be supplied as a vector with number of elements equal to the length of knots, in which case the parameters are common to all times. Alternatively a matrix may be supplied, with rows corresponding to different times, and columns corresponding to knots. -\item \code{knots} - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}, these include the two boundary knots. -\item \code{scale} - Either "hazard", "odds", or "normal", as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. -}} -} -\value{ -The value of a hazard function, a numeric value. -} -\description{ -Calculate the value of the density function, given specification as either parametric or Royston-Parmar splines model -} diff --git a/man/calc_dens_par.Rd b/man/calc_dens_par.Rd deleted file mode 100644 index 2e35619..0000000 --- a/man/calc_dens_par.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_dens_par} -\alias{calc_dens_par} -\title{Calculate the value of the density function (parametric form)} -\usage{ -calc_dens_par(time, dist, pars) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{dist}{is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}).} - -\item{pars}{is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -}} -} -\value{ -The value of a density function, a numeric value. -} -\description{ -Calculate the value of the density function, given the statistical distribution and its parameters. -} -\seealso{ -\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/calc_ex.Rd b/man/calc_ex.Rd deleted file mode 100644 index 9f87e48..0000000 --- a/man/calc_ex.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ltablesurv.R -\name{calc_ex} -\alias{calc_ex} -\title{Calculate restricted life expectancy from a lifetable} -\usage{ -calc_ex(Ty = 10, lifetable, discrate = 0) -} -\arguments{ -\item{Ty}{Time duration over which to calculate (default is 10 years). Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{lifetable}{The lifetable must be a dataframe with columns named \code{lttime} (years) and \code{lx}. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -List containing \code{ex_y} and \verb{ex_w'}, the numeric (restricted) life expectancy in years and weeks respectively, -and \code{calcs}, a dataframe of the calculations. -} -\description{ -Calculate restricted life expectancy from a lifetable -} -\examples{ -# Create a lifetable. Must end with lx=0. -# ltable <- tibble::tibble(lttime=0:20, lx=1-lttime*0.05) -# calc_ex(lifetable=ltable, discrate=0.03) -# calc_ex(Ty=Inf, lifetable=ltable) -} diff --git a/man/calc_haz.Rd b/man/calc_haz.Rd deleted file mode 100644 index c7d2d69..0000000 --- a/man/calc_haz.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_haz} -\alias{calc_haz} -\title{Calculate the value of the hazard function} -\usage{ -calc_haz(time, type, spec) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{type}{is either "par" for regular parametric form (exponential, weibull etc) or "spl" for Royston-Parmar splines.} - -\item{spec}{is a list comprising: -If type=="par": \code{dist} is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}) and \code{pars} is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -If type=="spl": -\item \code{gamma} - Vector of parameters describing the baseline spline function, as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. This may be supplied as a vector with number of elements equal to the length of knots, in which case the parameters are common to all times. Alternatively a matrix may be supplied, with rows corresponding to different times, and columns corresponding to knots. -\item \code{knots} - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}, these include the two boundary knots. -\item \code{scale} - Either "hazard", "odds", or "normal", as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. -}} -} -\value{ -The value of a hazard function, a numeric value. -} -\description{ -Calculate the value of the hazard function, given specification as either parametric or Royston-Parmar splines model -} diff --git a/man/calc_haz_par.Rd b/man/calc_haz_par.Rd deleted file mode 100644 index 868f8ba..0000000 --- a/man/calc_haz_par.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_haz_par} -\alias{calc_haz_par} -\title{Calculate the value of the hazard function (parametric form)} -\usage{ -calc_haz_par(time, dist, pars) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{dist}{is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}).} - -\item{pars}{is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -}} -} -\value{ -The value of a hazard function, a numeric value. -} -\description{ -Calculate the value of the hazard function, given the statistical distribution and its parameters. -} -\seealso{ -\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/calc_likes.Rd b/man/calc_likes.Rd index 8e53386..992a0cb 100644 --- a/man/calc_likes.Rd +++ b/man/calc_likes.Rd @@ -9,13 +9,13 @@ calc_likes(ptdata, dpam, cuttime = 0) \arguments{ \item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: \itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). +\item \code{ptid}: patient identifier +\item \code{pfs.durn}: duration of PFS from baseline +\item \code{pfs.flag}: event flag for PFS (=1 if progression or death occurred, 0 for censoring) +\item \code{os.durn}: duration of OS from baseline +\item \code{os.flag}: event flag for OS (=1 if death occurred, 0 for censoring) +\item \code{ttp.durn}: duration of TTP from baseline (usually should be equal to pfs.durn) +\item \code{ttp.flag}: event flag for TTP (=1 if progression occurred, 0 for censoring). } Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} @@ -77,6 +77,3 @@ params <- list( calc_likes(bosonc, dpam=params) } } -\seealso{ -This function calls \code{\link[=calc_likes_psm_simple]{calc_likes_psm_simple()}}, \code{\link[=calc_likes_psm_complex]{calc_likes_psm_complex()}}, \code{\link[=calc_likes_stm_cf]{calc_likes_stm_cf()}}, and \code{\link[=calc_likes_stm_cr]{calc_likes_stm_cr()}}. -} diff --git a/man/calc_likes_psm_complex.Rd b/man/calc_likes_psm_complex.Rd deleted file mode 100644 index 0fe63ae..0000000 --- a/man/calc_likes_psm_complex.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lhoods.R -\name{calc_likes_psm_complex} -\alias{calc_likes_psm_complex} -\title{Calculate likelihood for a more complex three-state partitioned survival model} -\usage{ -calc_likes_psm_complex(ptdata, dpam, cuttime = 0) -} -\arguments{ -\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: -\itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). -} - -Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} - -\item{dpam}{List of survival regressions for each endpoint: -\itemize{ -\item pre-progression death (PPD) -\item time to progression (TTP) -\item progression-free survival (PFS) -\item overall survival (OS) -\item post-progression survival clock forward (PPS-CF) and -\item post-progression survival clock reset (PPS-CR). -}} - -\item{cuttime}{Time cutoff - this is nonzero for two-piece models.} -} -\value{ -List of values and data relating to the likelihood for this model: -\itemize{ -\item \code{npts}: Number of patients analysed for each endpoint. -\item \code{likedata}: Patient-level dataset with additional likelihood-related calculations. -\item \code{coefsdists}: Summary table of distributions and parameters used for each endpoint. -\item \code{slikes}: Total log-likelihood for each possible outcome -\item \code{ll}: Total log-likelihood -\item \code{params}: Number of parameters used in this model -\item \code{AIC}: Akaike Information Criterion value for this model -\item \code{BIC}: Bayesian Information Criterion value for this model -} -} -\description{ -Calculate likelihood values and other summary output for a more complex three-state partitioned survival model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by \code{\link[=calc_likes]{calc_likes()}}. Unlike \code{\link[=calc_likes_psm_simple]{calc_likes_psm_simple()}}, this likelihood function requires fitting to TTP. -} -\seealso{ -\code{\link[=calc_likes]{calc_likes()}}, \code{\link[=calc_likes_psm_simple]{calc_likes_psm_simple()}}, \code{\link[=calc_likes_psm_complex]{calc_likes_psm_complex()}}, \code{\link[=calc_likes_stm_cr]{calc_likes_stm_cr()}} -} diff --git a/man/calc_likes_psm_simple.Rd b/man/calc_likes_psm_simple.Rd deleted file mode 100644 index 54bb4ff..0000000 --- a/man/calc_likes_psm_simple.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lhoods.R -\name{calc_likes_psm_simple} -\alias{calc_likes_psm_simple} -\title{Calculate likelihood for a simple three-state partitioned survival model} -\usage{ -calc_likes_psm_simple(ptdata, dpam, cuttime = 0) -} -\arguments{ -\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: -\itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). -} - -Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} - -\item{dpam}{List of survival regressions for each endpoint: -\itemize{ -\item pre-progression death (PPD) -\item time to progression (TTP) -\item progression-free survival (PFS) -\item overall survival (OS) -\item post-progression survival clock forward (PPS-CF) and -\item post-progression survival clock reset (PPS-CR). -}} - -\item{cuttime}{Time cutoff - this is nonzero for two-piece models.} -} -\value{ -List of values and data relating to the likelihood for this model: -\itemize{ -\item \code{npts}: Number of patients analysed for each endpoint. -\item \code{likedata}: Patient-level dataset with additional likelihood-related calculations. -\item \code{coefsdists}: Summary table of distributions and parameters used for each endpoint. -\item \code{slikes}: Total log-likelihood for each possible outcome -\item \code{ll}: Total log-likelihood -\item \code{params}: Number of parameters used in this model -\item \code{AIC}: Akaike Information Criterion value for this model -\item \code{BIC}: Bayesian Information Criterion value for this model -} -} -\description{ -Calculate likelihood values and other summary output for a simple three-state partitioned survival model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by \link{calc_likes}.x three-state partitioned survival model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by \link{calc_likes}. Unlike \link{calc_likes_psm_complex}, this likelihood function assumes a progression hazard can be derived from the PFS hazard function and the ratio of progression to PFS events from PF patients. -} -\seealso{ -\code{\link[=calc_likes]{calc_likes()}}, \code{\link[=calc_likes_psm_complex]{calc_likes_psm_complex()}}, \code{\link[=calc_likes_stm_cf]{calc_likes_stm_cf()}}, \code{\link[=calc_likes_stm_cr]{calc_likes_stm_cr()}} -} diff --git a/man/calc_likes_stm_cf.Rd b/man/calc_likes_stm_cf.Rd deleted file mode 100644 index 895f32c..0000000 --- a/man/calc_likes_stm_cf.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lhoods.R -\name{calc_likes_stm_cf} -\alias{calc_likes_stm_cf} -\title{Calculate likelihood for a three-state clock forward state transition model} -\usage{ -calc_likes_stm_cf(ptdata, dpam, cuttime = 0) -} -\arguments{ -\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: -\itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). -} - -Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} - -\item{dpam}{List of survival regressions for each endpoint: -\itemize{ -\item pre-progression death (PPD) -\item time to progression (TTP) -\item progression-free survival (PFS) -\item overall survival (OS) -\item post-progression survival clock forward (PPS-CF) and -\item post-progression survival clock reset (PPS-CR). -}} - -\item{cuttime}{Time cutoff - this is nonzero for two-piece models.} -} -\value{ -List of values and data relating to the likelihood for this model: -\itemize{ -\item \code{npts}: Number of patients analysed for each endpoint. -\item \code{likedata}: Patient-level dataset with additional likelihood-related calculations. -\item \code{coefsdists}: Summary table of distributions and parameters used for each endpoint. -\item \code{slikes}: Total log-likelihood for each possible outcome -\item \code{ll}: Total log-likelihood -\item \code{params}: Number of parameters used in this model -\item \code{AIC}: Akaike Information Criterion value for this model -\item \code{BIC}: Bayesian Information Criterion value for this model -} -} -\description{ -Calculate likelihood values and other summary output for a three-state clock forward state transition model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by \link{calc_likes}. -} -\seealso{ -\code{\link[=calc_likes]{calc_likes()}}, \code{\link[=calc_likes_psm_simple]{calc_likes_psm_simple()}}, \code{\link[=calc_likes_psm_complex]{calc_likes_psm_complex()}}, \code{\link[=calc_likes_stm_cr]{calc_likes_stm_cr()}} -} diff --git a/man/calc_likes_stm_cr.Rd b/man/calc_likes_stm_cr.Rd deleted file mode 100644 index 370af0b..0000000 --- a/man/calc_likes_stm_cr.Rd +++ /dev/null @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lhoods.R -\name{calc_likes_stm_cr} -\alias{calc_likes_stm_cr} -\title{Calculate likelihood for a three-state clock reset state transition model} -\usage{ -calc_likes_stm_cr(ptdata, dpam, cuttime = 0) -} -\arguments{ -\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: -\itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). -} - -Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} - -\item{dpam}{List of survival regressions for each endpoint: -\itemize{ -\item pre-progression death (PPD) -\item time to progression (TTP) -\item progression-free survival (PFS) -\item overall survival (OS) -\item post-progression survival clock forward (PPS-CF) and -\item post-progression survival clock reset (PPS-CR). -}} - -\item{cuttime}{Time cutoff - this is nonzero for two-piece models.} -} -\value{ -List of values and data relating to the likelihood for this model: -\itemize{ -\item \code{npts}: Number of patients analysed for each endpoint. -\item \code{likedata}: Patient-level dataset with additional likelihood-related calculations. -\item \code{coefsdists}: Summary table of distributions and parameters used for each endpoint. -\item \code{slikes}: Total log-likelihood for each possible outcome -\item \code{ll}: Total log-likelihood -\item \code{params}: Number of parameters used in this model -\item \code{AIC}: Akaike Information Criterion value for this model -\item \code{BIC}: Bayesian Information Criterion value for this model -} -} -\description{ -Calculate likelihood values and other summary output for a three-state clock reset model, given appropriately formatted patient-level data, a set of fitted survival regressions, and the time cut-off (if two-piece modeling is used). This function is called by \link{calc_likes}. -} -\seealso{ -\code{\link[=calc_likes]{calc_likes()}}, \code{\link[=calc_likes_stm_cf]{calc_likes_stm_cf()}}, \code{\link[=calc_likes_psm_simple]{calc_likes_psm_simple()}}, \code{\link[=calc_likes_psm_complex]{calc_likes_psm_complex()}} -} diff --git a/man/calc_ltdens.Rd b/man/calc_ltdens.Rd deleted file mode 100644 index b4bbcdb..0000000 --- a/man/calc_ltdens.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ltablesurv.R -\name{calc_ltdens} -\alias{calc_ltdens} -\title{Calculate mortality density from a lifetable} -\usage{ -calc_ltdens(looktime, lifetable = NA, method = "geom") -} -\arguments{ -\item{looktime}{The time(s) to which survival is to be estimated (from time zero).} - -\item{lifetable}{The lifetable must be a dataframe with columns named \code{lttime} (years) and \code{lx}. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{method}{Method may be \code{floor}, \code{ceiling}, \code{arith} or \code{geom} (default).} -} -\value{ -Numeric survival probability -} -\description{ -Calculate mortality density a given time, according to a provided lifetable -} diff --git a/man/calc_ltsurv.Rd b/man/calc_ltsurv.Rd deleted file mode 100644 index 12eb730..0000000 --- a/man/calc_ltsurv.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ltablesurv.R -\name{calc_ltsurv} -\alias{calc_ltsurv} -\title{Calculate survival from a lifetable} -\usage{ -calc_ltsurv(looktime, lifetable = NA, method = "geom") -} -\arguments{ -\item{looktime}{The time(s) to which survival is to be estimated (from time zero).} - -\item{lifetable}{The lifetable must be a dataframe with columns named \code{lttime} (years) and \code{lx}. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{method}{Method may be \code{floor}, \code{ceiling}, \code{arith} or \code{geom} (default).} -} -\value{ -Numeric survival probability -} -\description{ -Calculate survival from time zero to a given time, according to a provided lifetable -} diff --git a/man/calc_pdist.Rd b/man/calc_pdist.Rd deleted file mode 100644 index f2f8a0d..0000000 --- a/man/calc_pdist.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_pdist} -\alias{calc_pdist} -\title{Calculate the distribution function} -\usage{ -calc_pdist(time, type, spec) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{type}{is either "par" for regular parametric form (exponential, weibull etc) or "spl" for Royston-Parmar splines.} - -\item{spec}{is a list comprising: -If type=="par": \code{dist} is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}) and \code{pars} is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -If type=="spl": -\item \code{gamma} - Vector of parameters describing the baseline spline function, as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. This may be supplied as a vector with number of elements equal to the length of knots, in which case the parameters are common to all times. Alternatively a matrix may be supplied, with rows corresponding to different times, and columns corresponding to knots. -\item \code{knots} - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}, these include the two boundary knots. -\item \code{scale} - Either "hazard", "odds", or "normal", as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. -}} -} -\value{ -The value of the distribution function, a numeric value. -} -\description{ -Calculate the value of the distribution function, given a regular parametric or Royston-Parmar formulation -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/calc_pdist_par.Rd b/man/calc_pdist_par.Rd deleted file mode 100644 index 89474a5..0000000 --- a/man/calc_pdist_par.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_pdist_par} -\alias{calc_pdist_par} -\title{Calculate the distribution function for parametric functions} -\usage{ -calc_pdist_par(time, dist, pars) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{dist}{is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}).} - -\item{pars}{is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -}} -} -\value{ -The value of the distribution function, a numeric value. -} -\description{ -Calculate the value of the distribution function for a parametric distribution, given the statistical distribution and its parameters. -} -\seealso{ -\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/calc_rmd.Rd b/man/calc_rmd.Rd index 6644c6d..3062018 100644 --- a/man/calc_rmd.Rd +++ b/man/calc_rmd.Rd @@ -29,7 +29,7 @@ If type=="spl": \item{discrate}{Discounting rate (\%) per year} } \value{ -The value of a hazard function, a numeric value. +Numeric } \description{ Calculates the restricted mean duration, given the form of a parametric distribution of Royston-Parmar splines @@ -45,5 +45,5 @@ calc_rmd(Tw=250, ) } \seealso{ -\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} +\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} } diff --git a/man/calc_rmd_first.Rd b/man/calc_rmd_first.Rd deleted file mode 100644 index c8485d6..0000000 --- a/man/calc_rmd_first.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{calc_rmd_first} -\alias{calc_rmd_first} -\title{Calculate restricted mean duration in respect of the first part of a two-piece model -Internal function to calculate the restricted mean duration up to the cut-off time, the first part of a two-piece model. Assumes the time horizon is beyond the cutoff time.} -\usage{ -calc_rmd_first(ds, cuttime) -} -\arguments{ -\item{ds}{patient-level dataset} - -\item{cuttime}{time cut-off} -} -\value{ -list containing: -\itemize{ -\item pfsurv: the PF survival function at the cut-off time -\item pfarea: area under the PF survival function up to the cut-off time -\item ossurv: the OS survival function at the cut-off time -\item osarea: area under the OS survival function up to the cut-off time -} -} -\description{ -Calculate restricted mean duration in respect of the first part of a two-piece model -Internal function to calculate the restricted mean duration up to the cut-off time, the first part of a two-piece model. Assumes the time horizon is beyond the cutoff time. -} diff --git a/man/calc_rmd_par.Rd b/man/calc_rmd_par.Rd deleted file mode 100644 index a2f9cdd..0000000 --- a/man/calc_rmd_par.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_rmd_par} -\alias{calc_rmd_par} -\title{Calculate restricted mean durations (parametric form)} -\usage{ -calc_rmd_par(Tw, dist, pars) -} -\arguments{ -\item{Tw}{is the time period over which the restricted mean is calculated} - -\item{dist}{is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}).} - -\item{pars}{is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -}} -} -\value{ -the restricted mean duration, a numeric value. -} -\description{ -Calculates the restricted mean duration, given a parametric statistical distribution. -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/calc_surv.Rd b/man/calc_surv.Rd deleted file mode 100644 index 58580ad..0000000 --- a/man/calc_surv.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{calc_surv} -\alias{calc_surv} -\title{Calculate the value of the survival function} -\usage{ -calc_surv(time, type, spec) -} -\arguments{ -\item{time}{is the time at which the distribution function should be calculated.} - -\item{type}{is either "par" for regular parametric form (exponential, weibull etc) or "spl" for Royston-Parmar splines.} - -\item{spec}{is a list comprising: -If type=="par": \code{dist} is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}) and \code{pars} is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -If type=="spl": -\item \code{gamma} - Vector of parameters describing the baseline spline function, as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. This may be supplied as a vector with number of elements equal to the length of knots, in which case the parameters are common to all times. Alternatively a matrix may be supplied, with rows corresponding to different times, and columns corresponding to knots. -\item \code{knots} - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}, these include the two boundary knots. -\item \code{scale} - Either "hazard", "odds", or "normal", as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. -}} -} -\value{ -The value of the survival function, a numeric value. -} -\description{ -Calculate the value of the survival function, given the statistical distribution and its parameters. -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/check_posdef.Rd b/man/check_posdef.Rd deleted file mode 100644 index 01b0ebd..0000000 --- a/man/check_posdef.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fitting.R -\name{check_posdef} -\alias{check_posdef} -\title{Checks whether the Hessian for a survival regression is positive-definite} -\usage{ -check_posdef(fitlist) -} -\arguments{ -\item{fitlist}{is a list returned after running \code{\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg()}} describing a fitted survival model} -} -\value{ -logical: TRUE if Hessian matrix is positive definite, FALSE if not. -} -\description{ -Checks whether the Hessian matrix returned in a list after fitting a survival regression with flexsurvreg is positive-definite. -} diff --git a/man/convert_fit2spec.Rd b/man/convert_fit2spec.Rd deleted file mode 100644 index 20a14f1..0000000 --- a/man/convert_fit2spec.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/lhoods.R -\name{convert_fit2spec} -\alias{convert_fit2spec} -\title{Obtain the type and specification as required in other package functions from a model fit} -\usage{ -convert_fit2spec(fitsurv) -} -\arguments{ -\item{fitsurv}{Fitted model (either parametric or Royston-Parmar splines model)} -} -\value{ -List of type and specification -\itemize{ -\item \code{type} is "spl" for splines model or "par" for parametric model -\item \code{spec} contains distribution (\code{dist}) and coefficients (\code{coefs}) if \code{type=="par"} -\item \code{spec} contains gamma values (\code{gamma}), knot locations (log scale, \code{knots}) and scale (\code{scale}) for Royston-Parmar splines model, if \code{type=="spl"} -} -} -\description{ -Obtain the type and specification as required in other package functions from a model fit -} -\seealso{ -\code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}} -} diff --git a/man/convert_wks2yrs.Rd b/man/convert_wks2yrs.Rd deleted file mode 100644 index ae25dd4..0000000 --- a/man/convert_wks2yrs.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{convert_wks2yrs} -\alias{convert_wks2yrs} -\title{Convert weeks to years} -\usage{ -convert_wks2yrs(weeks) -} -\arguments{ -\item{weeks}{Number of weeks} -} -\value{ -Number of years = weeks x 7 / 365.25 -} -\description{ -Convert weeks to years. Function allows hard-coding to be minimized elsewhere in the package. -} -\seealso{ -\link{convert_yrs2wks} -} diff --git a/man/convert_yrs2wks.Rd b/man/convert_yrs2wks.Rd deleted file mode 100644 index 7e0b2c1..0000000 --- a/man/convert_yrs2wks.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{convert_yrs2wks} -\alias{convert_yrs2wks} -\title{Convert years to weeks} -\usage{ -convert_yrs2wks(years) -} -\arguments{ -\item{years}{Number of years} -} -\value{ -Number of weeks = years / 7 * 365.25 -} -\description{ -Convert weeks to years. Function allows hard-coding to be minimized elsewhere in the package. -} -\seealso{ -\link{convert_wks2yrs} -} diff --git a/man/create_dummydata_flexbosms.Rd b/man/create_dummydata_flexbosms.Rd deleted file mode 100644 index f812237..0000000 --- a/man/create_dummydata_flexbosms.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/datasets.R -\name{create_dummydata_flexbosms} -\alias{create_dummydata_flexbosms} -\title{Create flexbosms dataset for illustration} -\usage{ -create_dummydata_flexbosms() -} -\value{ -Tibble dataset, for use with \link{psm3mkv} functions -} -\description{ -Create 'flexbosms' dummy dataset to illustrate \link{psm3mkv} -} -\seealso{ -\code{\link[=create_dummydata]{create_dummydata()}} -} diff --git a/man/create_dummydata_survcan.Rd b/man/create_dummydata_survcan.Rd deleted file mode 100644 index 18726eb..0000000 --- a/man/create_dummydata_survcan.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/datasets.R -\name{create_dummydata_survcan} -\alias{create_dummydata_survcan} -\title{Create survcan dummy dataset for illustration} -\usage{ -create_dummydata_survcan() -} -\value{ -Tibble dataset, for use with \link{psm3mkv} functions -} -\description{ -Create 'survcan' dummy dataset to illustrate \link{psm3mkv} -} -\seealso{ -\code{\link[=create_dummydata]{create_dummydata()}} -} diff --git a/man/drmd_psm.Rd b/man/drmd_psm.Rd deleted file mode 100644 index 5a2287f..0000000 --- a/man/drmd_psm.Rd +++ /dev/null @@ -1,58 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/discrmd.R -\name{drmd_psm} -\alias{drmd_psm} -\title{Discretized Restricted Mean Duration calculation for Partitioned Survival Model -Calculate restricted mean duration (RMD) in PF, PD and OS states under a Partitioned Survival Model structure.} -\usage{ -drmd_psm( - ptdata, - dpam, - psmtype = "simple", - Ty = 10, - discrate = 0, - lifetable = NA, - timestep = 1 -) -} -\arguments{ -\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: -\itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). -} - -Survival data for all other endpoints (time to progression, pre-progression death, post-progression survival) are derived from PFS and OS.} - -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{psmtype}{Either "simple" or "complex" PSM formulation} - -\item{Ty}{Time duration over which to calculate (defaults to 10 years). Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{discrate}{Discount rate (\%) per year (defaults to zero).} - -\item{lifetable}{Optional. The lifetable must be a dataframe with columns named time and lx. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{timestep}{Optional, defaults to one (week).} -} -\value{ -List containing: -\itemize{ -\item pf: RMD in PF state -\item pd: RMD in PD state -\item os: RMD in either alive state -} -} -\description{ -Discretized Restricted Mean Duration calculation for Partitioned Survival Model -Calculate restricted mean duration (RMD) in PF, PD and OS states under a Partitioned Survival Model structure. -} -\seealso{ -\code{\link[=drmd_stm_cf]{drmd_stm_cf()}} \code{\link[=drmd_stm_cr]{drmd_stm_cr()}} -} diff --git a/man/drmd_stm_cf.Rd b/man/drmd_stm_cf.Rd deleted file mode 100644 index 76768d0..0000000 --- a/man/drmd_stm_cf.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/discrmd.R -\name{drmd_stm_cf} -\alias{drmd_stm_cf} -\title{Discretized Restricted Mean Duration calculation for State Transition Model Clock Forward structure -Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Forward structure.} -\usage{ -drmd_stm_cf(dpam, Ty = 10, discrate = 0, lifetable = NA, timestep = 1) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate (defaults to 10 years). Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{discrate}{Discount rate (\%) per year (defaults to zero).} - -\item{lifetable}{Optional. The lifetable must be a dataframe with columns named time and lx. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{timestep}{Optional, defaults to one (week).} -} -\value{ -List containing: -\itemize{ -\item pf: RMD in PF state -\item pd: RMD in PD state -\item os: RMD in either alive state -} -} -\description{ -Discretized Restricted Mean Duration calculation for State Transition Model Clock Forward structure -Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Forward structure. -} -\seealso{ -\code{\link[=drmd_psm]{drmd_psm()}} \code{\link[=drmd_stm_cr]{drmd_stm_cr()}} -} diff --git a/man/drmd_stm_cr.Rd b/man/drmd_stm_cr.Rd deleted file mode 100644 index c0525ff..0000000 --- a/man/drmd_stm_cr.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/discrmd.R -\name{drmd_stm_cr} -\alias{drmd_stm_cr} -\title{Discretized Restricted Mean Duration calculation for State Transition Model Clock Reset structure -Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Reset structure.} -\usage{ -drmd_stm_cr(dpam, Ty = 10, discrate = 0, lifetable = NA, timestep = 1) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate (defaults to 10 years). Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{discrate}{Discount rate (\%) per year (defaults to zero).} - -\item{lifetable}{Optional. The lifetable must be a dataframe with columns named time and lx. The first entry of the time column must be zero. Data should be sorted in ascending order by time, and all times must be unique.} - -\item{timestep}{Optional, defaults to one (week).} -} -\value{ -List containing: -\itemize{ -\item pf: RMD in PF state -\item pd: RMD in PD state -\item os: RMD in either alive state -} -} -\description{ -Discretized Restricted Mean Duration calculation for State Transition Model Clock Reset structure -Calculate restricted mean duration (RMD) in PF, PD and OS states under a State Transition Model Clock Reset structure. -} -\seealso{ -\code{\link[=drmd_stm_cf]{drmd_stm_cf()}} \code{\link[=drmd_psm]{drmd_psm()}} -} diff --git a/man/fit_ends_mods_given.Rd b/man/fit_ends_mods_given.Rd deleted file mode 100644 index b32a03e..0000000 --- a/man/fit_ends_mods_given.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{fit_ends_mods_given} -\alias{fit_ends_mods_given} -\title{Fit survival models to each endpoint, given type and spec -Internal function to fit survival models to each endpoint, given type and spec in format of \code{\link[=convert_fit2spec]{convert_fit2spec()}}} -\usage{ -fit_ends_mods_given(simdat, dpam, cuttime) -} -\arguments{ -\item{simdat}{is the (sample of the) patient-level dataset} - -\item{dpam}{is the currently fitted set of survival models to each endpoint} - -\item{cuttime}{is the cut-off time for two-piece modeling} -} -\value{ -A list by endpoint, then distribution, each containing two components: -\itemize{ -\item result: A list of class \emph{flexsurvreg} containing information about the fitted model. -\item error: Any error message returned on fitting the regression (NULL indicates no error). -} -} -\description{ -Fit survival models to each endpoint, given type and spec -Internal function to fit survival models to each endpoint, given type and spec in format of \code{\link[=convert_fit2spec]{convert_fit2spec()}} -} -\seealso{ -\code{\link[=convert_fit2spec]{convert_fit2spec()}}, \code{\link[=fit_ends_mods_par]{fit_ends_mods_par()}}, \code{\link[=fit_ends_mods_spl]{fit_ends_mods_spl()}} -} diff --git a/man/fit_mods.Rd b/man/fit_mods.Rd deleted file mode 100644 index 34273b2..0000000 --- a/man/fit_mods.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fitting.R -\name{fit_mods} -\alias{fit_mods} -\title{Fit survival regressions with multiple splines or parametric distributions} -\usage{ -fit_mods(durn1, durn2 = NA, evflag, type, spec) -} -\arguments{ -\item{durn1}{Start time} - -\item{durn2}{End time} - -\item{evflag}{Event flag} - -\item{type}{Type of model ("spl" for spline or "par" for parametric)} - -\item{spec}{Specification of model} -} -\value{ -A list by distribution, each containing two components: -\itemize{ -\item result: A list containing information about the fitted model. -\item error: Any error message returned on fitting the regression (NULL indicates no error). -} -} -\description{ -Fit survival regressions with multiple splines or parametric distributions -} diff --git a/man/fit_mods_par.Rd b/man/fit_mods_par.Rd deleted file mode 100644 index 66bd3c4..0000000 --- a/man/fit_mods_par.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fitting.R -\name{fit_mods_par} -\alias{fit_mods_par} -\title{Fit survival regressions with multiple parametric distributions} -\usage{ -fit_mods_par(durn1, durn2 = NA, evflag, dists, expvar = NA) -} -\arguments{ -\item{durn1}{First time point, corresponds with time in \code{\link[survival:Surv]{survival::Surv()}}. For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval.} - -\item{durn2}{Second time point, corresponds with time2 in \code{\link[survival:Surv]{survival::Surv()}}. The ending time of the interval for interval censored or counting process data only.} - -\item{evflag}{Event flag, corresponds with event in \link[survival:Surv]{survival::Surv}. The status indicator is normally 0=alive, 1=dead.} - -\item{dists}{is a vector of all the distributions (named according to \code{\link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg()}}) for which statistical fits are requested.} - -\item{expvar}{Explanatory variable for modeling of PPS} -} -\value{ -A list by distribution, each containing two components: -\itemize{ -\item result: A list of class \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} containing information about the fitted model. -\item error: Any error message returned on fitting the regression (NULL indicates no error). -} -} -\description{ -Fits survival regressions with \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} to multiple statistical distributions in one function call. -} diff --git a/man/fit_mods_spl.Rd b/man/fit_mods_spl.Rd deleted file mode 100644 index cd33014..0000000 --- a/man/fit_mods_spl.Rd +++ /dev/null @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fitting-spl.R -\name{fit_mods_spl} -\alias{fit_mods_spl} -\title{Fit survival regressions with multiple spline regressions} -\usage{ -fit_mods_spl( - durn1, - durn2 = NA, - evflag, - knot_set = 1:3, - scale_set = c("hazard", "odds", "normal"), - expvar = NA -) -} -\arguments{ -\item{durn1}{First time point, corresponds with time in \code{\link[survival:Surv]{survival::Surv()}}. For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval.} - -\item{durn2}{Second time point, corresponds with time2 in \code{\link[survival:Surv]{survival::Surv()}}. The ending time of the interval for interval censored or counting process data only.} - -\item{evflag}{Event flag, corresponds with event in \link[survival:Surv]{survival::Surv}. The status indicator is normally 0=alive, 1=dead.} - -\item{knot_set}{is a vector of the numbers of knots to consider, following \code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}}).} - -\item{scale_set}{is a vector of the spline scales to consider, following \code{\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline()}}).} - -\item{expvar}{Explanatory variable for modeling of PPS} -} -\value{ -A list by distribution, each containing two components: -\itemize{ -\item result: A list of class \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} containing information about the fitted model. -\item error: Any error message returned on fitting the regression (NULL indicates no error). -} -} -\description{ -Fits survival regressions with \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} to multiple Royston-Parmar splines specifications in one function call. -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \code{\link[survival:Surv]{survival::Surv()}} -} diff --git a/man/give_noparams.Rd b/man/give_noparams.Rd deleted file mode 100644 index 25b1e2a..0000000 --- a/man/give_noparams.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{give_noparams} -\alias{give_noparams} -\title{Number of parameters used by parametric statistical distributions} -\usage{ -give_noparams(type, spec) -} -\arguments{ -\item{type}{is either "par" for regular parametric form (exponential, weibull etc) or "spl" for Royston-Parmar splines.} - -\item{spec}{is a list comprising: -If type=="par": \code{dist} is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg}) and \code{pars} is a vector of the parameters for that distribution. -\itemize{ -\item Exponential distribution (\code{exp}) requires the rate parameter. -\item Weibull distribution (both \code{weibullPH} and \code{weibull} formulations) requires the shape and scale parameters. -\item Log-logistic distribution (\code{llogis}) requires the shape and scale parameters. -\item Log-normal distribution (\code{lnorm}) requires the meanlog and sdlog parameters. -\item Gamma and Gompertz distributions (\code{gamma} and \code{gompertz}) require the shape and rate parameters. -\item Generalized Gamma requires the mu, sigma and Q parameters if using the standard parameterization (\code{gengamma}) or shape, scale and k parameters if using the original parameterization (\code{gengamma.orig}). -If type=="spl": -\item \code{gamma} - Vector of parameters describing the baseline spline function, as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. This may be supplied as a vector with number of elements equal to the length of knots, in which case the parameters are common to all times. Alternatively a matrix may be supplied, with rows corresponding to different times, and columns corresponding to knots. -\item \code{knots} - Vector of locations of knots on the axis of log time, supplied in increasing order. Unlike in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}, these include the two boundary knots. -\item \code{scale} - Either "hazard", "odds", or "normal", as described in \link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline}. With the default of no knots in addition to the boundaries, this model reduces to the Weibull, log-logistic and log-normal respectively. The scale must be common to all times. -}} -} -\value{ -a numeric value -} -\description{ -Returns the number of parameters used by the specified statistical model -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/give_noparams_par.Rd b/man/give_noparams_par.Rd deleted file mode 100644 index 7f45638..0000000 --- a/man/give_noparams_par.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/basics.R -\name{give_noparams_par} -\alias{give_noparams_par} -\title{Number of parameters used by parametric statistical distributions} -\usage{ -give_noparams_par(dist) -} -\arguments{ -\item{dist}{is the statistical distribution (named per \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg})} -} -\value{ -a numeric value -} -\description{ -Returns the number of parameters used by one or many statistical distributions, named as per flexsurv. -} -\seealso{ -\link[flexsurv:flexsurvspline]{flexsurv::flexsurvspline} and \link[flexsurv:flexsurvreg]{flexsurv::flexsurvreg} -} diff --git a/man/graph_psm_hazards.Rd b/man/graph_psm_hazards.Rd index 1c0c6b3..e8fb076 100644 --- a/man/graph_psm_hazards.Rd +++ b/man/graph_psm_hazards.Rd @@ -13,13 +13,13 @@ graph_psm_hazards(timevar, endpoint, ptdata, dpam, psmtype) \item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: \itemize{ -\item ptid: patient identifier -\item pfs.durn: duration of PFS from baseline -\item pfs.flag: event flag for PFS (=1 if progression or death occurred, 0 for censoring) -\item os.durn: duration of OS from baseline -\item os.flag: event flag for OS (=1 if death occurred, 0 for censoring) -\item ttp.durn: duration of TTP from baseline (usually should be equal to pfs.durn) -\item ttp.flag: event flag for TTP (=1 if progression occurred, 0 for censoring). +\item \code{ptid}: patient identifier +\item \code{pfs.durn}: duration of PFS from baseline +\item \code{pfs.flag}: event flag for PFS (=1 if progression or death occurred, 0 for censoring) +\item \code{os.durn}: duration of OS from baseline +\item \code{os.flag}: event flag for OS (=1 if death occurred, 0 for censoring) +\item \code{ttp.durn}: duration of TTP from baseline (usually should be equal to pfs.durn) +\item \code{ttp.flag}: event flag for TTP (=1 if progression occurred, 0 for censoring). }} \item{dpam}{List of survival regressions for each endpoint: @@ -32,10 +32,14 @@ graph_psm_hazards(timevar, endpoint, ptdata, dpam, psmtype) \item post-progression survival clock reset (PPS-CR). }} -\item{psmtype}{Type of PSM - simple or complex} +\item{psmtype}{Either "simple" or "complex" PSM formulation} } \value{ -\code{adj} is the hazard adjusted for constraints, \code{unadj} is the unadjusted hazard +List containing: +\itemize{ +\item \code{adj} is the hazard adjusted for constraints +\item \code{unadj} is the unadjusted hazard +} } \description{ Graph the PSM hazard functions @@ -56,7 +60,6 @@ params <- list( # psmh_simple <- graph_psm_hazards( # timerange=(0:10)*6, # endpoint="OS", -# ptdata=bosonc, # dpam=params, # psmtype="simple") # psmh_simple$graph diff --git a/man/graph_psm_survs.Rd b/man/graph_psm_survs.Rd index 9a5e7c6..9427489 100644 --- a/man/graph_psm_survs.Rd +++ b/man/graph_psm_survs.Rd @@ -4,13 +4,24 @@ \alias{graph_psm_survs} \title{Graph the PSM survival functions} \usage{ -graph_psm_survs(timevar, endpoint, dpam, psmtype) +graph_psm_survs(timevar, endpoint, ptdata, dpam, psmtype) } \arguments{ \item{timevar}{Vector of times at which to calculate the hazards} \item{endpoint}{Endpoint for which hazard is required (TTP, PPD, PFS, OS or PPS)} +\item{ptdata}{Dataset of patient level data. Must be a tibble with columns named: +\itemize{ +\item \code{ptid}: patient identifier +\item \code{pfs.durn}: duration of PFS from baseline +\item \code{pfs.flag}: event flag for PFS (=1 if progression or death occurred, 0 for censoring) +\item \code{os.durn}: duration of OS from baseline +\item \code{os.flag}: event flag for OS (=1 if death occurred, 0 for censoring) +\item \code{ttp.durn}: duration of TTP from baseline (usually should be equal to pfs.durn) +\item \code{ttp.flag}: event flag for TTP (=1 if progression occurred, 0 for censoring). +}} + \item{dpam}{List of survival regressions for each endpoint: \itemize{ \item pre-progression death (PPD) @@ -21,15 +32,20 @@ graph_psm_survs(timevar, endpoint, dpam, psmtype) \item post-progression survival clock reset (PPS-CR). }} -\item{psmtype}{Type of PSM - simple or complex} +\item{psmtype}{Either "simple" or "complex" PSM formulation} } \value{ -\code{adj} is the hazard adjusted for constraints, \code{unadj} is the unadjusted hazard +List containing: +\itemize{ +\item \code{adj} is the hazard adjusted for constraints +\item \code{unadj} is the unadjusted hazard +} } \description{ Graph the PSM survival functions } \examples{ +\donttest{ bosonc <- create_dummydata("flexbosms") fits <- fit_ends_mods_par(bosonc) # Pick out best distribution according to min AIC @@ -41,15 +57,14 @@ params <- list( pps_cf = find_bestfit_par(fits$pps_cf, "aic")$fit, pps_cr = find_bestfit_par(fits$pps_cr, "aic")$fit ) -# Original OS graphic -graph_orig <- graph_survs(ptdata=bosonc, dpam=params) -graph_orig$graph$os -# New graphic illustrating effect of constraints on OS model -# psms_simple <- graph_psm_survs( -# timerange=6*(0:10), -# endpoint="OS", -# ptdata=bosonc, -# dpam=params, -# psmtype="simple") -# psms_simple$graph +# Graphic illustrating effect of constraints on OS model +psms_simple <- graph_psm_survs( + timevar=6*(0:10), + endpoint="OS", + ptdata=bosonc, + dpam=params, + psmtype="simple" +) +psms_simple$graph +} } diff --git a/man/pickout_psmhaz.Rd b/man/pickout_psmhaz.Rd deleted file mode 100644 index d8e19fc..0000000 --- a/man/pickout_psmhaz.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ppdpps.R -\name{pickout_psmhaz} -\alias{pickout_psmhaz} -\title{Obtain adjusted and unadjusted PSM hazards} -\usage{ -pickout_psmhaz(timevar, endpoint = NA, dpam, psmtype) -} -\arguments{ -\item{timevar}{Vector of times at which to calculate the hazards} - -\item{endpoint}{Endpoint for which hazard is required (TTP, PPD, PFS, OS or PPS)} - -\item{dpam}{List of survival regressions for each endpoint: -\itemize{ -\item pre-progression death (PPD) -\item time to progression (TTP) -\item progression-free survival (PFS) -\item overall survival (OS) -\item post-progression survival clock forward (PPS-CF) and -\item post-progression survival clock reset (PPS-CR). -}} - -\item{psmtype}{Type of PSM - simple or complex} -} -\value{ -\code{adj} is the hazard adjusted for constraints, \code{unadj} is the unadjusted hazard -} -\description{ -EXPERIMENTAL. Obtain adjusted and unadjusted PSM hazards for given endpoint and time -} diff --git a/man/prmd_os_psm.Rd b/man/prmd_os_psm.Rd deleted file mode 100644 index c54780a..0000000 --- a/man/prmd_os_psm.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{prmd_os_psm} -\alias{prmd_os_psm} -\title{Safely calculate restricted mean duration for overall survival in the partitioned survival model} -\usage{ -prmd_os_psm(...) -} -\arguments{ -\item{...}{Pass-through to \link{rmd_os_psm}} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration alive (i.e. in either progression free or progressed disease states) for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of \link{rmd_os_psm}. This function is called by \link{calc_allrmds}. -} diff --git a/man/prmd_pd_stm_cf.Rd b/man/prmd_pd_stm_cf.Rd deleted file mode 100644 index 2c6bda1..0000000 --- a/man/prmd_pd_stm_cf.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{prmd_pd_stm_cf} -\alias{prmd_pd_stm_cf} -\title{Safely calculate restricted mean duration in progressed disease state for clock forward state transition model} -\usage{ -prmd_pd_stm_cf(...) -} -\arguments{ -\item{...}{Pass-through to \link{rmd_pd_stm_cf}} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progressed disease state for the clock forward state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of \link{rmd_pd_stm_cf}. This function is called by \link{calc_allrmds}. -} diff --git a/man/prmd_pd_stm_cr.Rd b/man/prmd_pd_stm_cr.Rd deleted file mode 100644 index 640ab65..0000000 --- a/man/prmd_pd_stm_cr.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{prmd_pd_stm_cr} -\alias{prmd_pd_stm_cr} -\title{Safely calculate restricted mean duration in progressed disease state for clock reset state transition model} -\usage{ -prmd_pd_stm_cr(...) -} -\arguments{ -\item{...}{Pass-through to \link{rmd_pd_stm_cr}} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progressed disease state for the clock reset state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of \link{rmd_pd_stm_cr}. This function is called by \link{calc_allrmds}. -} diff --git a/man/prmd_pf_psm.Rd b/man/prmd_pf_psm.Rd deleted file mode 100644 index a7d5b85..0000000 --- a/man/prmd_pf_psm.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{prmd_pf_psm} -\alias{prmd_pf_psm} -\title{Safely calculate restricted mean duration in progression free state for the partitioned survival model} -\usage{ -prmd_pf_psm(...) -} -\arguments{ -\item{...}{Pass-through to \link{rmd_pf_psm}} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progression free state for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of \link{rmd_pf_psm}. This function is called by \link{calc_allrmds}. -} diff --git a/man/prmd_pf_stm.Rd b/man/prmd_pf_stm.Rd deleted file mode 100644 index f721cb5..0000000 --- a/man/prmd_pf_stm.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{prmd_pf_stm} -\alias{prmd_pf_stm} -\title{Safely calculate restricted mean duration in progression-free for state transition models} -\usage{ -prmd_pf_stm(...) -} -\arguments{ -\item{...}{Pass-through to \link{rmd_pf_stm}} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progression-free state for both the state transition clock forward and clock reset models. Requires a carefully formatted list of fitted survival regressions for the necessary endpoints, and the time duration to calculate over. Wrapper with 'possibly' of \link{rmd_pf_stm}. This function is called by \link{calc_allrmds}. -} diff --git a/man/rmd_os_psm.Rd b/man/rmd_os_psm.Rd deleted file mode 100644 index ae0569e..0000000 --- a/man/rmd_os_psm.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{rmd_os_psm} -\alias{rmd_os_psm} -\title{Restricted mean duration for overall survival in the partitioned survival model} -\usage{ -rmd_os_psm(dpam, Ty = 10, starting = c(1, 0, 0), discrate = 0) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate. Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{starting}{Vector of membership probabilities at time zero.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration alive (i.e. in either progression free or progressed disease states) for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. -} -\seealso{ -Used safely as \link{prmd_os_psm} by \link{calc_allrmds} -} diff --git a/man/rmd_pd_stm_cf.Rd b/man/rmd_pd_stm_cf.Rd deleted file mode 100644 index 56eeeee..0000000 --- a/man/rmd_pd_stm_cf.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{rmd_pd_stm_cf} -\alias{rmd_pd_stm_cf} -\title{Restricted mean duration in progressed disease state for clock forward state transition model} -\usage{ -rmd_pd_stm_cf(dpam, Ty = 10, starting = c(1, 0, 0), discrate = 0) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate. Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{starting}{Vector of membership probabilities at time zero.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progressed disease state for the clock forward state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. -} -\seealso{ -Used safely as \link{prmd_pd_stm_cf} by \link{calc_allrmds} -} diff --git a/man/rmd_pd_stm_cr.Rd b/man/rmd_pd_stm_cr.Rd deleted file mode 100644 index b38a3e1..0000000 --- a/man/rmd_pd_stm_cr.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{rmd_pd_stm_cr} -\alias{rmd_pd_stm_cr} -\title{Restricted mean duration in progressed disease state for clock reset state transition model} -\usage{ -rmd_pd_stm_cr(dpam, Ty = 10, starting = c(1, 0, 0), discrate = 0) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate. Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{starting}{Vector of membership probabilities at time zero.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progressed disease state for the clock reset state transition model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. -} -\seealso{ -\link{rmd_pd_stm_cr} - -Used safely as \link{prmd_pd_stm_cr} by \link{calc_allrmds} -} diff --git a/man/rmd_pf_psm.Rd b/man/rmd_pf_psm.Rd deleted file mode 100644 index f20a987..0000000 --- a/man/rmd_pf_psm.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{rmd_pf_psm} -\alias{rmd_pf_psm} -\title{Restricted mean duration in progression free state for the partitioned survival model} -\usage{ -rmd_pf_psm(dpam, Ty = 10, starting = c(1, 0, 0), discrate = 0) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate. Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{starting}{Vector of membership probabilities at time zero.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progression free state for the partitioned survival model. Requires a carefully formatted list of fitted survival regressions for necessary endpoints, and the time duration to calculate over. -} -\seealso{ -Used safely as \link{prmd_pf_psm} by \link{calc_allrmds} -} diff --git a/man/rmd_pf_stm.Rd b/man/rmd_pf_stm.Rd deleted file mode 100644 index cc20528..0000000 --- a/man/rmd_pf_stm.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/resmeans.R -\name{rmd_pf_stm} -\alias{rmd_pf_stm} -\title{Restricted mean duration in progression-free for state transition models} -\usage{ -rmd_pf_stm(dpam, Ty = 10, starting = c(1, 0, 0), discrate = 0) -} -\arguments{ -\item{dpam}{List of survival regressions for model endpoints. These must include time to progression (TTP) and pre-progression death (PPD).} - -\item{Ty}{Time duration over which to calculate. Assumes input is in years, and patient-level data is recorded in weeks.} - -\item{starting}{Vector of membership probabilities at time zero.} - -\item{discrate}{Discount rate (\%) per year} -} -\value{ -Numeric value in same time unit as patient-level data (weeks). -} -\description{ -Calculates the mean duration in the progression-free state for both the state transition clock forward and clock reset models. Requires a carefully formatted list of fitted survival regressions for the necessary endpoints, and the time duration to calculate over. -} -\seealso{ -Used safely as \link{prmd_pf_stm} by \link{calc_allrmds} -} diff --git a/man/vonelookup.Rd b/man/vonelookup.Rd deleted file mode 100644 index cc10043..0000000 --- a/man/vonelookup.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ltablesurv.R -\name{vonelookup} -\alias{vonelookup} -\title{VoneLOOKUP function} -\usage{ -vonelookup(oneindexval, indexvec, valvec, method = "geom") -} -\arguments{ -\item{oneindexval}{The single index value to be looked-up} - -\item{indexvec}{The vector of indices to look-up in} - -\item{valvec}{The vector of values corresponding to the vector of indices} - -\item{method}{Method may be \code{floor}, \code{ceiling}, \code{arith} or \code{geom} (default).} -} -\value{ -Numeric value or vector, depending on the lookup/interpolation method chosen: -\itemize{ -\item \code{floor}: Floor value, where interpolation is required between measured values -\item \code{ceiling}: Ceiling value, where interpolation is required between measured values -\item \code{arith}: Arithmetic mean, where interpolation is required between measured values -\item \code{geom}: Geometric mean, where interpolation is required between measured values -} -} -\description{ -Function to lookup a single (one) value according to an index. Aims to behave similarly to VLOOKUP in Microsoft Excel. -} -\seealso{ -\link{vlookup} -} diff --git a/vignettes/mortality-adjustments.Rmd b/vignettes/mortality-adjustments.Rmd index e005885..b26e565 100644 --- a/vignettes/mortality-adjustments.Rmd +++ b/vignettes/mortality-adjustments.Rmd @@ -114,7 +114,6 @@ First we load the packages we need - all of which are suggested for or imported ```{r packages, message=FALSE} library("dplyr") -library("HMDHFDplus") library("psm3mkv") library("tibble") ``` @@ -124,6 +123,9 @@ library("tibble") In order to apply constraints to background mortality, we need some background mortality data, in the form of a lifetable. We can take this from the Human Mortality Database using the *HMDHFDplus* package mentioned above (with thanks to Robert Hettle for the recommendation). The lifetable will need to start from an assumed age at baseline. Lifetables are constructed by time in years. ```{r ltable1, eval=FALSE} +# HMD HFD package +library("HMDHFDplus") + # Assumed population age at baseline (time=0) baseage <- 51.0 diff --git a/vignettes/psm3mkv.bib b/vignettes/psm3mkv.bib index 21c57b3..05e689a 100644 --- a/vignettes/psm3mkv.bib +++ b/vignettes/psm3mkv.bib @@ -104,14 +104,14 @@ @Manual{pack_tibble url = {https://CRAN.R-project.org/package=tibble}, } -@Manual{@pack_boot, +@Manual{pack_boot, title = {boot: Bootstrap R (S-Plus) Functions}, author = {{Angelo Canty} and {B. D. Ripley}}, year = {2024}, note = {R package version 1.3-29}, } -@Manual{@pack_ggsci, +@Manual{pack_ggsci, title = {ggsci: Scientific Journal and Sci-Fi Themed Color Palettes for 'ggplot2'}, author = {Nan Xiao},