%% Calculate Hazard Rates Based on Default Probability Curve
% Create a defprobcurve object using defprobcurve and then use hazardrates to calculate the hazard rates.

Settle = datetime(2017,9,20);
DefProbTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])];
DefaultProbabilities = [0.005 0.007 0.01 0.015 0.026 0.04 0.077 0.093 0.15 0.20]';
ProbDates = Settle + DefProbTimes;

DefaultProbCurve = defprobcurve(Settle,ProbDates,DefaultProbabilities,'Basis',5)
hazardrates(DefaultProbCurve)

% Copyright 2019 The MathWorks, Inc.