A study:

[P]erceived service quality was associated with both the likelihood of giving a tip and the amount tipped, thus suggesting that participants were using tipping as a form of reward. Similarly, those who said they thought it was important to help others in need tended to tip more (although they weren't any more likely to tip), suggesting altruism was another motive. Finally, social norms were a key factor - participants who said their friends and relatives thought it was important to tip were more likely to tip themselves, especially if there were more people with them at the time of questioning. Size of tip was not associated with this factor, perhaps because it's only the act of tipping that's visible to others, rather than the amount tipped.

Analysis from Sager here.