SURVIVAL ANALYSIS

Draft1: Final Rpubs publication will be released on 15.08.205

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(asaur)
data("gastricXelox")
summary(gastricXelox)
##    timeWeeks          delta       
##  Min.   :  4.00   Min.   :0.0000  
##  1st Qu.: 18.50   1st Qu.:0.0000  
##  Median : 43.00   Median :1.0000  
##  Mean   : 59.71   Mean   :0.6667  
##  3rd Qu.: 64.50   3rd Qu.:1.0000  
##  Max.   :253.00   Max.   :1.0000
library(survival)
attach(gastricXelox)
Surv(gastricXelox$timeWeeks,gastricXelox$delta)
##  [1]   4    8    8    8    9   11   12   13   16   16   17   17   19   21   24 
## [16]  24   25   28   28   30   37   37   42   43   43+  46   48+  50+  51+  53 
## [31]  54+  57+  59+  59   60   64   66   76   78   91+ 119+ 120+ 139+ 176+ 187+
## [46] 203+ 217+ 253+
KM1=survfit(Surv(gastricXelox$timeWeeks,gastricXelox$delta)~1,conf.type="log-log")
par(mfrow=c(1,2))
plot(KM1,,main="KM Prod.limit estimator S(t) curve")
summary(KM1)
## Call: survfit(formula = Surv(gastricXelox$timeWeeks, gastricXelox$delta) ~ 
##     1, conf.type = "log-log")
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     4     48       1    0.979  0.0206        0.861        0.997
##     8     47       3    0.917  0.0399        0.793        0.968
##     9     44       1    0.896  0.0441        0.768        0.955
##    11     43       1    0.875  0.0477        0.743        0.942
##    12     42       1    0.854  0.0509        0.718        0.928
##    13     41       1    0.833  0.0538        0.694        0.913
##    16     40       2    0.792  0.0586        0.647        0.882
##    17     38       2    0.750  0.0625        0.602        0.850
##    19     36       1    0.729  0.0641        0.580        0.833
##    21     35       1    0.708  0.0656        0.558        0.816
##    24     34       2    0.667  0.0680        0.515        0.781
##    25     32       1    0.646  0.0690        0.494        0.763
##    28     31       2    0.604  0.0706        0.452        0.726
##    30     29       1    0.583  0.0712        0.432        0.708
##    37     28       2    0.542  0.0719        0.392        0.670
##    42     26       1    0.521  0.0721        0.372        0.650
##    43     25       1    0.500  0.0722        0.353        0.631
##    46     23       1    0.478  0.0722        0.332        0.610
##    53     19       1    0.453  0.0727        0.308        0.587
##    59     16       1    0.425  0.0735        0.280        0.562
##    60     14       1    0.394  0.0742        0.251        0.535
##    64     13       1    0.364  0.0744        0.223        0.507
##    66     12       1    0.334  0.0742        0.196        0.478
##    76     11       1    0.303  0.0734        0.170        0.449
##    78     10       1    0.273  0.0720        0.145        0.418
AA1=survfit(Surv(gastricXelox$timeWeeks,gastricXelox$delta)~1,,conf.type="log-log",type="fh")
summary(AA1)
## Call: survfit(formula = Surv(gastricXelox$timeWeeks, gastricXelox$delta) ~ 
##     1, conf.type = "log-log", type = "fh")
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     4     48       1    0.979  0.0204        0.863        0.997
##     8     47       3    0.918  0.0395        0.795        0.968
##     9     44       1    0.897  0.0437        0.770        0.956
##    11     43       1    0.876  0.0473        0.745        0.942
##    12     42       1    0.856  0.0505        0.721        0.928
##    13     41       1    0.835  0.0533        0.697        0.914
##    16     40       2    0.794  0.0581        0.651        0.883
##    17     38       2    0.753  0.0620        0.606        0.851
##    19     36       1    0.732  0.0636        0.584        0.835
##    21     35       1    0.711  0.0651        0.562        0.818
##    24     34       2    0.670  0.0675        0.519        0.783
##    25     32       1    0.650  0.0685        0.498        0.765
##    28     31       2    0.608  0.0701        0.457        0.729
##    30     29       1    0.588  0.0707        0.437        0.711
##    37     28       2    0.546  0.0715        0.397        0.673
##    42     26       1    0.526  0.0717        0.377        0.654
##    43     25       1    0.505  0.0718        0.358        0.635
##    46     23       1    0.484  0.0719        0.338        0.615
##    53     19       1    0.459  0.0723        0.314        0.592
##    59     16       1    0.431  0.0731        0.287        0.567
##    60     14       1    0.401  0.0739        0.258        0.541
##    64     13       1    0.372  0.0741        0.230        0.513
##    66     12       1    0.342  0.0739        0.203        0.485
##    76     11       1    0.312  0.0732        0.178        0.456
##    78     10       1    0.283  0.0720        0.153        0.427
plot(AA1,col=3,main="KM in Aaren estimator S(t) curve")

KM=KM1
## Including Plots

Hazard calculation via KM , N-A estimator

The hazard calculation and use for statistics is seldom used or bypassed due to his diffucltyin mathematical and physical concept.

One should understand that h(t) is an ISNTANTANEOUS Failure (Rate) give you (the prob) survived until then.

It can defined by eseveral formulas or estimator but one shoul recall that it is a limit in time one should specified it.

As its is minus(for Calculus convention) the derivative of the survivor function / by the Survivor function i s part the the differential equation that explain you why transcendental exponential function is everywhere with log.

If one should have a physical comparison take the instantaneous velocity When delta time come close to zero you find an acceleration ” a change in speed [ of speed] in time “speedometer” or accelero-meter always give you spikes of inst speed, teh hazard to (see graph below) .

There is one major difference in this physical concept Compare to speed hazard cannot take negative value There is no negative value hazard His value range from zero to infinity and with our daily life we surely understand this concept although a null hazard too is dubtfull but let accept it theora<tically

Therefore when we plot hazard function is is a wiggly pattern and spikes jumping from zero to his value when event id occurs.The problem with Survival time is continuous and event are integer points in time it doesn’t mean that the hazard is null in between This paradoxical view of theory and pattern presented in Survival analysis amake the statistician SCARED to exploit it.

Let review and trial some of the basic calculation and concepts:

Hazard can never be nul

Survivor functionm extend form 0 to infiny and in theory limS(t)infinity = 0

KM1$n.event
##  [1] 1 3 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0
## [39] 0
KM1$n.risk
##  [1] 48 47 44 43 42 41 40 38 36 35 34 32 31 29 28 26 25 23 22 21 20 19 18 17 16
## [26] 14 13 12 11 10  9  8  7  6  5  4  3  2  1
ht=KM1$n.event/KM1$n.risk
ht
##  [1] 0.02083333 0.06382979 0.02272727 0.02325581 0.02380952 0.02439024
##  [7] 0.05000000 0.05263158 0.02777778 0.02857143 0.05882353 0.03125000
## [13] 0.06451613 0.03448276 0.07142857 0.03846154 0.04000000 0.04347826
## [19] 0.00000000 0.00000000 0.00000000 0.05263158 0.00000000 0.00000000
## [25] 0.06250000 0.07142857 0.07692308 0.08333333 0.09090909 0.10000000
## [31] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [37] 0.00000000 0.00000000 0.00000000
plot(ht,type="s",main="hazard from Kaplan-M d(i)/n(i)",lwd=2)

plot(cumsum(ht),type="s",main="cum Hazard H(t) from Kaplan-M sum[d(i)/n(i)]",lwd=2)

#why is above 1 weel due to his definition hard is aprob divded by time
plot(AA1$n.event/AA1$n.risk,type="s",main="hazard from AAREN-Est d(i)/n(i)",lwd=2,col=3)

Hazard with timeframe:

As it is a limit of a conditional prob in time/delta time therefore h(t) must be accommodate with time too.. Misunderstanding of hazard function and scale com from this specification: It like talking about a Poisson parameter always refer to a constant interval: by exponential density function accommodate time .i. e Poisson E[mean] parameter = 𝜆 vs exponential E[mean] is 1 / 𝜆.

see the KM extract $event: When there is a real censoring + the count is a null but it is recorded in the hazard frame when you sak for it It souldn’t in fact according our point of view.

To have an estimate of a mean they are several way:

1: Tmedian = ln2 / 𝜆.

#1
KM1
## Call: survfit(formula = Surv(gastricXelox$timeWeeks, gastricXelox$delta) ~ 
##     1, conf.type = "log-log")
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 48     32   44.5      25      66
log(2)/44.5
## [1] 0.01557634
0.0155 #persMonths rate
## [1] 0.0155
meanTime=1/0.0155
meanTime
## [1] 64.51613

Therefor an expectation of TIME [T] is given by the Integral from zero to infinity of S(T) It can anatically be demonstrated to be 1/lamda which is reported to be 64.51 Months which is biasedThe integral can be calculated top the bound from 0 to 253 Months:

exp(-(0.0655*253))
## [1] 6.354611e-08

2: Or by hand with[a] and without [b] the null censoring point

#2.a
ht=KM1$n.event/KM1$n.risk
ht
##  [1] 0.02083333 0.06382979 0.02272727 0.02325581 0.02380952 0.02439024
##  [7] 0.05000000 0.05263158 0.02777778 0.02857143 0.05882353 0.03125000
## [13] 0.06451613 0.03448276 0.07142857 0.03846154 0.04000000 0.04347826
## [19] 0.00000000 0.00000000 0.00000000 0.05263158 0.00000000 0.00000000
## [25] 0.06250000 0.07142857 0.07692308 0.08333333 0.09090909 0.10000000
## [31] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [37] 0.00000000 0.00000000 0.00000000
mean(ht)
## [1] 0.03225624
#2.b
KM1b=KM1
KM1b
## Call: survfit(formula = Surv(gastricXelox$timeWeeks, gastricXelox$delta) ~ 
##     1, conf.type = "log-log")
## 
##       n events median 0.95LCL 0.95UCL
## [1,] 48     32   44.5      25      66
KM1b=KM1$n.event>0
KM1b
##  [1]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
## [13]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE
## [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
## [37] FALSE FALSE FALSE
KM1$n.event[KM1b]
##  [1] 1 3 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1
KM1$n.risk[KM1b]
##  [1] 48 47 44 43 42 41 40 38 36 35 34 32 31 29 28 26 25 23 19 16 14 13 12 11 10
htb=KM1$n.event[KM1b]/KM1$n.risk[KM1b]
htb
##  [1] 0.02083333 0.06382979 0.02272727 0.02325581 0.02380952 0.02439024
##  [7] 0.05000000 0.05263158 0.02777778 0.02857143 0.05882353 0.03125000
## [13] 0.06451613 0.03448276 0.07142857 0.03846154 0.04000000 0.04347826
## [19] 0.05263158 0.06250000 0.07142857 0.07692308 0.08333333 0.09090909
## [25] 0.10000000
plot(htb,type="s")

mean(htb)
## [1] 0.05031973

Hazard from slope We know that lamda*t is integrale but lamda t is a lines with a slope Let see his coefficients in 253 MOnths:

length(htb)
## [1] 25
253/25
## [1] 10.12
tt=seq(from=1,to=253,by=10.12)
tt
##  [1]   1.00  11.12  21.24  31.36  41.48  51.60  61.72  71.84  81.96  92.08
## [11] 102.20 112.32 122.44 132.56 142.68 152.80 162.92 173.04 183.16 193.28
## [21] 203.40 213.52 223.64 233.76 243.88
plot(htb~tt,type="s")
summary(lm(htb~tt-1))
## 
## Call:
## lm(formula = htb ~ tt - 1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.019552 -0.007902  0.005595  0.019457  0.059779 
## 
## Coefficients:
##     Estimate Std. Error t value Pr(>|t|)    
## tt 3.642e-04  2.711e-05   13.44 1.16e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01932 on 24 degrees of freedom
## Multiple R-squared:  0.8827, Adjusted R-squared:  0.8778 
## F-statistic: 180.5 on 1 and 24 DF,  p-value: 1.163e-12
abline(lm(htb~tt-1),col=2)

Notice than

ht=KM1$n.event/KM1$n.risk
mean(ht)
## [1] 0.03225624
mean(AA1$n.event/AA1$n.risk)#aa setim
## [1] 0.03225624
###time di/timepersM
htime=KM1$n.event/KM$time#hazard interval perstime
KM$time
##  [1]   4   8   9  11  12  13  16  17  19  21  24  25  28  30  37  42  43  46  48
## [20]  50  51  53  54  57  59  60  64  66  76  78  91 119 120 139 176 187 203 217
## [39] 253
plot(htime~KM1$time ,type="s")##wrong time is summed up

INTER=diff(KM1$time)
INTER
##  [1]  4  1  2  1  1  3  1  2  2  3  1  3  2  7  5  1  3  2  2  1  2  1  3  2  1
## [26]  4  2 10  2 13 28  1 19 37 11 16 14 36
length(INTER)
## [1] 38
length(KM1$n.event)
## [1] 39
KM1$n.event
##  [1] 1 3 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0
## [39] 0
plot(KM1$n.event[1:38]/INTER,type="s")

KM1$n.censor
##  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1
## [39] 1
KM1$n.event
##  [1] 1 3 1 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 0 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0
## [39] 0
1/48#check ok with handcalc
## [1] 0.02083333
3/47
## [1] 0.06382979
KM1$n.event/KM$n.risk#check ok with handcalc
##  [1] 0.02083333 0.06382979 0.02272727 0.02325581 0.02380952 0.02439024
##  [7] 0.05000000 0.05263158 0.02777778 0.02857143 0.05882353 0.03125000
## [13] 0.06451613 0.03448276 0.07142857 0.03846154 0.04000000 0.04347826
## [19] 0.00000000 0.00000000 0.00000000 0.05263158 0.00000000 0.00000000
## [25] 0.06250000 0.07142857 0.07692308 0.08333333 0.09090909 0.10000000
## [31] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [37] 0.00000000 0.00000000 0.00000000
plot(cumsum(KM1$n.event[1:38]/INTER),type="s")

plot(KM1$cumhaz,type="s")

library(muhaz)
## Warning: le package 'muhaz' a été compilé avec la version R 4.5.1
muhz=muhaz(gastricXelox$timeWeeks,gastricXelox$delta,bw.grid=3,max.time=100,b.cor = "none",bw.method="global",bw.smooth=20)
summary(muhz)
## 
## Number of Observations .......... 48
## Censored Observations ........... 16
## Method used ..................... Global
## Boundary Correction Type ........ None
## Kernel type ..................... Epanechnikov
## Minimum Time .................... 0
## Maximum Time .................... 100
## Number of minimization points ... 51
## Number of estimation points ..... 101
## Pilot Bandwidth ................. 6.25
## Smoothing Bandwidth ............. 20
## Optimal Global Bandwidth ........ 3
## Minimum IMSE .................... 0
plot(muhaz(gastricXelox$timeWeeks,gastricXelox$delta,bw.grid=3,max.time=100,b.cor = "none",bw.method="global",bw.smooth=20))

plot(muhz$haz.est~muhz$est.grid,type="s")

phaz=pehaz(gastricXelox$timeWeeks,gastricXelox$delta,width=4,max.time = 100)
## 
## max.time= 100
## width= 4
## nbins= 25
summary(phaz)
##          Length Class  Mode   
## call      5     -none- call   
## Width     1     -none- numeric
## Cuts     26     -none- numeric
## Hazard   25     -none- numeric
## Events   25     -none- numeric
## At.Risk  25     -none- numeric
## F.U.Time 25     -none- numeric
plot(pehaz(gastricXelox$timeWeeks,gastricXelox$delta,width=4,max.time = 100))
## 
## max.time= 100
## width= 4
## nbins= 25

plot(ht,type="s",main="hazard from Kaplan-M d(i)/n(i)",lwd=2)

plot(phaz$Hazard[1:25]~phaz$Cuts[1:25],type="s")

plot(ht,type="s",main="hazard from Kaplan-M d(i)/n(i)",lwd=2)

phaz$Cuts
##  [1]   0   4   8  12  16  20  24  28  32  36  40  44  48  52  56  60  64  68  72
## [20]  76  80  84  88  92  96 100
phaz$Hazard
##  [1] 0.000000000 0.005319149 0.029069767 0.012422360 0.034482759 0.007299270
##  [7] 0.024000000 0.026315789 0.000000000 0.018867925 0.020000000 0.011111111
## [13] 0.000000000 0.014084507 0.015873016 0.019230769 0.043478261 0.000000000
## [19] 0.000000000 0.052631579 0.000000000 0.000000000 0.000000000 0.000000000
## [25] 0.000000000
plot(phaz$Hazard[1:25]~KM1$time[1:25],type="s")

KM and S(T) from cum Hazard estimates

phaz=pehaz(gastricXelox$timeWeeks,gastricXelox$delta,width=1,max.time = 300)
## 
## max.time= 300
## width= 1
## nbins= 300
phaz$Hazard
##   [1] 0.00000000 0.00000000 0.00000000 0.00000000 0.02127660 0.00000000
##   [7] 0.00000000 0.00000000 0.06818182 0.02325581 0.00000000 0.02380952
##  [13] 0.02439024 0.02500000 0.00000000 0.00000000 0.05263158 0.05555556
##  [19] 0.00000000 0.02857143 0.00000000 0.02941176 0.00000000 0.00000000
##  [25] 0.06250000 0.03225806 0.00000000 0.00000000 0.06896552 0.00000000
##  [31] 0.03571429 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [37] 0.00000000 0.07692308 0.00000000 0.00000000 0.00000000 0.00000000
##  [43] 0.04000000 0.04347826 0.00000000 0.00000000 0.04545455 0.00000000
##  [49] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.05555556
##  [55] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.07142857
##  [61] 0.07692308 0.00000000 0.00000000 0.00000000 0.08333333 0.00000000
##  [67] 0.09090909 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [73] 0.00000000 0.00000000 0.00000000 0.00000000 0.10000000 0.00000000
##  [79] 0.11111111 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [85] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [91] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [97] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [103] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [109] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [115] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [121] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [127] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [133] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [139] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [145] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [151] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [157] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [163] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [169] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [175] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [181] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [187] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [193] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [199] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [205] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [211] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [217] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [223] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [229] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [235] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [241] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [247] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [253] 0.00000000        NaN        NaN        NaN        NaN        NaN
## [259]        NaN        NaN        NaN        NaN        NaN        NaN
## [265]        NaN        NaN        NaN        NaN        NaN        NaN
## [271]        NaN        NaN        NaN        NaN        NaN        NaN
## [277]        NaN        NaN        NaN        NaN        NaN        NaN
## [283]        NaN        NaN        NaN        NaN        NaN        NaN
## [289]        NaN        NaN        NaN        NaN        NaN        NaN
## [295]        NaN        NaN        NaN        NaN        NaN        NaN
HT=cumsum(phaz$Hazard)
plot(HT,type="s")

STH=exp(-HT)
phazsm=pehaz(gastricXelox$timeWeeks,gastricXelox$delta,width=2,max.time = 300)
## 
## max.time= 300
## width= 2
## nbins= 150
phazsm$Hazard
##   [1] 0.00000000 0.00000000 0.01063830 0.00000000 0.04597701 0.01176471
##   [7] 0.02469136 0.00000000 0.05405405 0.01408451 0.01449275 0.00000000
##  [13] 0.04761905 0.00000000 0.03448276 0.01785714 0.00000000 0.00000000
##  [19] 0.03703704 0.00000000 0.00000000 0.04166667 0.00000000 0.02272727
##  [25] 0.00000000 0.00000000 0.02702703 0.00000000 0.00000000 0.03333333
##  [31] 0.03846154 0.00000000 0.04166667 0.04545455 0.00000000 0.00000000
##  [37] 0.00000000 0.00000000 0.05000000 0.05555556 0.00000000 0.00000000
##  [43] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [49] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [55] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [61] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [67] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [73] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [79] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [85] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [91] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
##  [97] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [103] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [109] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [115] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [121] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
## [127] 0.00000000        NaN        NaN        NaN        NaN        NaN
## [133]        NaN        NaN        NaN        NaN        NaN        NaN
## [139]        NaN        NaN        NaN        NaN        NaN        NaN
## [145]        NaN        NaN        NaN        NaN        NaN        NaN
HTsm=cumsum(phazsm$Hazard)
plot(HTsm,type="s")

STsmH=exp(-HTsm)
plot(KM1)
lines(STH,col=2,lwd=1.4)
lines(STsmH,col=3,lty=1)
legend("topright",legend=c("KM","St unsmooth","St smooth 2months"),col=c(1,2,3),lty=c(1,1,1),cex=0.7)

S(T) Because teh calculus assume a functional form of Intergtaion usullay based by constant hazard leading by intergration to the exponential distribution the assumprion of constant hazard is of course doubtfull But we will see that in some case that is a good parameters approach to cvonstructz from hazard the Survivor Function.

Effect of “Cohort Thining” in time

Another problem arise due to thinning of person at risk at the end of the study : Sipke in hazard at the ends of study might be due to that effects if the cohort is not very large in sizeThe magnituide might be affetcted by this effect but clustering events in time in that range is a good indicator or relapse of events.

The exponential

mean(phaz$Hazard,na.rm=TRUE)
## [1] 0.005322683
1/0.005322#mean months E[is 1/lamda] when t tend to infinty
## [1] 187.8993
phaz$cuts#months bin wide=1
## NULL
plot(exp(-0.005322683*phaz$Cuts),type="l")