% PURPOSE: An example of using sac() on a small data set (eire.dat)
%                                    
% Assumes that eire.mat is in the workspace

% y = Blood_Group_A data;
% x = pale indicator variable
% W = (sparse) Cliff-Ord weight matrix

n = length(y);
X = [ones(n,1),x]; %add intercept to data

%Construct "names" vector

names = strvcat('Blood_Group','Constant','Pale');
          
% Do exact sem regression

info.pflag = 0; % 1=show optimization results
info.lflag = 0; % don't use Pace-Barry approximation for log-det term
res = sac(y,X,W,W,info);
% print the output with variable names
disp('results based on analytical hessian (with Tony corrections)');
prt(res,names);


info2.hess = 1;  % use numerical hessian to get variance-covariance
info2.lflag = 0; % don't use Pace-Barry approximation for log-det term
res1 = sac(y,X,W,W,info2);
% print the output with variable names
disp('results based on numerical hessian');
prt(res1,names);



