The origins of status hierarchies: A formal theory and empirical test