# \donttest{
data(LL)
set.seed(123)
sp <- spacegraph("treated", LL, drop="re78", M=5,
R=list(cem=5,psm=5, mdm=5))
plot(sp)
## ABOUT THE PLOTTING TOOL:
## The circled solution is the current selection.
## Solutions that are strictly better are also circled.
## The gui provides the exact call to re-run the selected matching solution.
## The call can also be edited, re-run by clicking the button, and
## automatically added to the existing spacegraph.
## CEM solutions can also be adjusted variable by variable and re-run.
## Some plotting parameters can be changed
plot(sp, main="Comparison of Matching Methods",
ylab="L1", xlim=c(300,50), ylim=c(0,.7))
## You can specify whether the x-axis shows treated units,
## control units, or all units using the argument N, which
## can take the values "treated", "control", or "all".
## Default is "treated".
plot(sp, N="all")
## You can specify how the x-axis is scaled. Setting scale.var=T
## gives you the scaling as 1/sqrt(n). Setting scale.var=F gives
## scales it linearly. Default is scale.var=TRUE.
plot(sp, scale.var=FALSE)
## You can also specify which measure of balance to use
## by specifying the argument "balance.metric" as
## "L1", "mdiff" (Avg. standardized difference in means),
## or "mdisc" (Average Malanobis Discrepancy). Default is "L1".
plot(sp, balance.metric="mdiff")
plot(sp, balance.metric="mdisc")
## Matching solutions from other methods can be included in
## a spacegraph by using the argument "other.matches".
## First, Run a matching method. Here, propensity scores from MatchIt.
library(MatchIt)
m.out <- matchit(formula=treated ~ education+age, data=LL, method = "nearest")
## Put the required information into a list of data frames.
## Note, there are many ways to do this.
mymatches <- list(data.frame(names(m.out$w)))
names(mymatches[[1]])[1] <- "id"
mymatches[[1]]$weight <- m.out$w
mymatches[[1]]$method <- "matchit psm"
sp <- spacegraph("treated", LL, drop="re78", M=5,
R=list(cem=5,psm=5, mdm=5), other.matches=mymatches)
plot(sp)
# }
Run the code above in your browser using DataLab