dist_mahal {triplesmatch}R Documentation

Make Mahalanobis distance matrix

Description

Make Mahalanobis distance matrix

Usage

dist_mahal(X, z, st, rank_based = FALSE)

Arguments

X

Covariate matrix to be used in calculating distances

z

Vector of treatment assignments

st

Vector of stratum assignments, should be denoted by consecutive integers starting from 1

rank_based

Whether to use rank based Mahalanobis distance or not

Value

List of squared Mahalanobis distance matrices between each pair of treated-control units in a stratum. There is one entry in the list for each stratum. This entry is a distance matrix with a row for each treated unit and a column for each control unit in the stratum.

Examples

# Generate some data
set.seed(1)
n <- 40
x <- rnorm(n, 0, 1)
nt <- floor(n * 0.4)
nc <- n - nt
z <- c(rep(1, nt), rep(0, nc))
# Create some strata
ps <- glm(z ~ x, family = binomial)$fitted.values
ps_st <- cut(ps, c(0, quantile(ps, 1/3 * 1:2), 1), labels = 1:3)
# Create a list of distance matrices, one for each stratum
dist <- dist_mahal(data.frame(x = x), z, ps_st)


[Package triplesmatch version 1.0.0 Index]