---
title: "Frequently Asked Questions about the adjustedCurves Package"
output: rmarkdown::html_vignette
author: "Robin Denz"
vignette: >
  %\VignetteIndexEntry{FAQ adjustedCurves}
  %\VignetteEngine{knitr::rmarkdown}
  \usepackage[utf8]{inputenc}
---

This vignette answers some of the most frequently asked questions about the package.

## How do I add a table with the number at risk below the plot?

Since version 0.11.1, it is possible to use the `risk_table` argument of the `plot.adjustedsurv()` function to directly add such tables to the plot. It is, however, recommended to read the associated point in the documentation page first (`?plot.adjustedsurv`) first to find out whether adding such tables is a good idea or not.

## How do I get a p-value?

There is no easy answer to this question, because it is inherently vague. What should the p-value be for? Which hypothesis should be tested using it? The package offers multiple different ways to compare adjusted survival curves and CIFs, as described in the associated vignette (`vignette(topic="comparing_groups", package="adjustedCurves")`) and the documentation pages. Some of these also return p-values.

## Does this package support time-varying covariates?

No, time-varying covariates are currently not supported. There are two main reasons for this: (1) with time-varying covariates, it is unclear what the target estimand should be (see for example Hernán & Robins 2020) and (2) estimating one of the possible target estimands is, depending on the causal assumptions, a very complicated endeavor which cannot be easily automated. It is doubtful that this package will ever contain such methods, but we won't rule it out completely.

## Which method should I use?

Unfortunately there is no easy answer for this question either. It depends both on goals of the analysis, the causal assumptions and the observed data. Some theoretical guidance and comparison of most of the implemented methods is given in the associated simulation study (see Denz et al. 2023). More practical guidance (e.g. which method can I use to get adjusted survival curves if there are more than two groups of interest etc.) can be found in the methods vignette (`vignette(topic="method_overview", package="adjustedCurves")`).

## How can I interpret the results?

The interpretation of the results heavily depend on the causal assumptions made by the user. Resulting survival curves or CIFs cannot generally be interpreted as counterfactual survival curves. This interpretation is only possible under the causal identifiability assumptions and method-specific assumptions, as described in Denz et al. (2023). If these assumptions cannot be made, the results should only be interpreted as "marginal survival curves / CIFs after adjusting for confounders X".

## Is it possible to obtain adjusted survival curves for data with competing events?

No, this is generally impossible. Users may, however, use the `adjustedcif()` function to estimate confounder-adjusted cause-specific cumulative incidence functions instead.

## Can I use this package if the variable I am interested in is continuous?

It is possible, but not recommended. To get adjusted survival curves or CIFs for a continuous variable of interest with this package, users need to categorize the variable before doing any kind of analysis. This leads to a loss of information, which may lead to biased estimates or a loss of statistical power. To circumvent this issue, we developed another R-package called `contsurvplot` which directly implements plotting methods for continuous variables, as described in Denz & Timmesfeld (2023).

## Does this package offer an adjusted log-rank test?

No, it currently doesn't. We only know of one type of log-rank test that allows confounder-adjustment, which is the inverse probability of treatment weighted log-rank test described by Xie et al. (2005). Since this only works for one type of method, it is not implemented here. It is, however, implemented in the `RISCA` package. Other ways to compare survival curves or CIFs using the `adjustedCurves` package are described in the documentation and the associated vignette (`vignette(topic="comparing_groups", package="adjustedCurves")`).

## How do I deal with missing values?

The package offers direct support for multiple imputation as performed using the `mice` package. How exactly these imputations should be performed is beyond the scope of this package. We recommend seeking information on the `mice` package website or the associated book.

## I have fit a `coxph` model with start/stop type data. Can I use this model to obtain adjusted survival curves?

This is currently not supported. More information may be found in the question about time-varying covariates.

## Can interactions be included when estimating adjusted survival curves or CIFs?

Yes, that is possible. For example, if the user wants to use `method="direct"` with a `coxph` model as outcome model, interactions can be included using the standard syntax in the `coxph` call if they are not the main variable of interest. If, on the other hand, the main thing of interest *is* the interaction (e.g. the user wants to plot survival curves / CIFs for all possible combinations of two categorical variables) a slightly different procedure is needed. Users then need to construct a new variable that directly combines the two categorical variables (for example using the `interaction()` function) and use this new variable in both the `adjustedsurv()` / `adjustedcif()` call and the `coxph` model.

## How do I cite this package?

We recommend citing the relevant method-specific paper and the paper associated with this package when using it in a scientific publication. For example, when using `method="iptw_km"` in the `adjustedsurv()` function, we recommend citing both Xie et al. (2005) and the article associated with the package (Denz et al. 2023). 

# References

Robin Denz, Renate Klaaßen-Mielke, and Nina Timmesfeld (2023). "A Comparison of Different Methods to Adjust Survival Curves for Confounders". In: Statistics in Medicine 42.10, pp. 1461-1479.

Robin Denz, Nina Timmesfeld (2023). "Visualizing the (Causal) Effect of a Continuous Variable on a Time-To-Event Outcome". In: Epidemiology 34.5, pp. 652-660.

Jun Xie and Chaofeng Liu (2005). "Adjusted Kaplan-Meier Estimator and Log- Rank Test with Inverse Probability of Treatment Weighting for Survival Data". In: Statistics in Medicine 24, pp. 3089-3110.

Miguel Hernán and James Robins (2020). Causal Inference: What If. Boca Raton: Chapman & Hall/CRC
