Visualize the Effect of a Continuous Variable on a Time-to-Event Outcome
Overview
Graphically display the (causal) effect of a continuous variable on a time-to-event outcome using multiple different types of plots based on g-computation. Those functions include, among others, survival area plots, survival contour plots, survival quantile plots and 3D surface plots. Due to the use of g-computation, all plot allow confounder-adjustment naturally. For details, see Robin Denz, Nina Timmesfeld (2023) doi:10.1097/EDE.0000000000001630.
Enhancements:
- Added the
range_x,range_yandrange_zarguments to theplot_surv_3D_surface()function to allow changes of the axis ranges.
New Features:
- Added the
conf_intargument toplot_surv_rmst()andplot_surv_rmtl()
Bug Fixes
- The
legend.positionargument inplot_surv_area()is no longer being ignored. - Fixed annoying messages printed due to new
ggplot2version.
From NEWS.md in the release
Install
Health
ERRORexamplesr-devel-linux-x86_64-debian-gcc
Running examples in ‘contsurvplot-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: curve_cont
> ### Title: Estimate Counterfactual Survival or Failure Probabilities for
> ### Levels of a Continuous Variable
> ### Aliases: curve_cont
>
> ### ** Examples
>
> library(contsurvplot)
> library(riskRegression)
riskRegression version 2026.03.11
> library(survival)
>
> # using data from the survival package
> data(nafld, package="survival")
>
> # take a random sample to keep example fast
> set.seed(42)
> nafld1 <- nafld1[sample(nrow(nafld1), 150), ]
>
> # fit cox-model with age
> model <- coxph(Surv(futime, status) ~ age, data=nafld1, x=TRUE)
>
> # estimate survival probability at some points in time, for
> # a range of age values
> plotdata <- curve_cont(data=nafld1,
+ variable="age",
+ model=model,
+ horizon=c(50, 60, 70, 80),
+ times=c(1000, 2000, 3000, 4000))
Error in a$specials[[i]] : subscript out of bounds
Calls: curve_cont ... predictCox -> coxVariableName -> delete.response -> off
Execution haltedERRORre-building of vignette outputsr-devel-linux-x86_64-debian-gcc
Error(s) in re-building vignettes:
...
--- re-building ‘introduction.Rmd’ using rmarkdown
Quitting from introduction.Rmd:93-96 [unnamed-chunk-7]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<error/rlang_error>
Error in `a$specials[[i]]`:
! subscript out of bounds
---
Backtrace:
▆
1. └─contsurvplot::curve_cont(...)
2. └─contsurvplot:::one_iteration(...)
3. ├─riskRegression::predictRisk(...)
4. └─riskRegression:::predictRisk.coxph(...)
5. └─riskRegression::predictCox(...)
6. └─riskRegression::coxVariableName(object, model.frame = object.modelFrame)
7. └─stats::delete.response(...)
8. └─stats (local) off(a$specials[[i]])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: processing vignette 'introduction.Rmd' failed with diagnostics:
subscript out of bounds
--- failed re-building ‘introduction.Rmd’
SUMMARY: processing the following file failed:
‘introduction.Rmd’
Error: Vignette re-building failed.
Execution haltedERRORtestsr-devel-linux-x86_64-debian-gcc
Running ‘testthat.R’ [13s/22s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library(contsurvplot)
Please cite as:
Denz R, Timmesfeld N (2023). "Visualizing the (Causal) Effect of a Continuous Variable on a Time-To-Event Outcome." Epidemiology, 34 (5). doi: 10.1097/EDE.0000000000001630.
> library(survival)
> library(testthat)
>
> test_check("contsurvplot")
Saving _problems/test_curve_cont-13.R
Saving _problems/test_curve_cont-20.R
Saving _problems/test_curve_cont-29.R
Saving _problems/test_curve_cont-36.R
starting worker pid=3856762 on localhost:11643 at 16:32:39.392
starting worker pid=3856763 on localhost:11643 at 16:32:39.438
Loading required package: contsurvplot
Please cite as:
Denz R, Timmesfeld N (2023). "Visualizing the (Causal) Effect of a Continuous Variable on a Time-To-Event Outcome." Epidemiology, 34 (5). doi: 10.1097/EDE.0000000000001630.
loaded contsurvplot and set parent environment
Loading required packa
...[truncated]...
ot-change-horizon.svg', 'plot_surv_area/plot-cif.svg',
'plot_surv_area/plot-custom-colors.svg', 'plot_surv_area/plot-defaults.svg',
'plot_surv_area/plot-discrete-bins.svg',
'plot_surv_area/plot-discrete-round.svg',
'plot_surv_area/plot-lots-of-stuff.svg', 'plot_surv_area/plot-sep-lines.svg',
'plot_surv_area/plot-with-group.svg',
'plot_surv_area/plot-with-kaplan-meier.svg',
'plot_surv_area/plot-with-nonmonotonic.svg',
'plot_surv_at_t/plot-change-horizon.svg', …,
'plot_surv_rmtl/plot-with-group-ci.svg', and
'plot_surv_rmtl/plot-with-group.svg'
Error:
! Test failures.
Execution halted
Error in unserialize(node$con) :
error reading from connection '->localhost:11643'
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted
Error in unserialize(node$con) :
error reading from connection '->localhost:11643'
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted- ERROR12 OK, 1 ERROR2026-10-24
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- ERROR12 OK, 1 ERROR2026-06-08
Show 1 earlier changeHide 1 earlier change
- OK14 OK2026-03-10
Documentation
- Help pages
- 13includes a package overview page
- Examples that run
- 100%12 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 99%
- Return-value docs
- 100%
- Help pages citing references
- 69%
Downloads
Repository
- PRs merged (all time)
- 0%
- Median days to close, 50 most recently updated closed issues
- 2
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
9 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/robindenz1/contsurvplot on 2026-10-21.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-01-29 · The repository has a site deploy workflow
pkgdown site last built 2026-01-29
Show all practicesHide 2 practices
Dependencies
Code & Tests
People & History
Package metadata
- First published
- 2022-08-16
- Total releases
- 5 / 4 yrs
- License
- GPL (>= 3) OSI
- Download size
- 1.9 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("contsurvplot")The package provides a citation file that builds its entry when R runs it. Run citation() to see it.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.