plot.clarify_est {clarify}  R Documentation 
Plotting and inference for clarify_est
objects
Description
summary()
tabulates the estimates and confidence intervals and (optionally) pvalues from a clarify_est
object. confint()
computes confidence intervals. plot()
plots the "posterior" distribution of estimates.
Usage
## S3 method for class 'clarify_est'
plot(
x,
parm,
ci = TRUE,
level = 0.95,
method = "quantile",
reference = FALSE,
ncol = 3,
...
)
## S3 method for class 'clarify_est'
summary(object, parm, level = 0.95, method = "quantile", null = NA, ...)
## S3 method for class 'clarify_est'
confint(object, parm, level = 0.95, method = "quantile", ...)
Arguments
parm 
a vector of the names or indices of the estimates to plot. If unspecified, all estimates will be displayed. 
ci 

level 
the confidence level desired. Default is .95 for 95% confidence intervals. 
method 
the method used to compute pvalues and confidence intervals. Can be 
reference 

ncol 
the number of columns used when wrapping multiple plots; default is 3. 
... 
for 
object , x 
a 
null 
the values of the parameters under the null hypothesis for the pvalue calculations. Should have length equal to the number of quantities estimated, or one, in which case it will be recycled, or it can be a named vector with just the names of quantities for which null values are to be set. Set values to 
Details
summary()
uses the estimates computed from the original model as its estimates and uses the simulated parameters for inference only, in line with the recommendations of Rainey (2023).
When method = "wald"
, the standard deviation of the simulation estimates is used as the standard error, which is used in the zstatistics and the confidence intervals. The pvalues and confidence intervals are valid only when the sampling distribution of the resulting statistic is normal (which can be assessed using plot()
). When method = "quantile"
, the confidence interval is calculated using the quantiles of the simulation estimates corresponding to level
, and the pvalue is calculated as twice the proportion of simulation estimates less than or greater than null
, whichever is smaller; this is equivalent to inverting the confidence interval but is only truly valid when the true sampling distribution is only a location shift from the sampling distribution under the null hypothesis and should therefore be interpreted with caution. Using "method = "quantile"
(the default) is recommended because the confidence intervals will be valid even if the sampling distribution is not Normally distributed. The precision of the pvalues and confidence intervals depends on the number of simulations requested (the value of n
supplied to sim()
).
The plots are produced using ggplot2::geom_density()
and can be customized with ggplot2 functions. When reference = TRUE
, a reference Normal distribution is produced using the empirical mean and standard deviation of the simulated values. A blue references line is plotted at the median of the simulated values. For Waldbased inference to be valid, the reference distribution should overlap with the empirical distribution, in which case the quantilebased and Waldbased intervals should be similar. For quantilebased inference to be valid, the median of the estimates should overlap with the estimated value; this is a necessary but not sufficient condition, though.
Value
For summary()
, a summary.clarify_est
object, which is a matrix containing the coefficient estimates, standard errors, test statistics, pvalues, and confidence intervals. Not all columns will be present depending on the arguments supplied to summary()
.
For confint()
, a matrix containing the confidence intervals for the requested quantities.
For plot()
, a ggplot
object.
References
Rainey, C. (2023). A careful consideration of CLARIFY: Simulationinduced bias in point estimates of quantities of interest. Political Science Research and Methods, 1–10. doi:10.1017/psrm.2023.8
See Also

sim_apply()
for applying a function to each set of simulated coefficients
Examples
data("lalonde", package = "MatchIt")
fit < glm(I(re78 > 0) ~ treat + age + race + nodegree + re74,
data = lalonde)
s < sim(fit, n = 100)
# Compute average marginal means for `treat`
est < sim_ame(s, var = "treat", verbose = FALSE)
coef(est)
# Compute average marginal effects on risk difference
# (RD) and risk ratio (RR) scale
est < transform(est,
RD = `E[Y(1)]`  `E[Y(0)]`,
RR = `E[Y(1)]` / `E[Y(0)]`)
# Compute confidence intervals and pvalues,
# using given null values for computing pvalues
summary(est, null = c(`RD` = 0, `RR` = 1))
# Same tests using normal approximation and alternate
# syntax for `null`
summary(est, null = c(NA, NA, 0, 1),
normal = TRUE)
# Plot the RD and RR with a reference distribution
plot(est, parm = c("RD", "RR"), reference = TRUE,
ci = FALSE)
# Plot the RD and RR with quantile confidence bounds
plot(est, parm = c("RD", "RR"), ci = TRUE)