invert matrix with NA indicators