The present invention includes a method and apparatus for the optimized treatment of obstructive sleep apnea. The present invention includes a pressure source configured to provide positive airway pressure to a patient who is resting at home. The pressure source receives control signals from control electronics that define a pressure profile to be delivered to the patient. The control electronics select parameters to define the pressure profile based on factors such as a user selection, information received from a sensor, and/or a prescription.