%tongue.m
close all 
clear all
load 'C:\STAT\Survival\Survivaldat\tongue.dat'
type = tongue(:,1)-1;
time = tongue(:,2);
censor = tongue(:,3);
t0= time(type==0); ce0=censor(type==0);
[table0]=ple(t0, ce0)
hold on
t1= time(type==1); ce1=censor(type==1);
[table1]=ple(t1, ce1)
hold off

%%
tA= time(type ==0);
tB= time(type ==1);

cA= censor(type ==0);
cB= censor(type ==1);
      [pval chi2]=manteltwo(tA,  cA,  tB, cB)

% pval =
% 
%     0.0975
% 
% 
% chi2 =
% 
%     2.7464
%%
    [b,logl,H,stats] = coxphfit(type,time,...
    'censoring',censor);
stats
%
%     covb: 0.0787
%     beta: 0.4610
%       se: 0.2805
%        z: 1.6431
%  
%        p: 0.1004
[stats.beta - norminv(0.975)*stats.se  stats.beta + norminv(0.975)*stats.se]
%  -0.0889    1.0108

figure(1)
stairs(H(:,1),H(:,2))
hold on
stairs(H(:,1),exp(0.4610)*H(:,2),'r-')

figure(2)
stairs(H(1:length(H(:,1))-1,1),diff(H(:,2)))
hold on
stairs(H(1:length(H(:,1))-1,1),diff(exp(0.4610)*H(:,2)),'r-')

