Introduction to missr

What is missing data?

Missing data is defined as “data that we intended to collect, but for one reason or another were unable to” [1].

The problem of missing data

Missing data represents a loss of information, and so reduces the statistical power of a study [2].

Why can I not just impute the missing data?

Different methods for handling missing data (e.g. mean imputation) can introduce bias when estimating statistics [3]. Therefore, to produce unbiased estimates, one must choose the correct method. In order to do this, one must understand and categorise the pattern of missingness in the dataset. Having categorised the missingness as MCAR, MAR, or MNAR (see vignette("background")) one can then choose the correct method for handling the missing data without introducing bias.

How does missr work?

This package provides four functions to help you categorise the missingness in a dataset:

Each prints a one-sentence verdict, such as “No evidence of MNAR: the data are consistent with MAR”. Add verbose = TRUE to see the statistics behind it.

library(missr)
missr(healthcheck)
## Not MCAR, consistent with MAR: the recorded values differ between rows with
## and without missing values, but there is no evidence of MNAR (this does not
## prove MAR).
## 
##   MCAR (Little's test): not MCAR (p = 0.029)
##   MNAR (score test):    no evidence of MNAR (smallest adjusted p = 0.31)
## 
## Tip: this check is much more reliable with an instrument: a fully recorded
##   column linked to the column with gaps that doesn't affect whether it is
##   missing (e.g. the same measurement from last year).
##   No candidate for `rbc`: consider adding one to your data.
## 
## For the statistics behind this, use verbose = TRUE.
missr(companydata, instrument = c(employees = "employees_last_year"))
## Evidence of MNAR in `employees`: whether a value is missing appears to
## depend on the missing value itself.
## 
##   MCAR (Little's test):            not MCAR (p < 0.001)
##   MNAR (score + instrument tests): evidence of MNAR (smallest adjusted p < 0.001)
## 
## For the statistics behind this, use verbose = TRUE.

Or run the tests one at a time:

mcar(healthcheck)
## Evidence the data are not MCAR: the recorded values differ between rows with and without missing values.
## 
## For the statistics behind this, use verbose = TRUE.
mar(healthcheck)
## No evidence of MNAR: the data are consistent with MAR (this does not prove MAR).
## 
## Tip: this check is much more reliable with an instrument: a fully recorded
##   column linked to the column with gaps that doesn't affect whether it is
##   missing (e.g. the same measurement from last year).
##   No candidate for `rbc`: consider adding one to your data.
## 
## For the statistics behind this, use verbose = TRUE.
mar(companydata)
## No evidence of MNAR: the data are consistent with MAR (this does not prove MAR).
## 
## Tip: this check is much more reliable with an instrument: a fully recorded
##   column linked to the column with gaps that doesn't affect whether it is
##   missing (e.g. the same measurement from last year).
##   Try: mar(data, instrument = c(employees = "employees_last_year"))
##   No candidate for `product_rating`: consider adding one to your data.
## 
## For the statistics behind this, use verbose = TRUE.
mar(companydata, instrument = c(employees = "employees_last_year"))
## Evidence of MNAR in `employees`: whether a value is missing appears to depend on the missing value itself.
## 
## For the statistics behind this, use verbose = TRUE.

mar() works best with an instrument: a fully recorded column linked to the column with gaps that doesn’t affect whether values go missing. Without one it can miss MNAR, as above.

A test can only find evidence against an assumption, so missr never claims the data “are” MAR. See vignette("background") for why, and for what each test assumes.

This package also provides several toy datasets:

It also provides missr_benchmarks: 60 datasets built from real data that ships with R, with values removed by known rules (20 MCAR, 20 MAR and 20 MNAR), each with a valid instrument. missr’s own tests require the functions to classify them correctly.

Why was missr created?

There is a lack of information and software on practically categorising missing data.

References

[1] Carpenter JR, Kenward MG. Missing Data in Randomised Controlled Trials: A Practical Guide. Health Technology Assessment Methodology Programme; 2007.

[2] Pham TM, Pandis N, White IR. Missing data: Issues, concepts, methods. Seminars in Orthodontics. 2024;30(1):37-44. Statis- tics every orthodontist should know.

[3] van Buuren S. Flexible Imputation of Missing Data, Second Edition. Chapman and Hall/CRC; 2018.