Learn R Programming

PropensitySub (version 0.2.0)

std_diff_plot: Compare weighted and unweighted (naive analysis) standardized difference in plot

Description

Compare weighted and unweighted (naive analysis) standardized difference in plot

Usage

std_diff_plot(
  diff.list,
  legend.pos = "right",
  prefix.title = "In strata:",
  xlim.low = 0,
  xlim.high = 1
)

Arguments

diff.list

data list returned by function std_diff.

legend.pos

legend position: "left", "top", "right", "bottom".

prefix.title

prefix for title

xlim.low

(numeric) lower bound of xlim

xlim.high

(numeric) upper bound of xlim

Examples

Run this code
# NOT RUN {
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)
 )
ipw_diff <- std_diff(
  data.in = ipw_res1$data, vars = c("BECOG", "SEX", "BNLR"),
  indicator.var = "indicator", trt = "ARM",
  class.of.int = list("strata_1" = 1, "strata_2" = 0),
  usubjid.var = "SUBJID"
)
std_diff_plot(ipw_diff)
# }

Run the code above in your browser using DataLab