%CCRC_SIMU.M %This program produces a simulation of the equilibrium dynamics function [dm, A, Z, R, LA, H, Y, C, BETTA, u] = ccrc_simu(zL, zH, DL, DH, aL, aH, n, RSTAR, SIG, OMEGA, BETTA1, ALFA, PAIZ, KAPA, Kss,QQss); %The following command sets a different state of the seed for random numbers each time this program is used rand('state',sum(100*clock)); %Length of simulation in periods T = 5000; %Number of initial periods to be discarded in computing the denHaan-Marcet (RES, 1994) statistic Tcut = 1000; %Number of usable periods for computing the denHaan-Marcet statistic Tleft = T-Tcut; %Initial value of debt 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 of technology x = rand<0.5; sL = x; %low state sH = 1-x; %high state for t=1:T %Debt A(t,1) = A0; %Productivity shock x = randTcut; tt = t-Tcut; u(tt,1) = LA(t-1)-R(t-1).* BETTA(t-1).* LA(t); h = [A(t-5:t-1)' 1 Z(t-5:t-1)']; b = b + u(tt)*h/Tleft ; aa = aa + u(tt)^2 * h'*h/Tleft; end %if t>Tcut end %for t=1:T %denHaan-Marcet (RES, 1994) statistic dm = Tleft * b*inv(aa)*b'; dm = Tleft * b*inv(aa)*b';