The following examples demonstrate how to use plot_me from the plotMElm version >= 0.1.4) R package to visually assess and control the false positive rate issues raised by Esarey and Sumner. These examples build on the examples in their interactionTest R package.
library(plotMElm)
library(interactionTest)
library(ggplot2)
library(gridExtra)
# Load Clark and Golder (2006) replication data
data(legfig)
# Limit to established democracies from the 1990s
dat <- subset(legfig, subset = (nineties == 1 & old == 1))
# Estimate model
lin_formula <- enep1 ~ eneg * logmag + eneg * uppertier +
proximity1 * enpres
lin_mod <- lm(lin_formula, data = dat)
# Marginal effects with 'standard' and FDR 95% confidence intervals
p1 <- plot_me(lin_mod, term1 = 'eneg', term2 = 'logmag') + ggtitle('Standard CI')
p2 <- plot_me(lin_mod, term1 = 'eneg', term2 = 'logmag', ci_type = 'fdr') +
ggtitle('FDR CI')
## t-statistic used: 3.385
grid.arrange(p1, p2, nrow = 1)
It is also possible to supply custom t-statistics with the t_statistic argument. This is useful if you want to use a funciton like findMultiLims from the interactionTest to find t-statistics that can be used to correct confidence intervals for under-confidence. For example:
library(boot)
# Create bootstrap samples of marginal effects of eneg and logmag on enep1
boot_t_dist <- boot(data = dat, statistic = bootFun, R = 1000,
form = lin_formula, fam = 'gaussian',
x.name = 'eneg', z.name = 'logmag')$t
boot_t_x_dist <- boot_t_dist[, 1:10]
# Calculate critical t-statistic that sets familywise error rate to 10%
# for statistical significance of marginal effect of of eneg at any value of logmag
custom_t <- findMultiLims(boot_t_x_dist, type = 'any', err = 0.1)$mi
# Use custom t-statistic
plot_me(lin_mod, term1 = 'eneg', term2 = 'logmag', t_statistic = custom_t) +
ggtitle(sprintf('CI from t-statistic = %s', round(custom_t, digits = 3)))
## Using custom t-statistic (ignoring ci_type argument).