%TVCCI_SIMU.M %Simulates equilibrium dynamics in an economy with an individual time-varying collateral constraint. For a description of the underlying economic model, see ``Individual Versus Aggregate Collateral Constraints and the Overborrowing Syndrome,'' by Martin Uribe, April 2006. %(c) Martin Uribe, April 27, 2006 function [dm, A, Z, R, LA, H, Y, C, BETTA,Q, u] = tvcci_simu(zL, zH, DL, DH, aL, aH, a1L, a1H, n, RSTAR, SIG, OMEGA, BETTA1, ALFA, PAIZ, KAPA, Kss); rand('state',sum(100*clock)); %sets a different state each time. %Length of simulation T = 5000; Tcut = 1000;%number of periods thrown out in computing the test %Usable periods Tleft = T-Tcut; A0 = 5.10;%initial debt position b=0;h=0;aa=0;%initial conditions for construction of den Haan and Marcet (RES, 1994) accuracy test %initial state x = rand<0.5; sL = x; %low state sH = 1-x; %high state for t=1:T %External debt A(t,1) = A0; %Update state of nature x = randTcut; tt = t-Tcut; %Error in bond Euler equation u(tt,1) = LA(t-1)-R(t-1).* BETTA(t-1).* LA(t); %Error in land Euler equation u1(tt,1) = LA(t-1)*Q(t-1) - BETTA(t-1) / (1-KAPA*XI(t-1)) * LA(t) * (Q(t) + exp(Z(t)) * ALFA * (H(t)/Kss)^(1-ALFA)); %Instruments h = [A(t-5:t-1)' 1 Z(t-5:t-1)']; %Orthogonality conditions UH = kron([u(tt) u1(tt)],h); %Mean of orthogonality conditions b = b + UH/Tleft ; %average of var/cov of orthogonality conditions aa = aa + UH'*UH/Tleft; end %if t>Tcut end %for t=1:T %denHaan-Marcet (RES, 1994) statistic dm = Tleft * b*inv(aa)*b';