The mdist
method provides three ways to construct a mdist
matrix (or list of mdist matrices): function, glm, and formula. The mdist.function
method takes a function of two arguments. When
called, this function will recieve the treatment observations as the first argument
and the control observations as the second argument. As an example, the following
computes the raw differences between values of t1
for treatment
units (here, nuclear plants with pr==1
) and controls (here,
plants with pr==0
), returning the result as
a distance matrix:
sdiffs <- function(treatments, controls) {
abs(outer(treatments$t1, controls$t1, `-`))
}
The mdist.function
method does similar things as the
earlier optmatch function makedist
, although the
interface is a bit different.
The mdist.formula
computes the squared Mahalanobis distance between observations
using the supplied formula. In addition to the distance formula (the first argument),
this method can also take a structure formula to denote strata in the observations, e.g.
~ s
would group the observations by the factor s
.
The mdist.glm
takes an argument of class glm
as the first argument.
It computes the deviations between observations using the mad
function.
See pscore.dist
for more information.