Skip to contents

[Stable] mcar() performs Little's MCAR test to test for MCAR. The null hypothesis is that the data is MCAR.

Usage

mcar(data, debug = FALSE)

Arguments

data

A data frame.

debug

A logical value used only for unit testing.

Value

A tibble::tibble():

statistic

The d^2 statistic

degrees_freedom

Degrees of freedom of chi-squared distribution

p_val

P-value of the test

missing_patterns

Number of missing patterns

Details

This function reproduces the d^2 statistic in equation (5) from [1]. This statistic is used to test for MCAR. Comments reference variables from vignette("background") (in brackets) to improve readability and traceability.

Note

Code is adapted from mcar_test() from the naniar package using base R instead of the tidyverse.

References

[1] Little RJA. A Test of Missing Completely at Random for Multivariate Data with Missing Values. Journal of the American Statistical Association. 1988;83(404):1198-202.

Examples

mcar(pollutionlevels)
#> # A tibble: 1 × 4
#>   statistic degrees_freedom p_val missing_patterns
#>       <dbl>           <dbl> <dbl>            <int>
#> 1      1.49               3 0.684                2