dist: A distance object with three components: d, start, end, typically created by maha_dense or maha_sparse. d[i] gives the distance between the (start[i])th treated and the (end[i]-sum(z))th control.
z: A vector whose ith coordinate is 1 for a treated unit and is 0 for a control. Must have treated subjects (z = 1) before controls (z = 0).
dx: A vector of with length(z) = length(dx) giving the variable used to define the caliper. For instance, dx might be the propensity score.
positive: If positive = TRUE, a treated-minus-control difference in dx that is positive is increased by penalty, but if positive = FALSE a a treated-minus-control difference in dx that is negative is increased by penalty. Zero differences are never penalized.
penalty: The number added to a distance when the desired direction is violated.
Returns
Returns a new distance matrix that is the sum of dmat and the penalties for direction violations.