function [L] = logl_ssbias(b)
% The following is the incorrect loglikelihood function for a probit model
% with sample selectivity.

global x y z N

b0 = b(1);
b1 = b(2);
sigma = b(3);

XB = b0*ones(size(x,1),1) + b1*x ;

L=0 ;

for i = 1:N
    if z(i) == 1
      L = L - 0.5*log(2*pi) - 0.5*log(sigma^2) ...
                                        - 0.5*(((y(i) - XB(i))^2/sigma^2));
    elseif z(i) == 0
      L = L + 0;
    end
end

L = -L;

end

