multkw.m: Multivariate Kruskal-Wallis test with missing data

View source: R/multkw_m.R

multkw.mR Documentation

Multivariate Kruskal-Wallis test with missing data

Description

This function computes a multivariate Kruskal-Wallis test for n numeric variables (which can contain NA's) relative to one factorial variable (that subsets the dataset in groups)

Usage

multkw.m(group, y, r, weight, print = TRUE)

Arguments

group

The factorial variable that subsets the dataset in groups. Can be a character vector, a factorial vector or an integer/numeric vector.

y

The dataset of n numeric(or integer) variables.

r

Optional. The missing data pattern to be applied. If dataset has NA and if the missing data pattern is the distribution of the NA's in the dataset, r is optional and is automatically computed.

weight

Optional. The weighting scheme to be used to compute the final value of the test statistic. As test statistics are calculated for each pattern of missingness, there are as statistics as patterns. The final test statistic can thus be the arithmetic mean of each statistic (weight="equal") or the ponderated mean of each statistic relative to the proportion of each missing pattern (weight="prop").

print

Whether the test should be printed (TRUE, the default) or not (e.g., to be stored in an object)

Details

A "likelihood-based" multivariate Kruskal-Wallis test is computed ; in large samples, the test statistic is approximately khi² distributed. A first "classic" multivariate Kruskal-Wallis test is computed on "complete" data (i.e. removing the rows with at least one missing value). A second test is computed and include missing values: the test is computed for each "missing pattern" (i.e. missing pattern 1 = no missing data ; missing pattern 2 = missing data only in the first variable, etc) and a general test statistic is thus obtained from the "partial" test statistics. See also option "weight". Finally, outputs allow to compare results with complete data only and with missing data. As the test statistic is approximately khi² distributed (in large samples), p-values are based on khi² distributions. Degrees of freedom ar not the same for the "complete" data test and for the "missing" data test, see the See Also section.

Value

Returns a list of results of the various multivariate Kruskal-Wallis tests that have been computed. The results are the test statistics (W2), the degrees of freedom (df) and the p-value of the test statistic. These three results are given for (1) a "classical" multivariate Kruskal-Wallis test, i.e. on data without missing values; each test statistic is thus followed by a .c for "complete" and (2) a global multivariate Kruskal-Wallis test that takes into account missing values (see details); each test statistic is thus followed by a .m for "missing".

Author(s)

Fanyin He (most of the statistical function)

Jacob Maugoust (packaging)

References

\insertRef

He.etal.2017ULT

See Also

See chapter 2.2.2 and 4.2 of the PhD manuscript of Fanyin He and 'Methodology' of \insertCiteHe.etal.2017;textualULT for more details.

Examples

data(airquality)
datamkw<-airquality[,1:4]
multkw(y=datamkw,airquality$Month)
multkw.m(y=datamkw,airquality$Month)


jacobmaugoust/ULT documentation built on May 16, 2023, 1:29 p.m.