pwpp | R Documentation |
Constructs a plot of P values associated with pairwise comparisons of estimated marginal means.
pwpp(emm, method = "pairwise", by, sort = TRUE, values = TRUE,
rows = ".", xlab, ylab, xsub = "", plim = numeric(0), add.space = 0,
aes, ...)
emm |
An |
method |
Character or list. Passed to |
by |
Character vector of variable(s) in the grid to condition on. These will
create different panels, one for each level or level-combination.
Grid factors not in |
sort |
Logical value. If |
values |
Logical value. If |
rows |
Character vector of which |
xlab |
Character label to use in place of the default for the P-value axis. |
ylab |
Character label to use in place of the default for the primary-factor axis. |
xsub |
Character label used as caption at the lower right of the plot. |
plim |
numeric vector of value(s) between 0 and 1. These are included
among the observed p values so that the range of tick marks includes at
least the range of |
add.space |
Numeric value to adjust amount of space used for value labels. Positioning
of value labels is tricky, and depends on how many panels and the
physical size of the plotting region. This parameter allows the user to
adjust the position. Changing it by one unit should shift the position by
about one character width (right if positive, left if negative).
Note that this interacts with |
aes |
optional named list of lists. Entries considered are |
... |
Additional arguments passed to |
Factor levels (or combinations thereof) are plotted on the vertical scale, and P values are plotted on the horizontal scale. Each P value is plotted twice – at vertical positions corresponding to the levels being compared – and connected by a line segment. Thus, it is easy to visualize which P values are small and large, and which levels are compared. In addition, factor levels are color-coded, and the points and half-line segments appear in the color of the other level. The P-value scale is nonlinear, so as to stretch-out smaller P values and compress larger ones. P values smaller than 0.0004 are altered and plotted in a way that makes them more distinguishable from one another.
If xlab
, ylab
, and xsub
are not provided, reasonable labels
are created. xsub
is used to note special features; e.g., equivalence
thresholds or one-sided tests.
If emm
is the result of a Bayesian analysis, the plot is based on
summaries with frequentist = TRUE
.
The ggplot2 and scales packages must be installed in order
for pwpp
to work.
Additional plot aesthetics are available by adding them to the returned object; see the examples
A numerical display of essentially the same results is available
from pwpm
pigs.lm <- lm(log(conc) ~ source * factor(percent), data = pigs)
emm = emmeans(pigs.lm, ~ percent | source)
pwpp(emm)
pwpp(emm, method = "trt.vs.ctrl1", type = "response", side = ">")
# custom aesthetics:
my.aes <- list(point = list(shape = "square"),
segment = list(linetype = "dashed", color = "red"),
label = list(family = "serif", fontface = "italic"))
my.pal <- c("darkgreen", "blue", "magenta", "orange")
pwpp(emm, aes = my.aes) + ggplot2::scale_color_manual(values = my.pal)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.