covbalance {approxmatch}R Documentation

Check covariate balance of a design.

Description

For a given match, this function evaluates the balance of variables before and after matching. Balance is evaluated using standardized differences.

Usage

covbalance(.data, grouplabel, matches, vars, details)

Arguments

.data

A data frame or matrix containing the informations on the vars for which balance will be checked.

grouplabel

Argument describing the group structure. See the description in the documentation of kwaymatching function of this package.

matches

A character matrix describing the strata structure of the design. Standard use is the output of tripletmatching or kwaytmatching function.

Each row of the matrix corresponds to a strata and each entry corresponds to rowname of .data.

vars

A character vector of the names of the variables for which balance should be checked.

details

Optional argument. This argument can be used to get other details on the vars before and after matching. A character vector of names of functions which summarizes a vector, e.g. mean.

Details

Standardized difference of the covariates between two groups is computed as difference of the means of the variable over the squared root of the average variance of the variable in the groups.

For better understanding of the matching, details can be used. This argument can be used to get summaries of the variables before and after matching. For example, details = c(mean = 'mean', median = 'function(x) quantile(x, probs=.5)') given the mean and median of the variables. Only functions that give a single number summary can be used!

Currently, this function cannot be immediately used for a design with different strata sizes. One way to get around would be to fill in the smaller stratum with false units and making all the strata of equal size.

Value

A list consisting of the following elements.

std_diff

Standardized differences of the specified variables before and after matching for every pair of groups.

details

Only if details is provided. A list of summaries of the variables before and after matching using the functions specified by details.

Note

See kwaymatching for usage.

Author(s)

Bikram Karmakar

See Also

tripletmatching, kwaymatching

Examples

	
	data(Dodgeram)
	
	## An example strata structure
	matches = as.matrix(sample(rownames(Dodgeram), 500), ncol = 5)
	
	vars = c("AGE", "SEX.2", "IMPACT3.3", "DR_DRINK")
	details = c('std_diff', 'mean', 'function(x) diff(range(x))', 
	                         'function(x) quantile(x, probs = .9)')
	names(details) <- c('std_diff', 'mean', 'range', '90perc')
	
	covbalance(.data=Dodgeram, grouplabel=c("NOSAB", "optSAB", "WITHSABS"), 
	                 matches = matches, vars = vars, details)
					 

[Package approxmatch version 2.0 Index]