There is a large literature on social interactions and still little is known about the economic mechanisms leading to the high level of clustering in behavior that is so commonly observed in the data. In this paper we present a model in which agents are allowed to interact according to three distinct mechanisms, and we derive testable implications on the mean and the variance of the outcomes within and across groups. The empirical tests allow us to distinguish which mechanism(s) generates the observed patterns in the data. In our application we study the performance of undergraduate students and we find that social interactions take the form of mutual insurance. Such a result bears crucial policy implications for all those situations in which social interactions are important, from teamwork to class formation in education and co-authorship in academic research.