plot_microsynth {microsynth} | R Documentation |
Plotting for microsynth objects.
Description
Using a microsynth
object as an input, this function gives time
series plots of selected outcomes.
Usage
plot_microsynth(
ms,
plot.var = NULL,
start.pre = NULL,
end.pre = NULL,
end.post = NULL,
file = NULL,
sep = TRUE,
plot.first = NULL,
legend.spot = "bottomleft",
height = NULL,
width = NULL,
at = NULL,
labels = NULL,
all = "cases",
main.tc = NULL,
main.diff = NULL,
xlab.tc = NULL,
xlab.diff = NULL,
ylab.tc = NULL,
ylab.diff = NULL
)
Arguments
ms |
A microsynth object |
plot.var |
A vector of variable names giving the outcome variables that
are shown in plots. If |
start.pre |
An integer indicating the time point that corresponds to the
earliest time period that will be plotted.
When |
end.pre |
An integer that gives the final time point of the
pre-intervention period. That is, |
end.post |
An integer that gives final time point that will be plotted.
When |
file |
A character string giving the name of file that will be
created in the home directory containing plots.
The name should have a |
sep |
If |
plot.first |
The number of permutation groups to plot. |
legend.spot |
The location of the legend in the plots. |
height |
The height of the graphics region (in inches) when a pdf is created. |
width |
The width of the graphics region (in inches) when a pdf is created. |
at |
A vector that gives the location of user-specified x-axis labels.
|
labels |
A vector of the same length as |
all |
A scalar character string giving the unit name for cases.
If |
main.tc |
A scalar (or a vector of the same length as |
main.diff |
A scalar (or a vector of the same length as |
xlab.tc |
A scalar (or a vector of the same length as |
xlab.diff |
A scalar (or a vector of the same length as |
ylab.tc |
A scalar (or a vector of the same length as |
ylab.diff |
A scalar (or a vector of the same length as |
Details
Plots are given over both pre- and intervention time periods and shown in terms of raw outcome values or treatment/control differences. Time series of permutation groups may be overlaid to help illustrate statistical uncertainty.
Only required input is a parameter ms
which is a microsynth object.
Value
No return value, called for side effects (i.e., to produce plots of outcome values and treatment/control differences, with the option to write to file).
Examples
# Declare time-variant (outcome) and time-invariant variables for matching
cov.var <- c('TotalPop', 'BLACK', 'HISPANIC', 'Males_1521',
'HOUSEHOLDS', 'FAMILYHOUS', 'FEMALE_HOU', 'RENTER_HOU', 'VACANT_HOU')
match.out <- c('i_felony', 'i_misdemea', 'i_drugs', 'any_crime')
set.seed(99199) # for reproducibility
# Perform matching and estimation, without permutations or jackknife
# runtime: <1 min
sea1 <- microsynth(seattledmi,
idvar='ID', timevar='time', intvar='Intervention',
start.pre=1, end.pre=12, end.post=16,
match.out=match.out, match.covar=cov.var,
result.var=match.out, omnibus.var=match.out,
test='lower',
n.cores = min(parallel::detectCores(), 2))
# Plot with default settings in the GUI.
plot_microsynth(sea1)
# Make plots, display, and save to a single file (plots.pdf).
plot_microsynth(sea1, file = file.path(tempdir(), 'plots.pdf'), sep = FALSE)
# Make plots for only one outcome, display, and save to a single file.
plot_microsynth(sea1, plot.var = 'any_crime',
file = file.path(tempdir(), 'plots.pdf'), sep = FALSE)