plotftest | R Documentation |
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,
p_value_position = "auto"
)
f |
A numeric value indicating the observed F statistic. Alternatively, you can pass an object of class |
dfnum |
A numeric value indicating the degrees of freedom of the numerator. This argument is optional if you are using an |
dfdenom |
A numeric value indicating the degrees of freedom of the denominator. This argument is optional if you are using an |
blank |
A logical that indicates whether to hide ( |
xmax |
A numeric including the maximum for the x-axis. Defaults to |
title |
A character or expression indicating a custom title for the plot (optional). |
xlabel |
A character or expression indicating a custom title for the x axis (optional). |
ylabel |
A character or expression indicating a custom title for the y axis (optional). |
fontfamily |
A character indicating the font family of all the titles and labels (e.g. |
colorleft |
A character indicating the color for the "left" area under the curve (optional). |
colorright |
A character indicating the color for the "right" area under the curve (optional). |
colorleftcurve |
A character indicating the color for the "left" part of the curve (optional). |
colorrightcurve |
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 |
colorcut |
A character indicating the color for the cut line at the observed test statistic (optional). |
colorplabel |
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 |
theme |
A character indicating one of the predefined color themes. The themes are |
signifdigitsf |
A numeric indicating the number of desired significant figures reported for the F (optional). |
curvelinesize |
A numeric indicating the size of the curve line (optional). |
cutlinesize |
A numeric indicating the size of the cut line (optional). By default, the size of the curve line is used. |
p_value_position |
A numeric vector of length 2, indicating the x and y coordinates of the p-value label. By default, the position is set to |
A plot with the density of probability of F under the null hypothesis, annotated with the observed test statistic and the p-value.
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)
#The same plot without the f or p value
plotftest(4,3,5, blank = TRUE)
#Passing an "lm" object
set.seed(1)
x <- rnorm(10) ; y <- x + rnorm(10)
fit <- lm(y ~ x)
plotftest(fit)
plotftest(summary(fit)) # also works
#Passing an "anova" F-change test
set.seed(1)
x <- rnorm(10) ; y <- x + rnorm(10)
fit1 <- lm(y ~ x)
fit2 <- lm(y ~ poly(x, 2))
comp <- anova(fit1, fit2)
plotftest(comp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.