caliper | R Documentation |
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.
caliper(x, width, exclude = c(), compare = `<=`, values = FALSE)
## S4 method for signature 'InfinitySparseMatrix'
caliper(x, width, exclude = c(), compare = `<=`, values = FALSE)
## S4 method for signature 'matrix'
caliper(x, width, exclude = c(), compare = `<=`, values = FALSE)
## S4 method for signature 'optmatch.dlist'
caliper(x, width, exclude = c(), compare = `<=`, values = FALSE)
x |
A distance specification created with |
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
|
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
|
values |
Should the returned object be made of all zeros
( |
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.
It is important to understand that width
argument is defined on the
scale of these distances. For univariate distances such as propensity scores,
it is common to specify calipers in standard deviations. If a caliper of
this nature is desired, you must either find the standard deviation directly
or use the match_on
function with its caliper
argument.
Since match_on
has access to the underlying univariate scores, for
example for the GLM method, it can determine the caliper width in standard
deviations.
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.
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.
Mark M. Fredrickson and Ben B. Hansen
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.
exactMatch
, match_on
, fullmatch
, pairmatch
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(abs((caliper(ppty.dist, 1) + ppty.dist) -
caliper(ppty.dist, 1, values = TRUE)) < .Machine$Double.eps)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.