R/Balance.R
computeCovariateBalance.Rd
For every covariate, prevalence in treatment and comparator groups before and after matching/trimming/weighting are computed. When variable ratio matching was used the balance score will be corrected according the method described in Austin et al (2008).
computeCovariateBalance(
population,
cohortMethodData,
subgroupCovariateId = NULL,
maxCohortSize = 250000,
covariateFilter = NULL
)
A data frame containing the people that are remaining after PS adjustment.
An object of type CohortMethodData as generated using
getDbCohortMethodData()
.
Optional: a covariate ID of a binary covariate that indicates a subgroup of interest. Both the before and after populations will be restricted to this subgroup before computing covariate balance.
If the target or comparator cohort are larger than this number, they will be downsampled before computing covariate balance to save time. Setting this number to 0 means no downsampling will be applied.
Determines the covariates for which to compute covariate balance. Either a vector
of covariate IDs, or a table 1 specifications object as generated for example using
FeatureExtraction::getDefaultTable1Specifications()
. If covariateFilter = NULL
,
balance will be computed for all variables found in the data.
Returns a tibble describing the covariate balance before and after PS adjustment,
with one row per covariate, with the same data as the covariateRef
table in the CohortMethodData
object,
and the following additional columns:
beforeMatchingMeanTarget: The (weighted) mean value in the target before PS adjustment.
beforeMatchingMeanComparator: The (weighted) mean value in the comparator before PS adjustment.
beforeMatchingSumTarget: The (weighted) sum value in the target before PS adjustment.
beforeMatchingSumComparator: The (weighted) sum value in the comparator before PS adjustment.
beforeMatchingSdTarget: The standard deviation of the value in the target before PS adjustment.
beforeMatchingSdComparator: The standard deviation of the value in the comparator before PS adjustment.
beforeMatchingMean: The mean of the value across target and comparator before PS adjustment.
beforeMatchingSd: The standard deviation of the value across target and comparator before PS adjustment.
afterMatchingMeanTarget: The (weighted) mean value in the target after PS adjustment.
afterMatchingMeanComparator: The (weighted) mean value in the comparator after PS adjustment.
afterMatchingSumTarget: The (weighted) sum value in the target after PS adjustment.
afterMatchingSumComparator: The (weighted) sum value in the comparator after PS adjustment.
afterMatchingSdTarget: The standard deviation of the value in the target after PS adjustment.
afterMatchingSdComparator: The standard deviation of the value in the comparator after PS adjustment.
afterMatchingMean: The mean of the value across target and comparator after PS adjustment.
afterMatchingSd: The standard deviation of the value across target and comparator after PS adjustment.
beforeMatchingStdDiff: The standardized difference of means when comparing the target to the comparator before PS adjustment.
afterMatchingStdDiff: The standardized difference of means when comparing the target to the comparator after PS adjustment.
targetStdDiff: The standardized difference of means when comparing the target before PS adjustment to the target after PS adjustment.
comparatorStdDiff: The standardized difference of means when comparing the comparator before PS adjustment to the comparator after PS adjustment. -targetComparatorStdDiff: The standardized difference of means when comparing the entire population before PS adjustment to the entire population after PS adjustment.
The 'beforeMatchingStdDiff' and 'afterMatchingStdDiff' columns inform on the balance: are the target and comparator sufficiently similar in terms of baseline covariates to allow for valid causal estimation?
The 'targetStdDiff', 'comparatorStdDiff', and 'targetComparatorStdDiff' columns inform on the generalizability: are the cohorts after PS adjustment sufficiently similar to the cohorts before adjustment to allow generalizing the findings to the original cohorts?
The population data frame should have the following three columns:
rowId (numeric): A unique identifier for each row (e.g. the person ID).
treatment (integer): Column indicating whether the person is in the target (1) or comparator (0) group.
propensityScore (numeric): Propensity score.
Austin, P.C. (2008) Assessing balance in measured baseline covariates when using many-to-one matching on the propensity-score. Pharmacoepidemiology and Drug Safety, 17: 1218-1225.