# plotftest: Illustrate an F Test graphically. In nhstplot: Plot Null Hypothesis Significance Tests

 plotftest R Documentation

## Illustrate an F Test graphically.

### Description

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).

### Usage

``````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
)
``````

### Arguments

 `f` A numeric value indicating the observed F statistic. Alternatively, you can pass an object of class `lm` created by the function `lm()`. `dfnum` 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. `dfdenom` 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. `blank` 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). `xmax` A numeric including the maximum for the x-axis. Defaults to `"auto"`, which scales the plot automatically (optional). `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. `"serif"` (default), `"sans"`, `"Helvetica"`, `"Palatino"`, etc.) (optional). `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 `colorlabel` parameter. `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 `colorright`. `theme` 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. `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.

### Value

A plot with the density of probability of F under the null hypothesis, annotated with the observed test statistic and the p-value.

### Author(s)

Nils Myszkowski <nmyszkowski@pace.edu>

### Examples

``````#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
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)

``````

nhstplot documentation built on April 11, 2023, 5:54 p.m.