Learn R Programming

PropensitySub (version 0.2.0)

calc_std_diff: Calculate standardized difference

Description

Calculate standardized difference

Usage

calc_std_diff(vars, data0, weight0, data1, weight1)

Arguments

vars

variables of interest. standardized difference of each variable listed here will be calculated.

data0

A data.frame which include vars as columns from reference arm. All data are expected to be numerical. If a column is not numerical, it will be turned to numerical by model.matrix.

weight0

weights for each record in reference arm.

data1

A data.frame which include vars as columns from comparison arm. All data are expected to be numerical. If a column is not numerical, it will be turned to numerical by model.matrix.

weight1

weights for each record in comparison arm.

Value

return a numeric vector for standardized difference of each variable

Examples

Run this code
# NOT RUN {
library(dplyr)
data0 <- clinical %>% filter(ARM == "experimental")
data1 <- clinical %>% filter(ARM == "control")
calc_std_diff(
  vars = c("BECOG", "SEX"),
  data0 = data0,
  weight0 = rep(1, nrow(data0)),
  data1 = data1,
  weight1 = rep(1, nrow(data1))
 )
# }

Run the code above in your browser using DataLab