%% Estimate Transition Probabilities Using a totals Structure Input
% Use historical credit rating input data from Data_TransProb.mat and transprob to generate input for transprobbytotals:

load Data_TransProb

% Call TRANSPROB with three output arguments
[transMat, sampleTotals, idTotals] = transprob(data);
transMat

%
% Suppose companies 4 and 27 are outliers and you want to remove them from the pre-processed idTotals struct array and estimate the new transition probabilities.

idTotals([4 27]) = [];
[transMat1, sampleTotals1] = transprobbytotals(idTotals);
transMat1

%
% Obtain the 1-year, 2-year, 3-year, 4-year, and 5-year default probabilities, without the outlier information (i.e., using sampleTotals1).

DefProb = zeros(7,5);
for t = 1:5
    transMatTemp = transprobbytotals(sampleTotals1,'transInterval',t);
    DefProb(:,t) = transMatTemp(1:7,8);
end
DefProb

% Copyright 2015 The MathWorks, Inc.