Learn R Programming

misty (version 0.4.5)

test.levene: Levene's Test for Homogeneity of Variance

Description

This function performs Levene's test for homogeneity of variance across two or more independent groups.

Usage

test.levene(formula, data, method = c("median", "mean"), conf.level = 0.95,
            hypo = TRUE, descript = TRUE, digits = 2, p.digits = 3,
            as.na = NULL, check = TRUE, output = TRUE)

Arguments

formula

a formula of the form y ~ group where y is a numeric variable giving the data values and group a numeric variable, character variable or factor with two or more than two values or factor levels giving the corresponding groups.

data

a matrix or data frame containing the variables in the formula formula.

method

a character string specifying the method to compute the center of each group, i.e. method = "median" (default) to compute the Levene's test basd on the median (aka Brown-Forsythe test) or method = "mean" to compute the Levene's test based on the arithmetic mean.

conf.level

a numeric value between 0 and 1 indicating the confidence level of the interval.

hypo

logical: if TRUE, null and alternative hypothesis are shown on the console.

descript

logical: if TRUE, descriptive statistics are shown on the console.

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 NA before conducting the analysis.

check

logical: if TRUE, argument specification is checked.

output

logical: if TRUE, output is shown.

Value

Returns an object of class misty.object, which is a list with following entries: function call (call), type of analysis type, formula (formula), data frame with the outcome and grouping variable, (data), specification of function arguments (args), and a list with descriptive statistics including confidence interval and an object of class "anova" (result).

Details

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.

References

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.

See Also

t.test, aov

Examples

Run this code
# NOT RUN {
dat <- data.frame(y = c(2, 3, 4, 5, 5, 7, 8, 4, 5, 2, 4, 3),
                  group = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3))

# Levene's test based on the median with 95% confidence interval
test.levene(y ~ group, data = dat)

# Levene's test based on the arithmetic mean  with 95% confidence interval
test.levene(y ~ group, data = dat, method = "mean")

# Levene's test based on the median with 99% confidence interval
test.levene(y ~ group, data = dat, conf.level = 0.99)
# }

Run the code above in your browser using DataLab