%FIGURE1.M function figure1 %This program produces figure 1 of the paper ``Deep Habits,'' by Morten Ravn, Stephanie Schmitt-Grohe, and Martin Uribe (Review of Econmic Studies) % %Calls: gx_hx.m, and ir.m % %(c) Stephanie Schmitt-Grohe and Martin Uribe % %Date December 23, 2003 %SHOCKS %shock=1 preference %shock=2 government spending %shock=3 technology for shock=1:3 %Theta = [theta_s theta_d; theta_g] %where theta_s=superficial habit parameter; theta_d=deep habit parameter; and theta_g=government deephabit parameter %The matrix Theta: row 1: deep habits; row 2: superficial habits; row 3: no habits. Theta=0.86*[1 1 1; 1 0 0;0 0 0 ]; %Compute analytical derivatives of equilibrium conditions [fx,fxp,fy,fyp,f] = dh; for iter=1:size(Theta,1) theta_s = Theta(iter,1); theta_d=Theta(iter,2); theta_g=Theta(iter,3); %Numerical evaluation %Assign values to parameters and steady-state variables [RHO, THETA_S,THETA_D,THETA_G,GBAR,SIGMA,CHI,GAMA,BETTA,DELTA,ALFA,ETA,RHOZ,RHOG,RHOV,RHOVV,nu,nug,w,h,c,s,u,k,ivv,markup,a,g,v,vv,stockg,output,xx,nup,nugp,wp,hp,cp,sp,up,kp,ivvp,markupp,ap,gp,vp,vvp,stockgp,outputp,xxp,NU,NUG,W,H,C,S,U,K,IVV,MARKUP,A,G,V,VV,STOCKG,OUTPUT,XX,PHI,EHW]=dh_ss(theta_s,theta_d,theta_g); approx = 1; %Order of approximation desired %Compute numerical derivatives of f num_eval %Compute first-order accurate approximation to the policy function [gx,hx] = gx_hx(nfy,nfx,nfyp,nfxp); %Time horizon for impulse responses T=21; %Compute impulse responses IR = ir(gx,hx,[0 0 0 0 (shock==1)*XX (shock==2)*1 (shock==3)*1],T); Ir(:,:,iter,shock) = IR; end t=(0:size(IR,1)-1)'; c = squeeze(Ir(:,5,:,:)); h = squeeze(Ir(:,4,:,:)); w = squeeze(Ir(:,3,:,:)); ivv = squeeze(Ir(:,6,:,:)); output = squeeze(Ir(:,2,:,:)); markup = squeeze(Ir(:,1,:,:)); nu = squeeze(Ir(:,8,:,:)); nug = squeeze(Ir(:,9,:,:)); s = squeeze(Ir(:,12,:,:)); g = squeeze(Ir(:,16,:,:)); a = squeeze(Ir(:,17,:,:)); subplot(3,4,1+(shock-1)*4) plot(t,markup(:,1,shock),'-',t,markup(:,2,shock),'--',t,markup(:,3,shock),':') title('Markup') subplot(3,4,2+(shock-1)*4) plot(t,output(:,1,shock),'-',t,output(:,2,shock),'--',t,output(:,3,shock),':') title('Output') subplot(3,4,3+(shock-1)*4) plot(t,w(:,1,shock),'-',t,w(:,2,shock),'--',t,w(:,3,shock),':') title('Wage') %ylabel('% dev. from ss') subplot(3,4,4+(shock-1)*4) plot(t,c(:,1,shock),'-',t,c(:,2,shock),'--',t,c(:,3,shock),':') title('Consumption') %ylabel('% dev. from ss') end shg %DH.M function [fx,fxp,fy,fyp,f] = dh %This program computes a log-linear approximation to the function f for an economy with catching up with the Joneses good by good. The model is described in ``Deep Habits,'' by M. Ravn, S. Schmitt-Grohe, and M. Uribe (RES). %The function f defines the DSGE model (a p denotes next-period variables) : % E_t f(yp,y,xp,x) =0. % %Inputs: theta_s theta_d theta_g (the degree of superficial, deep, and government habit) % %Output: analytical first derivative of f % %Calls: anal_deriv.m % %(c) Stephanie Schmitt-Grohe and Martin Uribe % %Date December 23, 2003 %Define parameters syms RHO THETA_S THETA_D THETA_G SIGMA CHI GAMA BETTA DELTA ALFA ETA RHOZ RHOG RHOV RHOVV GBAR PHI %Define variables syms xx xxp s sp c cp h hp w wp u up k kp ivv ivvp nu nup nug nugp markup markupp a ap g gp stockg stockgp output outputp v vp vv vvp %Give functional form for production, and utility functions %Utility function util = ((xx-log(vv))^(1-SIGMA) -1) / (1-SIGMA) + GAMA * ((1-h)^(1-CHI)-1) / (1-CHI); utilp = ((xxp-log(vvp))^(1-SIGMA) -1) / (1-SIGMA) + GAMA * ((1-hp)^(1-CHI)-1) / (1-CHI); pf = a*k^(ALFA)*h^(1-ALFA); pfp = ap * kp^(ALFA)*hp^(1-ALFA); %Write equations (ei, i=1:n) e1 = -xx + c-THETA_S * s; %Habit-adjusted consumption %Labor supply e2 = w + diff(util,'h') / diff(util,'xx'); %Euler equation e3 = -v^(1-SIGMA) * diff(util,'xx') + BETTA * vp^(1-SIGMA) * diff(utilp,'xxp') * (1-DELTA+up); %Resource constraint e4 = -(pf - PHI) + c + ivv + g; %Evoluiton of capital e5 = -kp + (1-DELTA) * k + ivv; %Markup e6 = -markup + diff(pf,'h') / w; %nu e7 = - (c+g+ivv) / ETA + nu * (c - THETA_D * s) + nug * (g - THETA_G * stockg) + ivv * (1-1/markup); %Firm's FOC w.r.t. s e8 = - (1-nu - 1/markup ) / (RHO-1) + BETTA * diff(utilp,'xxp') / diff(util,'xx') * (vp/v)^(1-SIGMA) * (THETA_D * nup + RHO * (1-nup-1/markupp) / (RHO-1)); %Firm's FOC w.r.t. stockg e9 = - (1-nug - 1/markup ) / (RHO-1) + BETTA * diff(utilp,'xxp') / diff(util,'xx') * (vp/v)^(1-SIGMA) * (THETA_G * nugp + RHO * (1-nugp-1/markupp) / (RHO-1)); %MRT = w/u e10 = -w / u + diff(pf,'h') / diff(pf,'k'); %Evolution of habit stock e11 = - sp + RHO * s + (1-RHO) * c; %Evolution of gov't habit stock e12 = -stockgp + RHO * stockg + (1-RHO) * g; %Technology shock e13 = log(ap) - RHOZ * log(a); %Government Purchases shock e14 = log(gp/GBAR) - RHOG * log(g/GBAR); %Evolution of preference shock e15 = - log(vp) + RHOV * log(v); e16 = - log(vvp) + RHOVV * log(vv); %Definition of output e17 = -output + pf - PHI; %Create function f f = [e1;e2;e3;e4;e5;e6;e7;e8;e9;e10;e11;e12;e13;e14;e15;e16;e17]; % Define the vector of controls in period t, y, and t+1, yp, and the vector of states in period t, x, and t+1, xp x = [stockg s k v vv g a]; xp = [stockgp sp kp vp vvp gp ap]; y = [markup output w h c ivv u nu nug xx]; yp = [markupp outputp wp hp cp ivvp up nup nugp xxp]; %Make f a function of the logarithm of the state and control vector f = subs(f, [x,y,xp,yp], exp([x,y,xp,yp])); approx = 1; %Order of approximation desired %Compute analytical derivatives of f [fx,fxp,fy,fyp]=anal_deriv(f,x,y,xp,yp,approx); %DH_SS.M function [RHO, THETA_S,THETA_D,THETA_G,GBAR,SIGMA,CHI,GAMA,BETTA,DELTA,ALFA,ETA,RHOZ,RHOG,RHOV,RHOVV,nu,nug,w,h,c,s,u,k,ivv,markup,a,g,v,vv,stockg,output,xx,nup,nugp,wp,hp,cp,sp,up,kp,ivvp,markupp,ap,gp,vp,vvp,stockgp,outputp,xxp,NU,NUG,W,H,C,S,U,K,IVV,MARKUP,A,G,V,VV,STOCKG,OUTPUT,XX,PHI,EHW]=dh_ss(theta_s,theta_d,theta_g); %This program produces the deep structural parameters and computes the steady state of the additive external deep habit model described in ``Deep Habits.'' by Morten Ravn, Stephanie Schmitt-Grohe, and Martin Uribe (RES). %(c) Stephanie Schmitt-Grohe and Martin Uribe, December 23, 2003 %Calibrated parameters THETA_S=theta_s;%superficial habit parameter THETA_D = theta_d;%deep habit parameter THETA_G = theta_g; %govt deep habit parameter SIGMA = 2; %intertemporal elasticity of substitution EHW = 1.3; %Frisch elasticity of labor suppy H = 0.2; %hours (Prescott, 1986) ETA = 5.3;%Long-run Price elasticity of demand for a particular variety. Taken from the econometric estimates shown in the paper ``Deep Habits'' R = 1.04^(1/4); %Gross quarterly real interest rate (Rotemberg & Woodford, JPE, 1991) SH = 0.75;%Labor share (Rotemberg & Woodford, JPE, 1991) SG = 0.12; % Steady State Share of Government Purchases (Rotemberg & Woodford, JPE, 1991) RHOZ = 0.9; %Persistence of technology shock z_t RHOG = 0.9; %Persistence of Government purchases shock RHOV = 0.9; %Persistence of preference shock RHOVV = 0.9; %Persistence of additive preference shock RHO = 0.85; %1-RHO is the weight on current consumption in the evolution of the stock of habit. S_t = RHO s_{t-1} + (1-RHO) C_{t}. Taken from the econometric estimates presented in ``Deep Habits.'' SC = 0.7; %Consumption share (Rotemberg & Woodford, JPE, 1991) %Implied parameters BETTA = 1/R; %Subjective discount factor SI = 1-SC-SG; %INVESTMENT SHARE m = SC * ((1-BETTA * RHO) * (1-THETA_D) / (BETTA * THETA_D * (RHO-1) +1 - BETTA * RHO)) + SG * ((1-BETTA * RHO) * (1-THETA_G) / (BETTA * THETA_G * (RHO-1) +1 - BETTA * RHO)) + SI; MARKUP = 1/ (1-1/ETA/ m); %Markup ALFA = 1 - SH; %capital elasticity of output SK = SH * ALFA/(1-ALFA); %share of capital DELTA = SI * (1/BETTA-1)/ (SK-SI); NU = (1-1/MARKUP)/ ((BETTA * THETA_D * (RHO-1) + 1 - BETTA * RHO)/ (1-BETTA*RHO)); NUG = (1-1/MARKUP)/ ((BETTA * THETA_G * (RHO-1) + 1 - BETTA * RHO)/ (1-BETTA*RHO)); %Lagrange multiplier on aggregate demand faced by monopolist i U = 1/BETTA-1+DELTA; %rental rate of capital K = (SI/DELTA/MARKUP)^(1/(1-ALFA))*H; %Steady state capital stock OUTPUT = K^ALFA * H^(1-ALFA) / MARKUP; %output W = U * (1-ALFA)/ALFA *K/H; %Wage rate IVV = DELTA * K; %Investment PHI = K^ALFA * H^(1-ALFA) - OUTPUT; %Fixed cost C = SC * OUTPUT; %consumption S = C; %Stock of habit XX = C - THETA_S * S; %Habit-adjusted consumption CHI = (1-H)/H / EHW; GAMA = W * (1-H)^CHI / XX^(SIGMA); V =1; %Steady-State value of preference shock VV =0; %Steady-State value of additive preference shock A = 1; %steady-state value of technology shock G = SG * OUTPUT; %Government consumption GBAR=G; %Unconditional mean of gov't consumption STOCKG = G; %Log values nu=log(NU); nug=log(NUG); w=log(W); h=log(H); c=log(C); s=log(S); u=log(U); k=log(K); ivv=log(IVV); markup=log(MARKUP); a=log(A); g = log(G); stockg=g; output = log(OUTPUT); xx = log(XX); v=log(V); vv=VV; %Future values of logged variables nup=log(NU); nugp=log(NUG); wp=log(W); hp=log(H); cp=log(C); sp=log(S); up=log(U); kp=log(K); ivvp=log(IVV); markupp=log(MARKUP); ap=log(A); gp = log(G); stockgp=g; outputp = log(OUTPUT); xxp = log(XX); vp=log(V); vvp=VV;