reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

growthrate3.m (635B)


      1 function [gr,se]=growthrate3(x,yrs);
      2 
      3 % growthrate3.m  -- Slope on time trends
      4 %
      5 %  yrs=[1 10;
      6 %       1 5;
      7 %	6 10];
      8 %
      9 %  x=TxN vector  ==> compute the average growth rate of x over the yrs periods.
     10 %
     11 %  se is the standard error of the growth rate
     12 
     13 gr=zeros(size(yrs,1),size(x,2));
     14 se=gr;
     15 for i=1:size(yrs,1);
     16   y=x(yrs(i,1):yrs(i,2));
     17   [gg,ss]=lsgrowth(y);
     18   gr(i)=gg;
     19   se(i)=ss;
     20 end;
     21 
     22 function [g,gse] = lsgrowth(y);
     23 
     24 y=log(y);
     25 T=length(y);
     26 x=[ones(T,1) (1:T)'];
     27 K=2;
     28 xxinv = inv(x'*x);
     29 beta  = xxinv*x'*y;
     30 u     = y-x*beta;
     31 sigma2=u'*u/(T-K);
     32 stdest=sqrt(sigma2);
     33 vcv   =sigma2*xxinv;
     34 se    =sqrt(diag(vcv));
     35 g=beta(2);
     36 gse=se(2);