Skip to content

Commit

Permalink
Rearrange tests and Matlab files
Browse files Browse the repository at this point in the history
  • Loading branch information
mgao6767 committed Jul 6, 2023
1 parent d3419f1 commit 953d76e
Show file tree
Hide file tree
Showing 27 changed files with 69 additions and 1,577 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [F, f1j, ival, rho, sig, T] = GenTestDataLoanPayoff()
function [F, f1j, ival, rho, sig, T] = FRDSGenTestDataLoanPayoff()
fs = [-0.8:0.05:0.8]'/(0.2*sqrt(0.5)*sqrt(10)); %range for dW_0 shocks

N = 10; %number of loan cohorts
Expand Down
11 changes: 9 additions & 2 deletions src/frds/measures/modified_merton/matlab/ModMertonComputation.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
%if not provided as input, then generate here
if nargin < 5
rng(1,'twister')
w = normrnd(0,1,[Nsim2, 3*N]);
% w = normrnd(0,1,[Nsim2, 3*N]);
% Mingze's note
% This is to produce the same random normal values as numpy
% For unknown reasons, same seed doesn't guarantee same random NORMAL values
% in Matlab and Numpy given the same MT19937 rng.
% This line below is a workaround.
w = norminv(rand(Nsim2, 3*N),0,1);
end

ival = log(bookF)-log(ltv); %initial log asset value of borrower at origination
Expand Down Expand Up @@ -173,7 +179,8 @@
for j = 1:N
FHr = reshape(FHr1(:,j,:)+FHr2(:,j,:),Nsim2*Nsim1,1);
Lr = reshape(Lr1(:,j,:)+Lr2(:,j,:),Nsim2*Nsim1,1);
[sortF, ind] = sort(FHr);
% Mingze's note: line below is changed to make sure we rely on a fixed precision
[sortF, ind] = sort(round(FHr, 9));
sortL = Lr(ind);
win = (Nsim2*Nsim1)/20; %/10 seems to give about sufficient smoothness
LHs = fftsmooth(sortL,win);
Expand Down
11 changes: 6 additions & 5 deletions src/frds/measures/modified_merton/matlab/ModMertonCreateLookup.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@


rng(1,'twister')
w = normrnd(0,1,[Nsim2, 3*N]);

% w = normrnd(0,1,[Nsim2, 3*N]);
w = norminv(rand(Nsim2, 3*N),0,1);

J = size(xsig,2);
K = size(xr,3);
Q = size(xF,4);
Expand All @@ -25,9 +26,9 @@
for k = 1:K

for q = 1:Q
j
k
q
% j
% k
% q

param = [xr(1,j,k,q); T; xF(1,j,k,q); H; bookD*exp(xr(1,j,k,q)*H); rho; ltv; xsig(1,j,k,q); d; y]; %get face value of debt from current book value of debt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
clc;

%output directory
direc = ['/Users/snagel/Dropbox/hdrive/Research/projects/BankCreditRisk/output/'];
direc = ['./'];

comp = 1; %1 to re-calculate, 0 to use already saved file;

Expand Down
9 changes: 0 additions & 9 deletions tests/measures/modified_merton/matlab/FindFaceValueIndiv.m

This file was deleted.

21 changes: 0 additions & 21 deletions tests/measures/modified_merton/matlab/LoanPayoff.m

This file was deleted.

31 changes: 0 additions & 31 deletions tests/measures/modified_merton/matlab/MertonSolution.m

This file was deleted.

255 changes: 0 additions & 255 deletions tests/measures/modified_merton/matlab/ModMertonComputation.m

This file was deleted.

Loading

0 comments on commit 953d76e

Please sign in to comment.