A nonlinear dynamic model for credit risk contagion