%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ordered Probit a la Poirier & Tobias Book chapter
% i.e. re-parameterized a la Nandram & Chen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

rand('state',37); % set arbitrary seed for uniform draws
randn('state',37); % set arbitrary seed for normal draws

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

n=1000; % number of observations

bet=[-1 2 0.8]';
X=[ones(n,1) 2.5+2*randn(n,1) 0.5+1.3*randn(n,1)];
ystar=X*bet+randn(n,1); %tag on 0/1 normal error

% min(y)% approx -11
% max(y)% approx 20

% define cutpoints (Let's do 3, so we'll get 5 bins)
c1=2.8;
c2=5;
c3=7.8;

y=zeros(n,1);

f0=find(ystar<=0);
f1=find(ystar>0 & ystar<=c1);
f2=find(ystar>c1 & ystar<=c2);
f3=find(ystar>c2 & ystar<=c3);
f4=find(ystar>c3);

y(f0)=1;
y(f1)=2;
y(f2)=3;
y(f3)=4;
y(f4)=5;

l0=length(f0);
l1=length(f1);
l2=length(f2);
l3=length(f3);
l4=length(f4);

test=[l0;l1;l2;l3;l4] %make sure we have enough obs's in each bin
% stick with 156 / 194 /198 / 241 / 211

save c:\klaus\aaec6564\mlab\worksp\OP_data;
