Skip to content

Commit d9d8342

Browse files
committed
Update to description adding Cole & Hernan (2014) reference
1 parent df0e5c0 commit d9d8342

9 files changed

Lines changed: 57 additions & 34 deletions

.DS_Store

0 Bytes
Binary file not shown.

DESCRIPTION

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
Package: weightedsurv
22
Title: Survival Analysis with Subject-Specific (Case Weights) and Time-Dependent Weighting
33
Version: 0.1.0
4-
Authors@R:
5-
person("Larry", "Leon", , "larry.leon.05@post.harvard.edu", role = c("aut", "cre"))
6-
Description:
7-
Survival analysis functions allowing for time-dependent and subject-specific
8-
(for example, propensity-scores) weighting. Weighted estimation for Cox model,
9-
Kaplan-Meier treatment survival curves as well as treatment difference along
10-
with point-wise and simultaneous confidence bands, and restricted mean
11-
survival time comparisons where 'RMST' estimates are evaluated across all
12-
potential truncation times (point-wise and simultaneous bands).
4+
Authors@R: person("Larry", "Leon", , "larry.leon.05@post.harvard.edu", role = c("aut", "cre"))
5+
Description: Survival analysis functions allowing for time-dependent and subject-specific (for example, propensity-scores) weighting. Weighted estimation for Cox model, Kaplan-Meier treatment survival curves as well as treatment difference along with point-wise and simultaneous confidence bands, and restricted mean survival time comparisons where 'RMST' estimates are evaluated across all potential truncation times (point-wise and simultaneous bands). See for example, Cole, S. R. & Hernán, M. A. (2004). Adjusted survival curves with inverse probability weights. Computer Methods and Programs in Biomedicine, 75(1), 45–49. doi:10.1016/j.cmpb.2003.10.012
136
License: MIT + file LICENSE
147
Encoding: UTF-8
158
Roxygen: list(markdown = TRUE)

R/kmplotting_helpers.R

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#' @param x Numeric vector of time points.
77
#' @param surv Numeric vector of survival probabilities.
88
#' @param se Numeric vector of standard errors of survival probabilities.
9-
#' @param conf_level Confidence level for interval (default 0.95).
9+
#' @param conf_level Numeric; confidence level for interval (default 0.95).
1010
#' @param col Color for the polygon.
11+
#'
1112
#' @importFrom graphics polygon
13+
#' @return Invisibly returns NULL. Used for plotting side effects.
1214
#' @export
1315

1416
plot_km_confint_polygon <- function(x, surv, se, conf_level, col) {
@@ -51,9 +53,12 @@ plot_km_confint_polygon <- function(x, surv, se, conf_level, col) {
5153
#' @param conf.int Logical; show confidence intervals (default FALSE).
5254
#' @param conf_level Confidence level (default 0.95).
5355
#' @param censor.cex Numeric; censoring mark size (default 1.0).
56+
#' @param time.zero Numeric; time zero value for risk table alignment (default 0).
57+
#' @param tpoints.add Numeric vector; additional time points to include (default c(0)).
5458
#' @param ... Additional arguments to plot.
55-
#' @inheritParams KM_plot_2sample_weighted_counting
59+
#'
5660
#' @importFrom graphics plot lines legend title axis box points
61+
#' @return Invisibly returns NULL. Used for plotting side effects.
5762
#' @export
5863

5964
plot_km_curves_counting <- function(
@@ -129,6 +134,7 @@ check_km_curve <- function(S.KM, group_name = "Group", stop_on_error = TRUE) {
129134
#' @param y.risk0 Numeric; y position for group 0 risk table.
130135
#' @param y.risk1 Numeric; y position for group 1 risk table.
131136
#' @importFrom graphics text axis
137+
#' @return Invisibly returns NULL. Used for plotting side effects.
132138
#' @export
133139

134140
add_risk_table <- function(risk.points, rpoints0, rpoints1, col.0, col.1, risk.cex, ymin, risk_offset, risk_delta, y.risk0, y.risk1) {
@@ -142,13 +148,15 @@ add_risk_table <- function(risk.points, rpoints0, rpoints1, col.0, col.1, risk.c
142148
#'
143149
#' Adds median survival annotation to a Kaplan-Meier plot.
144150
#'
145-
#' @param medians_df Data frame with quantile results.
146-
#' @param med.digits Integer; digits for median.
147-
#' @param med.cex Numeric; text size for median.
148-
#' @param med.font Integer; font for median.
149-
#' @param xmed.fraction Numeric; x position fraction.
150-
#' @param ymed.offset Numeric; y offset.
151+
#' @param medians_df Data frame with quantile results. Should contain columns \code{quantile}, \code{lower}, \code{upper}, and \code{group}.
152+
#' @param med.digits Integer; number of digits to display for median and confidence interval.
153+
#' @param med.cex Numeric; text size for median annotation.
154+
#' @param med.font Integer; font for median annotation.
155+
#' @param xmed.fraction Numeric; fraction of the x-axis for annotation placement (e.g., 0.8 for 80\% to the right).
156+
#' @param ymed.offset Numeric; offset from the top of the plot for annotation placement.
157+
#'
151158
#' @importFrom graphics text
159+
#' @return Invisibly returns NULL. Used for plotting side effects.
152160
#' @export
153161

154162
add_median_annotation <- function(medians_df, med.digits, med.cex, med.font, xmed.fraction, ymed.offset) {
@@ -173,22 +181,24 @@ add_median_annotation <- function(medians_df, med.digits, med.cex, med.font, xme
173181
#'
174182
#' Adds legends for Cox model, log-rank test, and arms to a Kaplan-Meier plot.
175183
#'
176-
#' @param dfcount List with results.
184+
#' @param dfcount List with results, typically output from a survival analysis function. Should contain elements such as \code{cox_results}, \code{z.score}, and \code{zlogrank_text}.
177185
#' @param show.cox Logical; show Cox legend.
178186
#' @param cox.cex Numeric; Cox legend size.
179-
#' @param put.legend.cox Character; Cox legend position.
187+
#' @param put.legend.cox Character; Cox legend position (e.g., "topright").
180188
#' @param show.logrank Logical; show logrank legend.
181189
#' @param logrank.cex Numeric; logrank legend size.
182-
#' @param put.legend.lr Character; logrank legend position.
190+
#' @param put.legend.lr Character; logrank legend position (e.g., "topleft").
183191
#' @param show_arm_legend Logical; show arm legend.
184192
#' @param arms Character vector of arm labels.
185193
#' @param col.1 Color for group 1.
186194
#' @param col.0 Color for group 0.
187195
#' @param ltys Line types.
188196
#' @param lwds Line widths.
189197
#' @param arm.cex Numeric; arm legend size.
190-
#' @param put.legend.arms Character; arm legend position.
198+
#' @param put.legend.arms Character; arm legend position (e.g., "left").
199+
#'
191200
#' @importFrom graphics legend
201+
#' @return Invisibly returns NULL. Used for plotting side effects.
192202
#' @export
193203

194204
add_legends <- function(dfcount, show.cox, cox.cex, put.legend.cox, show.logrank, logrank.cex, put.legend.lr, show_arm_legend, arms, col.1, col.0, ltys, lwds, arm.cex, put.legend.arms) {

man/add_legends.Rd

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/add_median_annotation.Rd

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/add_risk_table.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_km_confint_polygon.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plot_km_curves_counting.Rd

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/weightedsurv_examples.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Key Features
143143

144144

145145
```{r, message = FALSE, warning = FALSE}
146+
oldpar <- par(no.readonly = TRUE)
146147
library(survival)
147148
# to install weightedKMplots
148149
# library(devtools)
@@ -312,6 +313,7 @@ dfcount_rotterdam_unwtd <- get_dfcounting(df=df_rotterdam, tte.name=tte.name, ev
312313
313314
dfcount_rotterdam_wtd <- get_dfcounting(df=df_rotterdam, tte.name=tte.name, event.name=event.name, treat.name=treat.name, arms=arms, by.risk=24,
314315
weight.name="sw.weights")
316+
315317
```
316318

317319
---- Plotting Weighted vs Unweighted ----
@@ -788,6 +790,9 @@ non-stratified (should be same as above results without stratification)
788790
```{r}
789791
with(res,lr^2/sig2_lr)
790792
with(res,z.score^2)
793+
794+
# Restore when done
795+
par(oldpar)
791796
```
792797

793798

0 commit comments

Comments
 (0)