A doctor may diagnose you with respiratory failure based on the oxygen and carbon dioxide levels in your blood, a physical exam to see how fast and shallow your breathing is and how hard you are working to breathe, as well as the results of lung function tests.