This function plots the density probability distribution of an F statistic, with a vertical cutline at the observed F value specified. A p-value and the observed F value are plotted. Although largely customizable, only three arguments are required (the observed F and the degrees of freedom).
plotftest(
f,
dfnum = f$fstatistic[2],
dfdenom = f$fstatistic[3],
blank = FALSE,
xmax = "auto",
title = "F Test",
xlabel = "F",
ylabel = "Density of probability\nunder the null hypothesis",
fontfamily = "serif",
colorleft = "aliceblue",
colorright = "firebrick3",
colorleftcurve = "black",
colorrightcurve = "black",
colorcut = "black",
colorplabel = colorright,
theme = "default",
signifdigitsf = 3,
curvelinesize = 0.4,
cutlinesize = curvelinesize
)
A plot with the density of probability of F under the null hypothesis, annotated with the observed test statistic and the p-value.
A numeric value indicating the observed F statistic. Alternatively, you can pass an object of class lm
created by the function lm()
.
A numeric value indicating the degrees of freedom of the numerator. This argument is optional if you are using an lm
object as the f
argument.
A numeric value indicating the degrees of freedom of the denominator. This argument is optional if you are using an lm
object as the f
argument.
A logical that indicates whether to hide (blank = TRUE
) the test statistic value, p value and cutline. The corresponding colors are actually only made transparent when blank = TRUE
, so that the output is scaled exactly the same (this is useful and especially intended for step-by-step explanations).
A numeric including the maximum for the x-axis. Defaults to "auto"
, which scales the plot automatically (optional).
A character or expression indicating a custom title for the plot (optional).
A character or expression indicating a custom title for the x axis (optional).
A character or expression indicating a custom title for the y axis (optional).
A character indicating the font family of all the titles and labels (e.g. "serif"
(default), "sans"
, "Helvetica"
, "Palatino"
, etc.) (optional).
A character indicating the color for the "left" area under the curve (optional).
A character indicating the color for the "right" area under the curve (optional).
A character indicating the color for the "left" part of the curve (optional).
A character indicating the color for the "right" part of the curve (optional). By default, for color consistency, this color is also passed to the label, but this can be changed by providing an argument for the colorlabel
parameter.
A character indicating the color for the cut line at the observed test statistic (optional).
A character indicating the color for the label of the p-value (optional). By default, for color consistency, this color is the same as color of colorright
.
A character indicating one of the predefined color themes. The themes are "default"
(light blue and red), "blackandwhite"
, "whiteandred"
, "blueandred"
, "greenandred"
and "goldandblue"
) (optional). Supersedes colorleft
and colorright
if another argument than "default"
is provided.
A numeric indicating the number of desired significant figures reported for the F (optional).
A numeric indicating the size of the curve line (optional).
A numeric indicating the size of the cut line (optional). By default, the size of the curve line is used.
Nils Myszkowski <nmyszkowski@pace.edu>
#Making an F plot with an F of 3, and degrees of freedom of 1 and 5.
plotftest(f = 4, dfnum = 3, dfdenom = 5)
#Note that the same can be obtained even quicker with:
plotftest(4,3,5)
#The same plot without the f or p value
plotftest(4,3,5, blank = TRUE)
#Passing an "lm" object
x <- rnorm(10) ; y <- x + rnorm(10)
fit <- lm(y ~ x)
plotftest(fit)
plotftest(summary(fit)) # also works
Run the code above in your browser using DataLab