*Abstract*: Missing data are ubiquitous in many domains such as healthcare. When these data entries are not missing completely at random, the (conditional) independence relations in the observed data may be different from those in the complete data generated by the underlying causal process. Consequently, simply applying existing causal discovery methods to the observed data may lead to wrong conclusions. In this paper, we aim at developing a causal discovery method to recover the underlying causal structure from observed data that are missing under different mechanisms, including missing completely at random (MCAR), missing at random (MAR), and missing not at random (MNAR). With missingness mechanisms represented by missingness graphs (m-graphs), we analyze conditions under which additional correction is needed to derive conditional independence/dependence relations in the complete data. Based on our analysis, we propose Missing Value PC (MVPC), which extends the PC algorithm to incorporate additional corrections. Our proposed MVPC is shown in theory to give asymptotically correct results even on data that are MAR or MNAR. Experimental results on both synthetic data and real healthcare applications illustrate that the proposed algorithm is able to find correct causal relations even in the general case of MNAR. 



*GitHub*: In this repository, we provide the implementation of Missing Value PC (MVPC) for both linear Gaussian and binary cases. 
MVPC is a framework of causal discovery in the presence of different missingness mechanisms, including missing completely at random (MCAR), missing at random (MAR), and missing not at random (MNAR). 
MVPC is based on the PC algorithm and contains two methods for correcting wrong results produced by missing value issues, Permutation-based Correction (PermC) and Density Ratio Weighted (DRW) correction method. 
More details can be found in the paper :footcite:t:`tu2019causal` and the long paper version :footcite:t:`tu2020causald`. 
The implementation is based on the R package pcalg.


.. rubric:: Example 

Config file: `mvpc.json <https://github.com/felixleopoldo/benchpress/blob/master/workflow/rules/structure_learning_algorithms/mvpc/mvpc.json>`_

Command:

.. code:: bash

    snakemake --cores all --use-singularity --configfile workflow/rules/structure_learning_algorithms/mvpc/mvpc.json

:numref:`mvpcplot` and :numref:`mvpcplot2`  show FP/P vs. TP/P for pattern graphs and skeletons based on 3 datsets corresponding to 3 realisations of a 20-variables random Gaussian SEM, with an average indegree of 4.
Each dataset contains 10000 samples and contains data that is missing not at random (MNAR) and was sampled using :ref:`mvpc_gen_data`.


.. _mvpcplot:

.. figure:: ../../../workflow/rules/structure_learning_algorithms/mvpc/pattern.png
    :width: 320 
    :alt: FP/P vs. TP/P MVPC example
    :align: left

    FP/P vs. TP/P. for pattern graphs

.. _mvpcplot2:

.. figure:: ../../../workflow/rules/structure_learning_algorithms/mvpc/skeleton.png
    :width: 320 
    :alt: FP/P vs. TP/P MVPC example
    :align: right

    FP/P vs. TP/P. for  skeletons

