Description Usage Arguments Value Examples
View source: R/km_plot_weight.R
Weighted KM plot
1 2 3 4 5 6 7 8 9 10 11 12 | km_plot_weight(
data.in,
indicator.var = "indicator",
class.of.int = NULL,
prob.names = NULL,
filename = NULL,
tte = "AVAL",
event = "event",
trt = "trt",
time.unit = "month",
prefix.title = "In strata:"
)
|
data.in |
input data, patients in rows and variables in columns. This could be an output from ipw_strata() or ps_match_strata(). |
indicator.var |
( |
class.of.int |
( |
prob.names |
column names for the probability scores to be used as weights. The order of probnames should match the order of class.of.int. if probnames is NULL, the function will assume that the probnames are pred0, pred1, prod2, prod1or2 in the example in class.of.int. |
filename |
if it is not NULL, a png file will be generated |
tte |
( |
event |
( |
trt |
( |
time.unit |
time unit to be marked in x axis |
prefix.title |
prefix for title |
return a list of plots with class of ggsurvplot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
library(dplyr)
clinical_1 <- clinical %>% mutate(
indicator = case_when(
STRATUM == "strata_1" ~ 0,
STRATUM == "strata_2" ~ 1,
is.na(STRATUM) & ARM == "experimental" ~ 1,
TRUE ~ -1
),
ARM = factor(ARM, levels = c("control","experimental")),
BNLR = case_when(
is.na(BNLR) ~ median(BNLR, na.rm = TRUE),
TRUE ~ BNLR
)
)
ipw_res1 <- ipw_strata(
data.in = clinical_1, formula = indicator ~ BECOG + SEX + BNLR,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 1, "strata_2" = 0)
)
km_plot_weight(ipw_res1$data,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT",
trt = "ARM", class.of.int = list("strata_2" = 0))
ps_res1 <- ps_match_strata(
data.in = clinical_1, formula = indicator ~ BECOG + SEX + BNLR,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT", trt = "ARM",
class.of.int = list("strata_1" = 1, "strata_2" = 0)
)
km_plot_weight(ps_res1$data,
indicator.var = "indicator", tte = "OS_MONTH", event = "OS_EVENT",
trt = "ARM", class.of.int = list("strata_1" = 1, "strata_2" = 0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.