Professional Documents
Culture Documents
Survival Analysis Practicals
Survival Analysis Practicals
DEPARTMENT OF STATISTICS
Course: M.Sc. Statistics(II)
Practical based ST-404(B) Survival Analysis
Que 1] The following are the time in days between successive serious earthquakes worldwide. An
earthquake is included in the data set if its magnitude was at least 7.5 on Richter scale, or if over
1000 people were killed. Recording starts on 16-th of December 1902 and ends on 14-th March
1997. There were 63 earthquakes recorded altogether, and so 62 waiting times.
840,157,145,44, 33,121,150,280, 434, 736, 584, 887, 263,1901, 695, 294, 562,
721, 76, 710, 46, 402, 194, 759,319, 460, 40,1336, 335, 1334, 454, 36, 667,
40, 556, 99, 304, 375, 567, 139, 780, 203, 436, 30, 384, 129, 9, 209, 599, 83,
832, 328, 246, 1617, 638, 937, 735, 38, 365, 92, 82, 220
Assume that the earthquakes occur at random and hence waiting times are exponentially
distributed. Obtain
R Code:
294, 562, 721, 76, 710, 46, 402, 194, 759,319, 460, 40,1336,335, 1334,
454, 36, 667, 40, 556, 99, 304, 375, 567, 139, 780, 203,436, 30, 384, 129,
9, 209, 599, 83, 832, 328, 246, 1617, 638,937, 735, 38, 365, 92, 82, 220)
#[1] 62
estlam
#[1] 0.002288921
LCL
#[1] 0.001754903
UCL<-estlam*2*qgamma(.975,shape=n)/(2*n) # Upper confidence limit (UCL).
UCL
#[1] 0.002892792
#We use graphical method to check exponentiality . We plot empirical and estimated survival curves
on the same graph paper. If the two curves are close then the model is appropriate.
d<-c(rep(1,62))
cd<-cumsum(d)
t<-sort(t)
legend (locator (1), legend = c ("empirical", "estimated exponential", pch = 1:2, cex = 0.7)
Suppose 20 items from an exponential distribution are put on life test and observed for 150 hrs.
During the period 15 item fail with the following life times, measured in hrs: 3, 19, 23, 26, 27, 37, 38,
41, 45, 58, 84, 90, 99, 109, 138. Test the hypothesis Ho : — 65 against H\ : \x > 65 at 2.5% level of
significance.
[1]15
t0<-150
p0
[1]0.9005094
estmu
[1]105.8
[1]0.025
qnorm((1-alpha1))
[1] 1.959964
u0<-(estmu - mu0)/mu0
u0
[1]0.6276923
nz0<-u0*(n*p0)^.5
nz0
[1]2.663826
dz1<-2*u0*(1-p0)*log(1-p0)/p0
dz1
[1] - 0.3200725
dz2<-(1-p0)*u0 ^2
dz2
[1]0.03919905
z0
[1]2.284824
#Conclusion - ZQ > 2i_Q.. Therefore Ho is rejected and we conclude that the average life is greater
than 65 hours.
time<-c(142,149,320,345,560,805,1130,1720,2480,4210,5230,6890);
length(time);
status=c(1,1,1,0,1,1,0,1,0,0,1,1);
length(status);
#[I] 12
attach(ctrl);
library (survival);
km.ctrl< — survfit(Surv(time,status==1));
library (survival)
time=c(17.88,28.92,33.0,41.52,42.12,45.60,48.48,51.84,51.96,54.12,55.56,67.80,68.64,68.64,68.88,8
4.12,93.12,98.64,105.12,105.84,127.92,128.04,173.4)
length(time)
#[1] 23
length(status)
#[1] 23
ball= data.frame(time,status)
attach(ball)
km.ball= survfit(Surv(time,status))