Perform a Jeffreys test on aggregated probability of default (PD) data. The Jeffreys test determines whether the PD is greater than the default rate. The file PDRatingGradeData.csv contains a table with variables that include PD, RatingGrade, and Default. These variables, respectively, correspond to the PD, customer rating grade, and whether the customer defaulted.
Load the data.
data=500×4 table
PD RatingGrade ObservationYear Default
________ ___________ _______________ _______
0.40736 9 2020 0
0.4529 10 2020 0
0.063493 2 2020 0
0.45669 10 2020 1
0.31618 7 2020 0
0.04877 1 2020 0
0.13925 3 2020 0
0.27344 6 2020 0
0.47875 10 2020 0
0.48244 10 2020 0
0.078807 2 2020 0
0.4853 10 2020 0
0.47858 10 2020 0
0.24269 5 2020 0
0.40014 9 2020 0
0.070943 2 2020 0
⋮
Use the groupsummary function to aggregate the data by rating grade and calculate the sum and the mean of PD and Default for each group.
aggData=10×6 table
RatingGrade GroupCount sum_PD mean_PD sum_Default mean_Default
___________ __________ ______ ________ ___________ ____________
1 56 1.5593 0.027845 6 0.10714
2 79 6.0743 0.07689 18 0.22785
3 68 8.6793 0.12764 16 0.23529
4 54 9.4626 0.17523 21 0.38889
5 45 10.206 0.2268 11 0.24444
6 40 11.001 0.27502 14 0.35
7 40 13.08 0.327 10 0.25
8 34 12.796 0.37635 13 0.38235
9 37 15.526 0.41964 19 0.51351
10 47 22.219 0.47274 22 0.46809
aggData is a table that contains the aggregated data.
Perform the Jeffreys test. Use the average probabilities, total number of defaults, and total number of loans as input arguments.
hJeffreysTest = 10×1
1
1
1
1
0
0
0
0
0
0
Output = struct with fields:
Results: [10×8 table]
hJeffreysTest contains the results of the hypothesis test and Output contains additional statistics. The results of the hypothesis test show that enough evidence exists to reject the null hypothesis for the first four groups in the hJeffreysTest listing.
Display the Results field of Output.
ans=10×8 table
RejectTest PValue Probability CriticalValue NumEvents NumTrials ObservedProbability ConfidenceLevel
__________ __________ ___________ _____________ _________ _________ ___________________ _______________
1 0.0020852 0.027845 0.053864 6 56 0.10714 0.95
1 1.2882e-05 0.07689 0.15815 18 79 0.22785 0.95
1 0.0068992 0.12764 0.15973 16 68 0.23529 0.95
1 9.566e-05 0.17523 0.28585 21 54 0.38889 0.95
0 0.37742 0.2268 0.15256 11 45 0.24444 0.95
0 0.14453 0.27502 0.23637 14 40 0.35 0.95
0 0.85089 0.327 0.15239 10 40 0.25 0.95
0 0.46541 0.37635 0.25591 13 34 0.38235 0.95
0 0.12403 0.41964 0.3809 19 37 0.51351 0.95
0 0.52436 0.47274 0.35209 22 47 0.46809 0.95
The Results table includes the hypothesis test p-values and the critical values. The variable ObservedProbability variable contains the default rate, which is the quotient of NumEvents and NumTrials.