Plots the covariate balance before and after matching for multiple data sources.
plotCovariateBalances(
balances,
labels,
threshold = 0,
beforeLabel = "Before matching",
afterLabel = "After matching",
fileName = NULL
)
A list of covariate balance objects as created using the
computeCovariateBalance()
function in the CohortMethod
package. Each
balance object is expected to be a data frame with at least these two columns:
beforeMatchingStdDiff
and afterMatchingStdDiff
.
A vector containing the labels for the various sources.
Show a threshold value for the standardized difference.
Label for before matching / stratification / trimming.
Label for after matching / stratification / trimming.
Name of the file where the plot should be saved, for example 'plot.png'. See the function ggplot2::ggsave for supported file formats.
A Ggplot object. Use the ggplot2::ggsave.
Creates a plot showing the covariate balance before and after matching. Balance distributions are displayed as box plots combined with scatterplots.
# Some example data:
balance1 <- data.frame(
beforeMatchingStdDiff = rnorm(1000, 0.1, 0.1),
afterMatchingStdDiff = rnorm(1000, 0, 0.01)
)
balance2 <- data.frame(
beforeMatchingStdDiff = rnorm(1000, 0.2, 0.1),
afterMatchingStdDiff = rnorm(1000, 0, 0.05)
)
balance3 <- data.frame(
beforeMatchingStdDiff = rnorm(1000, 0, 0.1),
afterMatchingStdDiff = rnorm(1000, 0, 0.03)
)
plotCovariateBalances(
balances = list(balance1, balance2, balance3),
labels = c("Site A", "Site B", "Site C")
)