A method for use in an implantable medical device comprises the steps of monitoring respiration with an amplifier having a gain, generating a moving apneic threshold based on recent respiration cycles, accumulating differences between amplitudes of respiration cycles and the moving apnea detection threshold and comparing the accumulated differences against an apnea detection threshold to detect the onset of an episode of apnea. The method further comprises measuring respiration levels upon detecting the onset of apnea, confirming the episode of apnea based upon the respiration levels measured upon detecting the onset of apnea; and adjusting one of the gain of the amplifier and the apnea detection threshold so that the time from the detection of onset of apnea to the time of confirmation of the episode of apnea is within a predetermined time range following the detection of the onset of apnea.