library(survival)
## Loading required package: splines
UNMissions=read.csv("UNMissions.csv")

1.

KM=survfit(Surv(Duration, 1-Censored)~1, conf.type='plain', data=UNMissions)
plot(KM, mark.time=F, conf.int=T)

plot of chunk unnamed-chunk-2

summary(KM)
## Call: survfit(formula = Surv(Duration, 1 - Censored) ~ 1, data = UNMissions, 
##     conf.type = "plain")
## 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     2     54       1    0.981  0.0183       0.9455        1.000
##     4     53       1    0.963  0.0257       0.9126        1.000
##     5     52       2    0.926  0.0356       0.8561        0.996
##     7     50       3    0.870  0.0457       0.7808        0.960
##    10     47       1    0.852  0.0483       0.7571        0.947
##    11     46       1    0.833  0.0507       0.7339        0.933
##    12     45       2    0.796  0.0548       0.6889        0.904
##    13     43       1    0.778  0.0566       0.6669        0.889
##    15     41       2    0.740  0.0598       0.6226        0.857
##    16     39       1    0.721  0.0612       0.6008        0.841
##    18     37       1    0.701  0.0626       0.5787        0.824
##    19     36       1    0.682  0.0638       0.5568        0.807
##    21     35       1    0.662  0.0649       0.5352        0.790
##    23     34       2    0.623  0.0667       0.4928        0.754
##    25     31       3    0.563  0.0687       0.4284        0.698
##    26     27       1    0.542  0.0693       0.4065        0.678
##    28     26       1    0.521  0.0697       0.3848        0.658
##    29     25       1    0.501  0.0699       0.3635        0.638
##    30     23       2    0.457  0.0703       0.3192        0.595
##    31     21       1    0.435  0.0702       0.2976        0.573
##    34     20       1    0.413  0.0700       0.2763        0.551
##    46     19       3    0.348  0.0684       0.2142        0.482
##    48     16       2    0.305  0.0664       0.1746        0.435
##    49     14       1    0.283  0.0651       0.1553        0.411
##    66     12       1    0.259  0.0638       0.1343        0.384
##    70     11       1    0.236  0.0622       0.1138        0.358
##   128      6       1    0.196  0.0630       0.0729        0.320

Our point estimate is 34 (value closest to 40 without going over), and our interval estimate is [0.22448, 0.4792].

  1. Our point estimate for the 25th percentile is 15 (where survival first drops below .75), and our interval estimate is [10, 21].

kmcivwar=survfit(Surv(Duration, 1-Censored)~CivilWar, conf.type='plain', data=UNMissions)
plot(kmcivwar, mark.time=F, conf.int=T, col=1:2)

plot of chunk unnamed-chunk-4

To find the confidence intervals:

summary(kmcivwar)
## Call: survfit(formula = Surv(Duration, 1 - Censored) ~ CivilWar, data = UNMissions, 
##     conf.type = "plain")
## 
##                 CivilWar=0 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     2     40       1    0.975  0.0247       0.9266        1.000
##     5     39       1    0.950  0.0345       0.8825        1.000
##     7     38       3    0.875  0.0523       0.7725        0.977
##    10     35       1    0.850  0.0565       0.7393        0.961
##    11     34       1    0.825  0.0601       0.7072        0.943
##    12     33       1    0.800  0.0632       0.6760        0.924
##    15     32       1    0.775  0.0660       0.6456        0.904
##    18     30       1    0.749  0.0687       0.6145        0.884
##    19     29       1    0.723  0.0710       0.5841        0.863
##    21     28       1    0.698  0.0730       0.5544        0.841
##    23     27       1    0.672  0.0748       0.5252        0.818
##    25     25       2    0.618  0.0778       0.4654        0.770
##    26     23       1    0.591  0.0789       0.4363        0.746
##    29     22       1    0.564  0.0798       0.4078        0.721
##    30     20       1    0.536  0.0806       0.3779        0.694
##    31     19       1    0.508  0.0812       0.3487        0.667
##    46     18       2    0.451  0.0814       0.2919        0.611
##    48     16       2    0.395  0.0804       0.2374        0.553
##    49     14       1    0.367  0.0794       0.2110        0.522
##    66     12       1    0.336  0.0785       0.1823        0.490
##    70     11       1    0.306  0.0771       0.1546        0.457
##   128      6       1    0.255  0.0793       0.0993        0.410
## 
##                 CivilWar=1 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     4     14       1   0.9286  0.0688       0.7937        1.000
##     5     13       1   0.8571  0.0935       0.6738        1.000
##    12     12       1   0.7857  0.1097       0.5708        1.000
##    13     11       1   0.7143  0.1207       0.4776        0.951
##    15      9       1   0.6349  0.1308       0.3785        0.891
##    16      8       1   0.5556  0.1364       0.2881        0.823
##    23      7       1   0.4762  0.1381       0.2055        0.747
##    25      6       1   0.3968  0.1360       0.1303        0.663
##    28      4       1   0.2976  0.1334       0.0362        0.559
##    30      3       1   0.1984  0.1203       0.0000        0.434
##    34      2       1   0.0992  0.0924       0.0000        0.280
##    46      1       1   0.0000     NaN          NaN          NaN

Our confidence interval for \(CivilWar=0\) is [0.4654, 0.770], and our interval for \(CivilWar=1\) is[0.1303, 0.663]. There is some overlap between the intervals, so there is not enough evidence to say that the true 25-month survival probabilities are different.

length(unique(UNMissions$Duration[UNMissions$Censored==0]))
## [1] 27
length(unique(UNMissions$Duration[UNMissions$Censored==1]))
## [1] 14

27 2x2 tables are required.

*To find the data:

(0,2] Dead Alive Total
Civil War=0 1 39 40
Civil War =1 0 14 14
Total 1 53 54

In this case, Ai = 1 and Ci = 0.

  1. Null hypothesis: Survival rates are the same for missions that are in response to a civil war (\(CivilWar=1\)) as for missions that are not (\(CivilWar=0\)). Alternative hypothesis: Survival rates are different for missions that are in response to a civil war than for missions that are not.

To perform the log-rank test:

survdiff(Surv(Duration, 1-Censored)~CivilWar, data=UNMissions)
## Call:
## survdiff(formula = Surv(Duration, 1 - Censored) ~ CivilWar, data = UNMissions)
## 
##             N Observed Expected (O-E)^2/E (O-E)^2/V
## CivilWar=0 40       27     32.7     0.992       6.7
## CivilWar=1 14       12      6.3     5.144       6.7
## 
##  Chisq= 6.7  on 1 degrees of freedom, p= 0.00966
.992 + 5.144  #calculate test statistic
## [1] 6.136
1-pchisq(6.136, 1) #calculate p-value
## [1] 0.01325

The p-value is less than .05, so we reject the null hypothesis. There appears to be a difference between survival rates for missions that are in response to a civil war and missions that are not.

  1. To calculate the point and interval estimates:
(27/32.7)/(12/6.3) #point estimate: HR = (OA/EA)/(OB/EB)
## [1] 0.4335
.4334862*exp(-1.96*sqrt(1/32.7+1/6.3)) #lower bound for interval: [HR*e +/- 1.96*s ] where s = sd (log(HR)) = sqrt(1/EA + 1/EB)
## [1] 0.1848
.4334862*exp(1.96*sqrt(1/32.7+1/6.3)) #upper bound for interval
## [1] 1.017

Our point estimate is .4334862, and our interval estimate is [0.1847615, 1.017042].

Here, the HR confidence interval and the results from the log-rank test do NOT agree. The log-rank test indicates that there is a difference between survival rates for missions that are in response to a civil war and missions that are not (p-value < .05), but the HR confidence indicates that there may be no difference (interval estimate containing 1).

  1. Null hypothesis: Survival rates are the same for missions that are in response to interstate conflict (\(InterState=1\)) as for missions that are not (\(InterState=0\)). Alternative hypothesis: Survival rates are different for missions that are in response to interstate conflict than for missions that are not.

To perform the log-rank test:

survdiff(Surv(Duration, 1-Censored)~InterState, data=UNMissions)
## Call:
## survdiff(formula = Surv(Duration, 1 - Censored) ~ InterState, 
##     data = UNMissions)
## 
##               N Observed Expected (O-E)^2/E (O-E)^2/V
## InterState=0 44       34     28.1      1.22      4.78
## InterState=1 10        5     10.9      3.16      4.78
## 
##  Chisq= 4.8  on 1 degrees of freedom, p= 0.0289
1.22 + 3.16  #calculate test statistic
## [1] 4.38
1-pchisq(4.38, 1) #calculate p-value
## [1] 0.03636

The p-value is less than .05, so we reject the null hypothesis. There appears to be a difference between survival rates for missions that are in response to interstate conflict and missions that are not.

To calculate the point and interval estimates:

(34/28.1)/(5/10.9) #point estimate: HR = (OA/EA)/(OB/EB)
## [1] 2.638
2.637722*exp(-1.96*sqrt(1/28.1+1/10.9)) #lower bound for interval: [HR*e +/- 1.96*s ] where s = sd (log(HR)) = sqrt(1/EA + 1/EB)
## [1] 1.311
2.637722*exp(1.96*sqrt(1/28.1+1/10.9)) #upper bound for interval
## [1] 5.309

Our point estimate is 2.637722, and our interval estimate is [1.310648, 5.308502].

Here, the HR confidence interval and the results from the log-rank test DO agree. The log-rank test indicates that there is a difference between survival rates for missions that are in response to interstate conflict and missions that are not (p-value < .05), and the HR confidence comes to the same conclusion (interval estimate excluding 1).

  1. In this context, HR > 1 means that missions that are NOT in response to interstate conflict tend to have higher risk than missions that are not. We conclude that the length of missions when there is an interstate conflict is higher, because risk of failure (the mission ending) is lower.