Learn R Programming

smsets (version 2.0.0)

Levenetestsms.mv: Robust Levene's Tests for the Comparison of Variation of m Samples in Multivariate Data

Description

Performs Levene's tests for m samples on p responses, based on (univariate) One-Way ANOVAs and One-Way MANOVAs applied to absolute differences around medians. Significance levels of the univariate tests of variation can be corrected using any of the adjustment methods for multiple comparisons offered by p.adjust. Effects sizes are also computed with respect to the One-Way ANOVAs.

Usage

Levenetestsms.mv(x, group, var.equal = FALSE, P.adjust = "none")

Value

Returns an list of class "Levenetestsms.mv", a list containing the following components:

nameA character string describing the function.mediansA \(m \times p\) matrix; the cell (m,p) contains the median of the p-th response in sample m.absdev_mediansA list containing m data frames, one data frame for each level of group, and each data frame having p columns containing the absolute deviations around the m-th sample median.df_absdevA data frame containing the absolute deviations around medians, seen as a compact version of absdev_medians.means_absdevA \(m \times p\) matrix; the cell (m,p) contains the mean absolute deviation around the median of the p-th response in sample m.vars_absdevA \(m \times p\) matrix; the cell (m,p) contains the variance of absolute deviations around the median of the p-th response in sample m.OneWayANOVAsA list containing the results of the p tests for equal means of absolute deviations around medians in a one-way layout. Each element in the list is basically the result of oneway.test, but the p-values have been possibly recomputed as a consequence of the P.adjust method chosen.ANOVATablesA list containing p analysis of variance tables produced by anova.lm, each table corresponding to a one-way analysis of variance for the comparison of m-samples on the p-th response variable. Each element in the list is basically the result of anova.lm, but the p-values have been possibly recomputed as a consequence of 1) the P.adjust method chosen, and/or 2) the assumption of equal variance of absolute deviations around medians is FALSE.var.equal
A logical variable indicating whether the two variances were treated as being equal TRUE or not FALSE.P.adjustA character string indicating the correction method chosen.Eff_sizesA list of length p containing four effect size measures for an F-test in one-way ANOVA, and their respective 95% confidence intervals. Those measures are \(\eta^2\), \(\omega^2\), \(\epsilon^2\) and Cohen's f, as implemented in the effectsize package (Ben-Shachar et al. 2020). When var.equal = FALSE these effect sizes are approximations.OWM_absdevA list of class "manova" containing the results of the One-Way MANOVA applied to the absolute deviations around medians, i.e., the multivariate Levene's test.groupA character string specifying the name of the m-level factor defining samples.levels.groupA vector of length m showing the levels in factor group.variablesA vector of length p showing the names of response variables.data.nameA character string giving the name of the data.dataThe data frame analyzed.

The extractor function print.Levenetestsms.mv returns an annotated output of the univariate Levene tests and, optionally, the multivariate Levene's test.

Arguments

x

a data frame containing a factor with m levels and p response variables.

group

a factor with m levels defining samples. It must be one of the columns in x.

var.equal

a logical variable indicating whether to treat the m variances of absolute deviations around medians (the variances of the measure of variation among samples!) as being equal for the One-Way ANOVAs. If TRUE then a simple F test for the equality of means is performed. If FALSE the Welch (1951) approximation to the degrees of freedom is used, as implemented in oneway.test.

P.adjust

p-value correction method of univariate Levene's tests (One-Way ANOVAs), a character string. Can be abbreviated. See 'Details'.

Author

Jorge Navarro Alberto, ganava4@gmail.com

Details

This function focuses on robust Levene's tests, both univariate and multivariate, for the comparison of variation among m samples in multivariate data. These tests can be chosen as alternatives to Box's test which is sensitive to deviations from normality. The application of Levene's test one variable at a time from a set of p variables can be computed by repeating p times car's package function leveneTest (Fox and Weisberg 2019), when center = median. However, there are p univariate Levene's tests possible, each one consisting of one-way ANOVAs applied to the absolute deviations around medians. Therefore, the p-values produced in the ANOVAs can be subject to corrections for multiple testing, depending on the number of response variables analyzed. The methods implemented in P.adjust are the same as those contained in the p.adjust.methods: "bonferroni", "holm", "hochberg", "hommel", "BH", (Benjamini-Hochberg) or its alias "fdr" (False Discovery Rate), and "BY" (Benjamini & Yekutieli). The default pass-through option ("none") is also included. Four measures of effect size are also computed with respect to the univariate F tests, which are interpreted as effect sizes of variation among samples. User-friendly summaries of all analyses (including the multivariate Levene's test) can be invoked using the print method for this function.

References

Ben-Shachar, M., Lüdecke, D., and Makowski, D. (2020). effectsize: Estimation of Effect Size Indices and Standardized Parameters. Journal of Open Source Software, 5(56), 2815. doi: 10.21105/joss.02815

Fox, J., and Weisberg, S. (2019). An R Companion to Applied Regression, Third edition. Sage, Thousand Oaks CA. https://www.john-fox.ca/Companion/.

Manly, B.F.J., Navarro Alberto, J.A. and Gerow, K. (2024) Multivariate Statistical Methods. A Primer. 5th Edn. Chapman and Hall/CRC.

Welch, B.L. (1951). On the comparison of several mean values: an alternative approach. Biometrika, 38, 330-336. doi:10.2307/2332579.

Examples

Run this code
data(skulls)
res.Levenems.mv <- Levenetestsms.mv(skulls, Period, var.equal = TRUE,
                                    P.adjust = "bonferroni")
res.Levenems.mv

Run the code above in your browser using DataLab