%------------------------------------------------------------------------- % The model: Safe Assets - the case of unit IES (THETA = 1) % % This file defines the baseline model (see Appendix for the full derivation). % Bonds are short term perfectly safe. % % Variables are denoted by small letters and % parameters by capital letters. Future values are denoted by suffix p. %------------------------------------------------------------------------- clear,clc %% Symbolic variables syms RHO GAMMA1 GAMMA2 NU MU TAU real syms f1 f2 f1p f2p x1 x2 x1p x2p real syms logq logqp tilp tilpp real syms state1 state1p state2 state2p hatyp deltap k1 tilb1 real syms tila1 tila1p tila2 invtila1 invtila2 invtilp rbp rep c1 c2 c1p c2p q qp real syms invc1 invc1p invc2 invc2p invf1 invf2 r1p r2p logu1p logu2p u1p u2p logf1 logf1p logf2 logf2p real syms term1p term2p invr1p invr2p real %% Parameters symparams = [RHO,GAMMA1,GAMMA2,NU,MU]; %% State variables state = [tila1]; % current period statep = [tila1p]; % future period %% Control variables control = [f1,f2,x1,x2,logq]; % current period controlp = [f1p,f2p,x1p,x2p,logqp]; % future period %% shocks shocks = [hatyp]; %% auxiliary variables tilp = 1/RHO; % price-dividend ratio for unit IES tilpp = tilp; % next period c1 = RHO/(1 + RHO); % consumption/wealth ratio of agent 1 for unit IES c1p = c1; % next period c2 = c1; % consumption/wealth ratio of agent 2 for unit IES c2p = c2; % next period logc1p = log(c1p); logc2p = log(c2p); invf1_ = 1/f1; invf2_ = 1/f2; logf1p_ = log(f1p); logf2p_ = log(f2p); invr1p_ = 1/r1p; invr2p_ = 1/r2p; q_ = exp(logq); qp_ = exp(logqp); invtila1_ = 1/tila1; invtila2_ = 1/tila2; rep_ = (1 + tilpp)/tilp*hatyp; % return on equity rbp_ = 1/q; % return on bond u1p_ = exp(logu1p); u2p_ = exp(logu2p); %% MODEL CONDITIONS tila2_ = tilp + 1 - tila1; k1_ = x1*(1 - c1)*tila1/tilp; tilb1_ = (1 - x1)*(1 - c1)*tila1; eq1 = tilb1*invtila2 + (1 - x2)*(1 - c2); r1p_ = x1*rep + (1 - x1)*rbp; r2p_ = x2*rep + (1 - x2)*rbp; term1p_ = r1p^(1 - GAMMA1)*((1 - NU*(1 - MU))*u1p^(1 - GAMMA1)... + NU*(1 - MU)*u2p^(1 - GAMMA1))*invf1^(1 - GAMMA1); term2p_ = r2p^(1 - GAMMA2)*((1 - NU*MU)*u2p^(1 - GAMMA2)... +NU*MU*u1p^(1 - GAMMA2))*invf2^(1 - GAMMA2); eq2 = -1 + term1p; % define f1 = (E(r1p*u1p)^(1-GAMMA1))^(1/(1-GAMMA1)) eq3 = -1 + term2p; % define f2 similarly logu1p_ = RHO/(1 + RHO)*logc1p + 1/(1 + RHO)*log(1 - c1p) + 1/(1 + RHO)*logf1p; logu2p_ = RHO/(1 + RHO)*logc2p + 1/(1 + RHO)*log(1 - c2p) + 1/(1 + RHO)*logf2p; eq4 = (rep - rbp)*term1p*invr1p; eq5 = (rep - rbp)*term2p*invr2p; %% Function f (Ef = 0 imposes model conditions) f_fun = [eq1;eq2;eq3;eq4;eq5]; %% law of motion of state variables Phi_fun = (1 + tilp)*(k1 - NU*(k1 - MU)) + (1 - NU)*tilb1/(hatyp*q); % law of motion of tila1 %% collect auxiliary variables and functions allvars=who; auxfuns=[]; auxvars=[]; for i=1:length(allvars) if strcmp(allvars{i}(end),'_') eval(['tempfun=' allvars{i} ';']) eval(['tempvar=' allvars{i}(1:end-1) ';']) auxfuns=[auxfuns;tempfun]; auxvars=[auxvars;tempvar]; end end %% Approximation order (<=4) order = 4; %% Preprocess model and save model = prepare_tp(f_fun,Phi_fun,controlp,control,statep,state,shocks,symparams,order,auxfuns,auxvars); save('model')