% something to compare ch3_ex1b and ch3_ex1c to

% define the law of motion parameters

mu=0.0179 ;
rho=-0.139 ;
sigma=0.0348 ;

ss=10001 ;

% simulate consumption (dividend) growth

x=normar1(mu,rho,sigma,ss) ;

% choose the values of beta and gamma

b=0.99 ;
g=2.0 ;


% solve steady state conditions
% a trap must be built in to catch inadmissable pairs of beta and gamma

if (b*exp((1-g)*mu)) < 1,

 vt=log(b)+(1-g)*mu-log(1-b*exp((1-g)*mu)) ;
 qt=log(b)-g*mu ;
 m=exp(log(b)+(1-g)*mu) ;

 % compute simulated prices

 v=exp(vt+(1-g)*rho*(x-mu)/(1-m*rho)) ;
 q=exp(qt-g*rho*(x-mu)) ;

 % compute rates of return

 re=(v(2:ss,1)+1).*exp(x(2:ss,1))./v(1:ss-1,1)-1 ;
 rf=ones(ss-1,1)./q(1:ss-1,1)-1 ;

 % compute and store the averages

 rfr=mean(rf)
 epr=mean(re-rf)
 srf=std(rf)
 sep=std(re-rf)

end ;
