clear all
close all

%
% Banerjee, S. and Carlin, B. P. (2004). 
% Parametric spatial cure rate models for interval-censored 
% time-to-relapse data. Biometrics 60, 268--275. 
% 
% 
% model {
% for (i in 1:N)
%                {
%               RelapseT[i] ~ dlogis(mu[i],tau) I(censored.time[i],)
%               mu[i]  <-  beta[1] + beta[2] * Age[i] + beta[3] * AgeStart[i] +
%                 beta[4] * SexF[i] + beta[5] * SIUC[i] + beta[6] * F10Cigs[i] 
%                }
% for( j in 1:6){
% beta[j] ~ dnorm(0, 0.01)	
%                      }
% tau ~ dgamma(1,0.01)
% meanT <- mean(mu[])
% sigma <- 1.8138/tau     #1.8138 ~ pi/sqrt(3) 
% 
% 
% 
% Ag <- 50; AgSt <- 18; SxF <- 0; S <- 1; Cigs <- 20;
% fmu   <-  beta[1] + beta[2] * Ag  + beta[3] * AgSt +
%                 beta[4] * SxF  + beta[5] * S   + beta[6] *  Cigs 
% for(i in 1:100) {
%      time[i]  <-  i/10
%      Surv[i] <- 1/(1 + exp(tau*(time[i] - fmu)))
%      }
% }
%-------------------------------------
% Surv[i] (mean, std, quantile0.025, median, quantile0.975) is saved as
% file 'C:\Springer\Survival\Survivaldat\smokingoutbugs.mat'
%


 disp('Survival Function from WinBUGS')
 lw = 3; 
 set(0, 'DefaultAxesFontSize', 16);
 fs = 15;
 msize = 10;


load 'C:\Springer\Survival\Survivaldat\smokingoutbugs.mat'
figure(1)
plot(smokingoutbugs.x, smokingoutbugs.means,'r-','LineWidth',2)
hold on
plot(smokingoutbugs.x, smokingoutbugs.post025,'g--','LineWidth',2)
plot(smokingoutbugs.x, smokingoutbugs.post975,'g--','LineWidth',2)
errorbar(smokingoutbugs.x, smokingoutbugs.means, smokingoutbugs.std)
axis tight
xlabel('Time'); ylabel('$\hat S(t)$','Interpreter','LaTeX')

print -depsc 'C:\Springer\Survival\Survivaleps\smokingbugs.eps'


