distMat: Matrix of distances between observations

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Compute a matrix of distances between n observations using the distance measure in method.

Usage

1
distMat(X, Ahalf = diag(NCOL(X)), method = "euclidean", d = NULL, p = 2)

Arguments

X

Design matrix of covariates with dimension n by p, or else a vector of length n if there is a single covariate.

Ahalf

Weight matrix with dimension p by p so that the distances are computed between Ahalf %*% X[i, ].

method

the distance measure to be used. This must be one of "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski". Any unambiguous substring can be given.

d

Vector of treatment indicators with length n. If supplied, return the n1 by n0 submatrix corresponding to distances between treated and untreated observations. Otherwise return the full n by n matrix

p

The power of the Minkowski distance.

Value

Matrix of distances with dimension n by n or else n1 by n0

Examples

1
2
## 4 units, unit 1 and 3 are treated.
distMat(X=c(1, 2, 3, 4), d=c(TRUE, FALSE, TRUE, FALSE))

kolesarm/ATEHonest documentation built on Nov. 14, 2020, 4:50 a.m.