mcar_test | R Documentation |
Use Little's (1988) test statistic to assess if data is missing completely
at random (MCAR). The null hypothesis in this test is that the data is
MCAR, and the test statistic is a chi-squared value. The example below
shows the output of mcar_test(airquality)
. Given the high statistic
value and low p-value, we can conclude the airquality
data is not
missing completely at random.
mcar_test(data)
data |
A data frame |
A tibble::tibble()
with one row and four columns:
statistic |
Chi-squared statistic for Little's test |
df |
Degrees of freedom used for chi-squared statistic |
p.value |
P-value for the chi-squared statistic |
missing.patterns |
Number of missing data patterns in the data |
Code is adapted from LittleMCAR() in the now-orphaned BaylorEdPsych
package: https://rdrr.io/cran/BaylorEdPsych/man/LittleMCAR.html. Some of
code is adapted from Eric Stemmler: https://web.archive.org/web/20201120030409/https://stats-bayes.com/post/2020/08/14/r-function-for-little-s-test-for-data-missing-completely-at-random/
using Maximum likelihood estimation from norm
.
Andrew Heiss, andrew@andrewheiss.com
Little, Roderick 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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1988.10478722")}.
mcar_test(airquality)
mcar_test(oceanbuoys)
# If there are non-numeric columns, there will be a warning
mcar_test(riskfactors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.