Learn R Programming

optmatch (version 0.9-3)

caliper: Prepare matching distances suitable for matching within calipers.

Description

Encodes calipers, or maximum allowable distances within which to match. The result of a call to caliper is itself a distance specification between treated and control units that can be used with pairmatch() or fullmatch(). Calipers can also be combined with other distance specifications for richer matching problems.

Usage

## S3 method for class 'InfinitySparseMatrix':
caliper(x, width = 1,
    exclude = c(), compare = `<=`, values="FALSE)

## S3 method for class 'matrix': caliper(x, width = 1, exclude = c(), compare = `<=`, values="FALSE)

## S3 method for class 'optmatch.dlist': caliper(x, width = 1, exclude = c(), compare = `

Arguments

x
A distance specification created with match_on or similar.
width
The width of the caliper: how wide of a margin to allow in matches. Be careful in setting the width. Vector valued arguments will be recycled for each of the finite entries in x (and no order is guaranteed for x for some
exclude
(Optional) A character vector of observations (corresponding to row and column names) to exclude from the caliper.
compare
A function that decides that whether two observations are with the caliper. The default is `<=`< code="">. `<`< code=""> is a common alternative.
values
Should the returned object be made of all zeros (values = FALSE, the default) or should the object include the values of the original object (values = TRUE)?

Value

  • A matrix like object that is suitable to be given as distance argument to fullmatch or pairmatch. The caliper will be only zeros and Inf values, indicating a possible match or no possible match, respectively.

    You can combine the results of caliper with other distances using the `+` operator. See the examples for usage.

Details

caliper is a generic function with methods for any of the allowed distance specifications: user created matrices, the results of match_on, the results of exactMatch, or combinations (using `+`) of these objects.

width provides the size of the caliper, the allowable distance for matching. If the distance between a treated and control pair is less than or equal to this distance, it is allowed kept; otherwise, the pair is discarded from future matching. The default comparison of ``equal or less than can'' be changed to any other comparison function using the comparison argument.

If you wish to exclude specific units from the caliper requirements, pass the names of these units in the exclude argument. These units will be allowed to match any other unit.

References

P.~R. Rosenbaum and D.~B. Rubin (1985), Constructing a control group using multivariate matched sampling methods that incorporate the propensity score, The American Statistician, 39 33--38.

See Also

exactMatch, match_on, fullmatch, pairmatch

Examples

Run this code
data(nuclearplants)


### Caliper of 100 MWe on plant capacity
caliper(match_on(pr~cap, data=nuclearplants, method="euclidean"), width=100)

### Caliper of 1/2 a pooled SD of plant capacity
caliper(match_on(pr~cap, data=nuclearplants), width=.5)

### Caliper  of .2 pooled SDs in the propensity score
ppty <- glm(pr ~ . - (pr + cost), family = binomial(), data = nuclearplants)
ppty.dist <- match_on(ppty)

pptycaliper <- caliper(ppty.dist, width = .2)

### caliper on the Mahalanobis distance
caliper(match_on(pr ~ t1 + t2, data = nuclearplants), width = 3)

### Combining a Mahalanobis distance matching with a caliper
### of 1 pooled SD in the propensity score:
mhd.pptyc <- caliper(ppty.dist, width = 1) +
          match_on(pr ~ t1 + t2, data = nuclearplants)
pairmatch(mhd.pptyc, data = nuclearplants)

### Excluding observations from caliper requirements:
caliper(match_on(pr ~ t1 + t2, data = nuclearplants), width = 3, exclude = c("A", "f"))

### Returning values directly (equal up to the the attributes)
all.equal(caliper(ppty.dist) + ppty.dist,
          caliper(ppty.dist, values = TRUE),
          check.attributes = FALSE)

Run the code above in your browser using DataLab