reverse-shooting

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

convfreq.m (698B)


      1 % convfreq.m   y=convfreq(x,nobs,meth)
      2 %
      3 %    Converts the frequency of a series (matrix) x:
      4 %         quarterly -> annual:  nobs=4
      5 %         monthly   -> quarterly:  nobs=3
      6 %         monthly   -> annual:  nobs=12
      7 %
      8 %    meth=='geom' for geometric average instead of arithmetic average.
      9 %
     10 %    Assumes that the first observations is first quarter or month.
     11 
     12 function y=convfreq(x,nobs,meth);
     13 
     14 [T N]=size(x);
     15 if exist('meth')~=1;
     16   meth='arith';
     17 end;
     18 
     19 Tnew=floor(T/nobs);
     20 y=zeros(Tnew,N);
     21 
     22 for i=1:Tnew; 		% We'll ignore stragglers at end
     23   start=(i-1)*nobs+1;
     24   fin  = start+nobs-1;
     25   if meth(1)=='g';
     26     y(i,:)=exp(mean(log(x(start:fin,:))));
     27   else;
     28     y(i,:)=mean(x(start:fin,:));
     29   end;
     30 end;