test.levene | R Documentation |
This function performs Levene's test for homogeneity of variance across two or more independent groups including a plot showing violins and boxplots representing the distribution of the outcome variable for each group.
test.levene(formula, data, method = c("median", "mean"), conf.level = 0.95,
hypo = TRUE, descript = TRUE, digits = 2, p.digits = 3, as.na = NULL,
plot = FALSE, violin = TRUE, box = TRUE, jitter = FALSE,
violin.alpha = 0.3, violin.trim = FALSE, box.alpha = 0.2,
box.width = 0.2, jitter.size = 1.25, jitter.width = 0.05,
jitter.height = 0, jitter.alpha = 0.2, gray = FALSE, start = 0.9,
end = 0.4, color = NULL, xlab = NULL, ylab = NULL, ylim = NULL,
ybreaks = ggplot2::waiver(), title = "", subtitle = "",
filename = NULL, width = NA, height = NA,
units = c("in", "cm", "mm", "px"), dpi = 600, write = NULL,
append = TRUE, check = TRUE, output = TRUE)
formula |
a formula of the form |
data |
a matrix or data frame containing the variables in the
formula |
method |
a character string specifying the method to compute the
center of each group, i.e. |
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
hypo |
logical: if |
descript |
logical: if |
digits |
an integer value indicating the number of decimal places to be used for displaying results. |
p.digits |
an integer value indicating the number of decimal places to be used for displaying the p-value. |
as.na |
a numeric vector indicating user-defined missing values,
i.e. these values are converted to |
plot |
logical: if |
violin |
logical: if |
box |
logical: if |
jitter |
logical: if |
violin.alpha |
a numeric value between 0 and 1 for specifying the
|
violin.trim |
logical: if |
box.alpha |
a numeric value between 0 and 1 for specifying the
|
box.width |
a numeric value indicating the width of the boxplots. |
jitter.size |
a numeric value indicating the |
jitter.width |
a numeric value indicating the amount of horizontal jitter. |
jitter.height |
a numeric value indicating the amount of vertical jitter. |
jitter.alpha |
a numeric value between 0 and 1 for specifying the
|
gray |
logical: if |
start |
a numeric value between 0 and 1, graphical parameter to specify the gray value at the low end of the palette. |
end |
a numeric value between 0 and 1, graphical parameter to specify the gray value at the high end of the palette. |
color |
a character vector, indicating the color of the violins and the boxes. By default, default ggplot2 colors are used. |
xlab |
a character string specifying the labels for the x-axis. |
ylab |
a character string specifying the labels for the y-axis. |
ylim |
a numeric vector of length two specifying limits of the limits of the y-axis. |
ybreaks |
a numeric vector specifying the points at which tick-marks are drawn at the y-axis. |
title |
a character string specifying the text for the title for the plot. |
subtitle |
a character string specifying the text for the subtitle for the plot. |
filename |
a character string indicating the |
width |
a numeric value indicating the |
height |
a numeric value indicating the |
units |
a character string indicating the |
dpi |
a numeric value indicating the |
write |
a character string naming a text file with file extension
|
append |
logical: if |
check |
logical: if |
output |
logical: if |
Levene's test is equivalent to a one-way analysis of variance (ANOVA) with the
absolute deviations of observations from the mean of each group as dependent
variable (center = "mean"
). Brown and Forsythe (1974) modified the
Levene's test by using the absolute deviations of observations from the median
(center = "median"
). By default, the Levene's test uses the absolute
deviations of observations from the median.
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
data |
data frame specified in |
formula |
formula of the current analysis |
args |
specification of function arguments |
plot |
ggplot2 object for plotting the results |
result |
list with result tables, i.e., |
Takuya Yanagida takuya.yanagida@univie.ac.at
Brown, M. B., & Forsythe, A. B. (1974). Robust tests for the equality of variances. Journal of the American Statistical Association, 69, 364-367.
Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.
aov.b
, test.t
, test.welch
# Example 1: Levene's test based on the median
test.levene(mpg ~ gear, data = mtcars)
# Example 2: Levene's test based on the arithmetic mean
test.levene(mpg ~ gear, data = mtcars, method = "mean")
# Example 3: Levene's test based on the median, plot results
test.levene(mpg ~ gear, data = mtcars, plot = TRUE)
## Not run:
# Example 4: Write results into a text file
test.levene(mpg ~ gear, data = mtcars, write = "Levene.txt")
# Example 5: Levene's test based on the median, save plot
test.levene(mpg ~ gear, data = mtcars, plot = TRUE,
filename = "Levene-test.png", dpi = 600, width = 6, height = 5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.