function likeli=h1test(para,data1,data2,data3,data4,realsur,realden)

a   =para(1);
b   =para(2);

lamda =para(3);
gamma =para(4);

% old function
% pi=1./(1+exp(a+b.*lesi));
% likeli=sum((1-delta).*log(pi+(1-pi).*exp(-(lamda.*time).^gamma))...
%     +(delta).*(log(1-pi)+log(lamda.*gamma)+(gamma-1).*log(lamda.*time)-(lamda.*time).^gamma));
% 
%   likeli=(-1)*likeli +(a<0)*1e10+(b<0)*1e10+(lamda<0)*1e10+(gamma<0)*1e10;
% 
%diseased and died



l1=(1-1./(1+exp(a+b*data1(:,3)))) ...
       .*exp(-(lamda*data1(:,5)).^gamma).*(lamda*gamma*(lamda*data1(:,5)).^(gamma-1));

 logl1=sum(log(l1(l1~=0)));
%diseased but live (censored)

l2=(1-1./(1+exp(a+b*data2(:,3)))) ...
       .*exp(-(lamda*data2(:,5)).^gamma);

 logl2=sum(log(l2(l2~=0)));
   
%not diseased but died 
  
p3=(1./(1+exp(a+b *data3(:,3)')))';
 
l3=p3.*(realden)+(1-p3)*lamda*gamma.*(lamda*data3(:,5)).^(gamma-1).*exp(-(lamda*data3(:,5)).^gamma);

logl3=sum(log(l3(l3~=0)));
%not diseased and live (censored)
  

p4=(1./(1+exp(a+b.*data4(:,3)')))';
l4=p4.*realsur+(1-p4).*exp(-(lamda*data4(:,5)).^gamma);

logl4=sum(log(l4(l4~=0)));


likeli=logl1+logl2+logl3+logl4
 

likeli=(-1)*likeli+(a<0)*1e10+(b<0)*1e10+(lamda<0)*1e10+(gamma<0)*1e10;