R Markdown

DATASET 1

df <- data.frame(
  ID = 1:22,
  group = c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2),
  time = c(6.8 , 7.2, 9.5, 10.4, 12.6, 16.8, 20.2, 24.6, 28.6, 30.7, 9.4, 10.6, 12.8, 14.6, 16.2, 20.7, 23.5, 24.0, 30.6, 40.2, 44.1, 46.2),
  event = c(1,0,1,0,1,1,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1)
)
View(df)

Kaplan Maier estimates

## Call: survfit(formula = Surv(time, event) ~ group, data = df)
## 
##                 group=1 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##   6.8     10       1    0.900  0.0949        0.732        1.000
##   9.5      8       1    0.787  0.1340        0.564        1.000
##  12.6      6       1    0.656  0.1638        0.402        1.000
##  16.8      5       1    0.525  0.1759        0.272        1.000
##  24.6      3       1    0.350  0.1849        0.124        0.985
##  28.6      2       1    0.175  0.1545        0.031        0.987
##  30.7      1       1    0.000     NaN           NA           NA
## 
##                 group=2 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##   9.4     12       1    0.917  0.0798       0.7729        1.000
##  12.8     10       1    0.825  0.1128       0.6311        1.000
##  16.2      8       1    0.722  0.1380       0.4963        1.000
##  20.7      7       1    0.619  0.1520       0.3823        1.000
##  23.5      6       1    0.516  0.1578       0.2830        0.939
##  30.6      4       1    0.387  0.1627       0.1695        0.882
##  40.2      3       1    0.258  0.1511       0.0817        0.813
##  44.1      2       1    0.129  0.1184       0.0213        0.780
##  46.2      1       1    0.000     NaN           NA           NA

Log-Rank test

## Call:
## survdiff(formula = Surv(time, event) ~ group, data = df)
## 
##          N Observed Expected (O-E)^2/E (O-E)^2/V
## group=1 10        7     4.63     1.213      1.93
## group=2 12        9    11.37     0.494      1.93
## 
##  Chisq= 1.9  on 1 degrees of freedom, p= 0.2

The Mantel-Haenszel test yields a p-value of 0.2, indicating that there is no statistically significant difference between the two survival distributions. The chi-square value of 1.9 differs from the manually calculated result, suggesting a possible calculation error in the manual approach. However, the overall conclusion remains consistent—there is no significant difference in survival distributions.

DATASET 2

Kaplan Maier estimates

## Call: survfit(formula = Surv(Time, Status) ~ Group, data = s_data)
## 
##                 Group=1 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     1     21       4   0.8095  0.0857      0.65785        0.996
##     2     17       1   0.7619  0.0929      0.59988        0.968
##     3     16       1   0.7143  0.0986      0.54500        0.936
##     4     15       2   0.6190  0.1060      0.44260        0.866
##     5     13       1   0.5714  0.1080      0.39455        0.828
##     8     12       4   0.3810  0.1060      0.22085        0.657
##    11      8       2   0.2857  0.0986      0.14529        0.562
##    12      6       2   0.1905  0.0857      0.07887        0.460
##    15      4       1   0.1429  0.0764      0.05011        0.407
##    17      3       1   0.0952  0.0641      0.02549        0.356
##    22      2       1   0.0476  0.0465      0.00703        0.322
##    23      1       1   0.0000     NaN           NA           NA
## 
##                 Group=2 
##  time n.risk n.event survival std.err lower 95% CI upper 95% CI
##     6     21       3    0.857  0.0764        0.720        1.000
##     7     17       1    0.807  0.0869        0.653        0.996
##    10     15       1    0.753  0.0963        0.586        0.968
##    13     12       1    0.690  0.1068        0.510        0.935
##    16     11       1    0.627  0.1141        0.439        0.896
##    22      7       1    0.538  0.1282        0.337        0.858
##    23      6       1    0.448  0.1346        0.249        0.807

##    strata median lower upper
## 1 Group=1      8     4    12
## 2 Group=2     23    16    NA

The median survival time is 8 months for Group 1 and 23 months for Group 2, indicating a longer survival duration in Group 2.

Log-Rank test

## Call:
## survdiff(formula = Surv(Time, Status) ~ Group, data = s_data)
## 
##          N Observed Expected (O-E)^2/E (O-E)^2/V
## Group=1 21       21     10.8      9.68      16.8
## Group=2 21        9     19.2      5.43      16.8
## 
##  Chisq= 16.8  on 1 degrees of freedom, p= 4e-05

The log-rank test yielded a very small p-value, which allows us to reject the null hypothesis. This indicates that the survival distributions between the treatment group and placebo group differ statistically.