Default, Liquidity and Crises: An Econometric Framework