An implantable medical device is connectable to or comprises an activity sensor and determines a current activity level of a subject based on a sensor signal from the activity sensor. A time period during which the current activity level of the subject has exceeded a threshold level is also determined. A pulse generator controller controls a pulse generator to generate pacing pulses to be applied to the subjects heart at a pacing rate that is determined based on the current activity level and the length of the time period of activity at a level exceeding the threshold level.