%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Data for sample selection model
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rand('state',37); % set arbitrary seed for uniform draws
randn('state',37); % set arbitrary seed for normal draws
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
n=1000; %sample size
m=2; % number of correlated equations
Etrue=[1 0.75;0.75 1.8]; %error varcov, with a "healthy" covariance term
mu=zeros(m,1); % error mean
beta1true=[1 -1.5]'; %coefficients for selection equation
beta2true=[1.8 0.5]';%coefficients for outcome equation
X1=[ones(n,1) 0.5+1.3*randn(n,1)];
X2=[ones(n,1) 4+2*randn(n,1)];
e=mvnrnd(mu,Etrue,n); % will be n by 2
%latent variables
y1=X1*beta1true+e(:,1);
y2=X2*beta2true+e(:,2);
f=find(y1<0);
fi=length(f)/n % stop at 24%censoring
save c:\klaus\AAEC6564\mlab\worksp\select_data;