Missing Data - Little's MCAR Test

From Q
Jump to: navigation, search

Tests the null hypothesis that the missing data is Missing Completely At Random (MCAR). A p.value of less than 0.05 is usually interpreted as being that the missing data is not MCAR (i.e., is either Missing At Random or non-ignorable). See What are the Different Types of Missing Data? for more information about MCAR and other types of missing data.

Example

The default "Summary" output is shown below:

Usage

To run this test in Displayr, go to Insert > More > Missing Data > Little's MCAR Test (in Q, go to Automate > Browse Online Library > Missing Data > Little's MCAR Test).

In the object inspector, under Inputs > Variables select the variables you want to analyze, change any other settings, and click Calculate to run the function.

Options

Variables The variables to appear in the rows, as categories.

Output

Summary Shows a nicely formatted table of the test results (default).
R The original text-based output from the LittleMCAR function.

Variable names Display Variable Names in the output, instead of Variable Labels.

More decimal places Display numeric values with 8 decimal places.

Filter The data is automatically filtered using any filters prior to estimating the model.

Technical information

This test starts by using the EM algorithm to estimate the means and covariances. These estimates are approximate, and, consequently, the test is also approximate (it may get slightly different results on different computers).

This test does not take weights into account.

Acknowledgements

Uses the LittleMCAR function from the R Package BaylorEdPsych.

Little, R. J. A. (1988). A test of missing completely at random for multivariate data with missing values. Journal of the American Statistical Association, 83(404), 1198–1202.

Code

form.setHeading("Little's MCAR Test");
form.dropBox({label: "Variables", 
            types:["Variable: Numeric, Date, Money, Categorical, OrderedCategorical"], 
            name: "formVariables",
            multi:true, min_inputs: 2, height: 8, prompt: "Select at least two Variables"});
var formOutput = form.comboBox({label: "Output", 
              alternatives: ["Summary", "R"], 
              name: "formOutput", default_value: "Summary", prompt: "Select the output type"});
if (formOutput.getValue() == "Summary")
{
    form.checkBox({label: "Variable names", name: "formNames", default_value: false, prompt: "Display names instead of labels"});
    form.checkBox({label: "More decimal places", name: "formDecimals", default_value: false, prompt: "Display numeric values with eight decimal places"});
}
library(flipFormat)
library(flipTransformations)
if (length(unique(sapply(formVariables, length))) != 1)
    stop("All variables must be the same length and are not.")
dat <- ProcessQVariables(data.frame(if (length(formVariables) == 1) formVariables[[1]] else formVariables))
names(dat) <- Names(formVariables)
dat <- AsNumeric(dat[QFilter, ], binary = FALSE)
dat <- dat[apply(is.na(dat), 1, sum) < ncol(dat), ] # Removing cases with all missing values
lmcar <- BaylorEdPsych::LittleMCAR(dat)
little.mcar <- if (formOutput == "Summary") {
    decimal.places <- if (formDecimals) 8 else NULL
    SignificanceTest(lmcar, "Little's MCAR Test", formVariables, filter = QFilter,
                     missing = "Exclude cases with all missing data",
                     show.labels = !formNames, decimal.places = decimal.places)
} else
    lmcar