Theory of collective behavior