Plots the output of viztest objects with optional reference lines
# S3 method for viztest
plot(
x,
...,
add_test_level = TRUE,
ref_lines = "none",
viz_diff_thresh = 0.02,
make_plot = TRUE,
level = c("ce", "max", "min", "median"),
trans = I,
est_point_args = list(color = "black", size = 2),
opt_ci_args = list(),
test_ci_args = list(),
ref_line_args = list(color = "gray75", linetype = 3),
scale_linewidth_args = list(values = c(3.5, 0.5)),
scale_color_args = list(values = c("gray75", "black")),
overall_theme = theme_bw,
theme_arg = list(legend.position = "top", plot.caption = element_textbox_simple(width =
unit(1, "npc"), halign = 0, margin = margin(1, 0, 0, 0, "lines"))),
remove_caption = FALSE
)By default, a ggplot is returned. If make_plot = FALSE, the data for the plot are returned, but the plot is not constructed. If the data are returned, the following variables are in the dataset:
vbl - The name of the parameter.
est - The parameter estimate
se - The standard error of the estimate
lwr, upr - The inferential confidence bounds being used
lwr_add, upr_add - The confidence intervals that come from add_level.
label - Factor giving the parameter names
stim_start, stim_end - y-axis bounds of the reference line
bound_start, bound_end - x-axis values for reference lines
ambiguous - Logical vector indicating whether the comparison is considered "ambiguous".
Object to be plotted, should be of class viztest
Other arguments passed down. Currently not implemented.
Add the (1-test level) confidence interval to the plot. For this to work, you must have specified add_test_level in the call to viztest() so that the appropriate confidence intervals can be calculated.
Reference lines to be plotted - one of "all", "ambiguous", "none". This could also be a vector of stimulus names to plot - they should be the same as the names of the estimates in x$est. See details for explanation.
Threshold for identifying visual difficulty, see details.
Logical indicating whether the plot should be constructed or the data returned.
Level at which to plot the estimates. Accepts both numeric entries or one of "ce", "max", "min", "median" - defaults to "ce", the cognitively easiest level.
A function to transform the estimates and their confidence intervals like plogis.
A list of arguments to be passed to geom_point() that plots the point estimates.
A list of arguments to be passed to geom_linerange() to plot the optimal visual testing intervals.
A list of arguments to be passed to geom_linerange() to plot the (1-test level) confidence intervals.
A list of arguments to be passed to geom_segment() to plot the reference lines.
A list of arguments to be passed to scale_linewidth_manual() to change the thickness of the confidence intervals.
A list of arguments to be passed to scale_color_manual() to change the default color of the different confidence intervals when add_test_level=TRUE.
A theme function that will be passed to the ggplot call before theme(). Default is theme_bw.
A list of arguments to be passed to theme() to modify the theme of the plot.
Logical indicating whether caption should be removed. By default, it is printed to alert the user.
The ref_lines argument identifies what reference lines will be plotted in the figure. For any particular stimulus, the reference lines run along the upper bound of the stimulus from the stimulus location to the most distant stimulus with overlapping confidence intervals.
When ref_lines = "all", all lines are plotted, though in displays with many stimuli, this can make for a messy graph. When "ref_lines = ambiguous" is specified, then only the ones that help discriminate in cases where the result might be visually difficult to discern are plotted.
A comparison is determined to be visually difficult if the upper bound of the stimulus in question is within viz_diff_thresh times the difference between the smallest lower bound and the largest upper bound. If ref_lines = "non", then none of the reference lines are plotted.
Alternatively, you can specify the names of stimuli whose reference lines will be plotted. These should be the same as the names in the data. The viztest() function returns an object est, which contains the data that are used as input to this function. The variable vbl in
The est data frame contains the stimulus names.
data(mtcars)
mod2 <- lm(mpg ~ as.factor(cyl) + vs + am + as.factor(gear), data = mtcars)
v <- viztest(mod2)
plot(v, ref_lines="ambiguous") + ggplot2::theme_classic()
Run the code above in your browser using DataLab