%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PPP value for skewness in earnings data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rand('state',37); % set arbitrary seed for uniform draws
randn('state',37); % set arbitrary seed for normal draws
tic; % start stop watch
[fid]=fopen('c:\klaus\AAEC6564\mlab\logs\ppp.txt','w');
if fid==-1;
warning('File could not be opened');
return
else;
disp('File opened successfully');
end;
% load data posterior results for female earnings regression
load c:\klaus\AAEC6564\mlab\worksp\mod2application;
R=size(betamat,2); %number of draws from the GS
n=length(y);
k=size(X,2);
sk_y=zeros(R,1);
sk_ystar=zeros(R,1);
for r=1:R % start main loop
br=betamat(:,r);
sig2r=sig2mat(r);
%compute sk for actual data:
sk_y(r)=sqrt(n)*sum((y-X*br).^3)./(sum((y-X*br).^2)^(3/2));
% draw simulated data:
ystar=normrnd(X*br,sqrt(sig2r));
%this generates N by 1 draws of yi, each corresponding to its respective xi
%compute sk for simulated data
sk_ystar(r)=sqrt(n)*sum((ystar-X*br).^3)./(sum((ystar-X*br).^2)^(3/2));
end
% Compute PPP
%%%%%%%%%%%%%%%%%%%%%%%%
f=find(sk_ystar