% Example of the iid case



% define vectors of different values of beta amnd gamma



beta=0.95 ;    

gamm=4 ;  



% set the parameters of the law of motion of consumption growth



mu=0.02 ;

rho=0 ;

sig=0.15 ; % notice that for small sig, approximation is close



% load the quadrature data and choose the relevant submatrix

% of data for the number of quadrature points



nqp=4 ; % number of quadrature points to use ( must be <= 10 )



load ghquad.dat ;

ymat=ghquad(0.5*(nqp-1)*nqp+1:0.5*nqp*(nqp+1),2) ;

wmat=ghquad(0.5*(nqp-1)*nqp+1:0.5*nqp*(nqp+1),3) ;



% ymat is the vector of abscissas (points)

% wmat is the vector of weights



% Now transform the abscissas given the law of motion



ymat=mu+ymat*sig ;



% generate the transition matrix



pim=gettrans(ymat,wmat,mu,rho,sig) ; % calls external m file



% get solution for price-dividend ratio



pdr=getprice(ymat,pim,beta,gamm) 



% get exact solution



px=beta*exp((1-gamm)*mu+0.5*(1-gamm)^2*sig^2) ;

pdrex=px/(1-px) 