calc_std_diff: Calculate standardized difference

Description Usage Arguments Value Note Examples

View source: R/cal_std_diff.R

Description

Calculate standardized difference

Usage

1
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

Note

Calculation from Austin and Stuart (2015)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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))
 )

PropensitySub documentation built on July 29, 2021, 9:07 a.m.