lovePlot: Love Plot of Standardized Covariate Mean Differences (along...

Description Usage Arguments Details Value Author(s) Examples

View source: R/lovePlot.R

Description

lovePlot produces a Love plot displaying the standardized covariate mean differences (produced by getStandardizedCovMeanDiffs()). This function can also produce permutation quantiles for different assignment mechanisms - if a standardized covariate mean difference is outside these quantiles, then that is evidence that the assignment mechanism does not hold. This function supports the following assignment mechanisms:

Usage

1
2
3
4
5
6
lovePlot(X.matched, indicator.matched,
  permQuantiles = FALSE,
  assignment = "complete",
  subclass = NULL, threshold = NULL,
  alpha = 0.15, perms = 1000,
  X.full = NULL, indicator.full = NULL)

Arguments

X.matched

A covariate matrix (rows correspond to subjects/units; columns correspond to covariates) for the matched dataset.

indicator.matched

A vector of 1s and 0s (e.g., denoting treatment and control) for the matched dataset.

permQuantiles

Display permutation quantiles? TRUE or FALSE.

assignment

An assignment mechanism that the user wants to visualize. The possible choices are "complete", "blocked", "constrained diffs", "constrained md", "blocked constrained diffs", and "blocked constrained md". See Description for more details on these assignment mechanisms.

subclass

A vector denoting the subclass/block for each subject/unit. This must be specified only if one of the blocked assignment mechanisms are used.

threshold

The threshold used within the constrained assignment mechanisms; thus, this must be specified only if one of the constrained assignment mechanisms are used. This can be a single number or a vector of numbers (e.g., if one wants to use a different threshold for each covariate when testing constrained-differences randomization).

alpha

The alpha-level of the permutation quantiles, where the lower quantile is the alpha/2 quantile and the upper quantile is the 1-alpha/2 quantile. For example, if alpha = 0.15 (the default), then lovePlot() will display the 7.5-percent and 92.5-percent quantiles of the standardized covariate mean differences.

perms

The number of permutations used to compute the permutation quantiles. A larger number requires more computation time but results in a more consistent p-value.

X.full

A covariate matrix (rows correspond to subjects/units; columns correspond to covariates) for the full, unmatched dataset if available.

indicator.full

A vector of 1s and 0s (e.g., denoting treatment and control) for the full, unmatched dataset if available.

Details

The arguments X.full and indicator.full (i.e., the covariate matrix and indicator for the full, unmatched dataset) are only used to correctly define the standardized covariate mean differences. Technically, the covariate mean differences should be standardized by the pooled variance within the full, unmatched dataset, instead of within the matched dataset. If X.full and indicator.full are unspecified, the pooled variance within the matched dataset is used for standardization instead. This distinction rarely leads to large differences in the resulting standardized covariate mean differences, and so researchers should feel comfortable only specifying X.matched and indicator.matched if only a matched dataset is available. Furthermore, if one wants to make a Love plot for a full, unmatched dataset, then they should only specify X.matched and indicator.matched.

Value

A Love plot displaying the standardized covariate mean differences. Can also produce permutation quantiles for different assignment mechanisms.

Author(s)

Zach Branson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
	#This loads the classic Lalonde (1986) dataset,
	#as well as two matched datasets:
	#one from 1:1 propensity score matching,
	#and one from cardinality matching, where
	#the standardized covariate mean differences are all below 0.1.
	data("lalondeMatches")
	
	#obtain the covariates for these datasets
	X.lalonde = subset(lalonde, select = -c(treat))
	X.matched.ps = subset(lalonde.matched.ps, select = -c(treat,subclass))
	X.matched.card = subset(lalonde.matched.card, select = -c(treat,subclass))
	#the treatment indicators are
	indicator.lalonde = lalonde$treat
	indicator.matched.ps = lalonde.matched.ps$treat
	indicator.matched.card = lalonde.matched.card$treat

	#the subclass for the matched datasets are
	subclass.matched.ps = lalonde.matched.ps$subclass
	subclass.matched.card = lalonde.matched.card$subclass

	#The following code will display a classic Love plot
	#(with a dot for each standardized covariate mean difference).
	#Note that, for the full dataset, we only specify X.matched and indicator.matched.
	lovePlot(X.matched = X.lalonde, indicator.matched = indicator.lalonde)
	lovePlot(X.matched = X.matched.ps, indicator.matched = indicator.matched.ps,
	X.full = X.lalonde, indicator.full = indicator.lalonde)
	lovePlot(X.matched = X.matched.card, indicator.matched = indicator.matched.card,
	X.full = X.lalonde, indicator.full = indicator.lalonde)
	
	#The following lines of code create Love plots assessing
	#whether indicator.data follows different assignment mechanisms by
	#plotting the permutation quantiles
	
	#Note that the following examples only use 100 permutations
	#to approximate the randomization distribution.
	#In practice, we recommend setting perms = 1000 or more;
	#in these examples we use perms = 50 to save computation time.
	
	#Assessing complete randomization for the full dataset
	#Here we conclude complete randomization doesn't hold
	#because the standardized covariate mean differences
	#are almost all outside the quantiles.
	lovePlot(X.matched = X.lalonde, indicator.matched = indicator.lalonde,
		permQuantiles = TRUE,
		perms = 50)

	#assessing block (paired) randomization for
	#the 1:1 propensity score matched dataset
	#Many of the standardized covariate mean differences
	#are within the permutation quantiles,
	#but the race covariates (hispan and black)
	#are outside these quantiles.
	lovePlot(X.matched = X.matched.ps, indicator.matched = indicator.matched.ps,
	X.full = X.lalonde, indicator.full = indicator.lalonde,
  		permQuantiles = TRUE,
  		perms = 50,
  		assignment = "blocked", subclass = subclass.matched.ps)

	#assessing block (paired) randomization for
	#the cardinality matched dataset
	#All of the standardized covariate mean differences
	#are within the permutation quantiles
	lovePlot(X.matched = X.matched.card, indicator.matched = indicator.matched.card,
	X.full = X.lalonde, indicator.full = indicator.lalonde,
  		permQuantiles = TRUE,
  		perms = 50,
  		assignment = "blocked", subclass = subclass.matched.card)

	#assessing constrained randomization,
	#where the Mahalanobis distance is constrained.
	#Note that the Mahalanobis distance is approximately
	#a chi^2_K distribution, where K is the number of covariates.
	#In the Lalonde data, K = 8.
	#Thus, the threshold can be chosen as the quantile of the chi^2_8 distribution.
	#This threshold constrains the Mahalanobis distance to be below the 25-percent quantile:
	a = qchisq(p = 0.25, df = 8)
	#Then, the corresponding Love plot and permutation quantiles are:
	lovePlot(X.matched = X.matched.card, indicator.matched = indicator.matched.card,
	X.full = X.lalonde, indicator.full = indicator.lalonde,
  		permQuantiles = TRUE,
  		perms = 50,
  		assignment = "constrained md",
  		threshold = a)

randChecks documentation built on March 19, 2021, 1:06 a.m.