Provide a pipe-friendly framework to easily compute Levene's test for homogeneity of variance across groups.

Wrapper around the function leveneTest(), which can additionally handles a grouped data.

levene_test(data, formula, center = median)

Arguments

data

a data frame for evaluating the formula or a model

formula

a formula

center

The name of a function to compute the center of each group; mean gives the original Levene's test; the default, median, provides a more robust test.

Examples

# Prepare the data data("ToothGrowth") df <- ToothGrowth df$dose <- as.factor(df$dose) # Compute Levene's Test df %>% levene_test(len ~ dose)
#> # A tibble: 1 x 4 #> df1 df2 statistic p #> <int> <int> <dbl> <dbl> #> 1 2 57 0.646 0.528
# Grouped data df %>% group_by(supp) %>% levene_test(len ~ dose)
#> # A tibble: 2 x 5 #> supp df1 df2 statistic p #> <fct> <int> <int> <dbl> <dbl> #> 1 OJ 2 27 1.84 0.178 #> 2 VC 2 27 2.17 0.134