reverse-shooting

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

stdev.m (657B)


      1 %stdev.m
      2 % calculates cross sectional standard deviations
      3 % data = TxN matrix
      4 %
      5 % Also return 90% confidence interval following Greene S4.6, p121ff
      6 %
      7 % CI = (s*sqrt((n-1)/upper, s*sqrt((n-1)/lower))
      8 % 	where upper and lower are the critical values from a ChiSquare
      9 %	with n-1 dof so that 10% of the weight is in the tails.
     10 %	(For this version, 5% is lower tail and 5% is upper tail).
     11 
     12 function [std,cilow,ciupp]=stdev(data);
     13 
     14 	[T N]=size(data);
     15 	lower=invchicdf(.05,N-1)
     16 	upper=invchicdf(.95,N-1)
     17 
     18 	if ~isempty(data);
     19 		x =demean(data');
     20 		vcv=1/(N-1)*x'*x;
     21 		std=sqrt(diag(vcv));
     22 		cilow=std*sqrt((N-1)/upper);
     23 		ciupp=std*sqrt((N-1)/lower);
     24 	end;
     25 
     26 
     27 
     28 
     29 
     30 
     31 
     32