%By David Love, Yale, using original code by Hugo Benitez-Silva, Summer 2001. %Modified by Hugo Benitez-Silva, September 2001-March 2009. %This program has the setup and the main program in one set of code. setupandbicrra1.m %Setup contains some basic definitions and parameter values for the lifecycle problem tt=60; %Number of finite time periods periods=tt+1; simu=500; global vf i wgrid mu_r sig_r ar_r qa qw lnmu lnsig lnmx u1 ddelta bq gama beta intmeth wmax lntden unquad rp periods itt sut; beta=.98; %Discount factor bq=.1; %Bequest factor gama=1.5; %CRRA parameter ar_r=0; %Autoregressive parameter for lognormal AR(1) lnparametersh=@lnparameters; [mu_r,sig_r]=feval(lnparametersh,(1/beta),.3); mu_r=mu_r*(1-ar_r); sig_r=sig_r*(1-ar_r^2); wn=100; %Number of grid point on w axis (0 is the (log(rmax)-rm)/rs1st grid point). nrint=50; %Number of sample points used in expected value calculations. nqint=10; %Number of quadrature abscissa for expected value. wsp=1.3; %Determines degree of nonuniformity in spacing of w axis. %grid points: wsp=1 gives uniformly spaced points, wsp>1. %gives closer spacing near 0 and wider spacing as q increases. rmax=5; %Upper bound of truncated lognormal density for returns. rmin=0; %Lower bound of truncated lognormal density for returns. macheps=1e-16; %Tolerance for equality comparisons. wmax=200000; %Upper bound for wealth. wmin=1e-5; %Lower bound for wealth told=1e-16; %Tolerance for equality comparisons. btol=1e-2; %Tolerance for equality comparisons.feval(dufunc1h,cnew)+beta*(1-sut(periods-itt))*feval(dev_qw_myh,w,cnew)-sut(periods-itt)*bq*feval(dufunc1h,a) ddelta=1e-7; %Difference qoutient for numerical derivatives using superaccurate %central differences. Optimal values taken from table on p. 186 %from Rice, 1983, Numerical Methods, Software and Analysis, McGraw Hill. if (wmin