An implantable medical device (100) is connectable to or comprises an activity sensor (40) and determines a current activity level of a subject (10) based on a sensor signal from the activity sensor (40). A time period during which the current activity level of the subject (10) has exceeded a threshold level is also determined. A pulse generator controller (154) controls a pulse generator (130, 135) to generate pacing pulses to be applied to the subjects heart (15) 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.