Explaining the dynamics of teacher compensation