| rp.t_test | R Documentation |
The sample(s) of data are plotted along with a graphical display which indicates the uncertainty in the location of the true means and in their difference. This is done by plotting a shaded representation of a normal distribution in 'violin plot' style. This can also be compared with a reference mean, representing the null hypothesis in a t-test.
rp.t_test(x, y = NULL, panel = TRUE, mu = NULL, data.display = 'density',
display = c(distribution = FALSE, detail = FALSE),
ruler.position = 'none', candidate, print = FALSE,
cols, xlab, ylab, vlab, hscale = 1, vscale = hscale, ...)
x |
a vector of data on a continuous scale or a formula with a response variable and a single predictor variable which is a factor with two levels. |
y |
an optional second vector of data on a continuous scale, to allow two-sample or paired-sample analyses. Alternatively, |
panel |
a logical value which determines whether the function runs in interactive mode. |
mu |
a numerical value representing a reference mean of interest, for
example a null hypothesis in a formal test. This is the same parameter
as |
data.display |
a character value which controls the form of the data and
display. Valid options are |
display |
a named logical vector which controls the form of uncertainty to
be displayed. The named elements are |
ruler.position |
a character value which determines whether a standard error scale is
added to the plot and its location, |
candidate |
a numeric value controlling where the standard error ruler is located when |
print |
a logical value which controls whether the results are printed on the console. |
cols |
the colours to be used in constructing the display. The default values are set by the |
xlab, ylab, vlab |
character values providing labels for the group(s) to be analysed and for the measurement scale ( |
hscale, vscale |
scaling parameters for the size of the plot when |
... |
further named argument, which will be passed on to the |
The graphics are created through the ggplot2 package so this needs to be installed.
The function aims to follow the general pattern of the t.test function and the arguments of t.test described in its help file can also be passed to rp.t_test.
A ggplot object is returned. This allows further alterations and annotations to be made.
Bowman, A.W. (2019). Graphics for uncertainty (with discussion). Journal of the Royal Statistics Society, Series A, Statistics & Society, 182, 403-418.
## Not run:
x <- rnorm(50)
rp.t_test(x)
rp.t_test(x, mu = 0)
rp.t_test(x, uncertainty = 'sample mean')
rp.t_test(x, uncertainty = 'reference')
g <- factor(rep(1:2, each = 25))
plt <- rp.t_test(x ~ g)
plt + ggplot2::ggtitle("Two-sample inference")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.