Disclosed is an apparatus for treating a respiratory disorder, configured to compute a measure of typical recent ventilation such that a rate of adjustment of the measure of typical recent ventilation is reduced as a measure of recent uncompensated leak increases.