clear all
clc
d=dataread1;
data=d(:,[5 4 3]);
 
 
time=data(:,1)/12;
delta=data(:,2);
lesi=data(:,3);

lesi(lesi<3)=zeros(length(lesi(lesi<3)),1);
lesi(lesi>2)=ones(length(lesi(lesi>2)),1);

para0=[0.51 0.51 0.51 1.5];

options = optimset('MaxFunEvals',208888,'MaxIter',208888,'TolFun',1.e-9,'TolX',1.e-9);

[para1, fval1]=fminsearch(@h1testraw,para0,options, time, delta, lesi); 

para02=[.63 .54 1.81];

options = optimset('MaxFunEvals',208888,'MaxIter',208888,'TolFun',1.e-9,'TolX',1.e-9);

% [para0, fval0]=fminsearch(@h0test,para02,options, time, delta); 
% 
% lr=2*(fval0-fval1)
% pval=chi2pdf(lr,1)
% %save('h0.txt', 'para', 'fval1', '-ASCII');
% para =
% 
%     0.6354    0.7275    0.5389    1.7989
% 
 % fval1 =
% 
%   163.2382

curerate1=1/(1+exp(para1(1)))

curerate2=1/(1+exp(para1(1)+para1(2)))