Question

Penelitian psikologi mencatat kemampuan 25 mahasiswa untuk berkonsentrasi pada pembelajaran online melalui Zoom meeting.

Variabel yang diamati adalah waktu (dalam jam) dari awal belajar sampai kehilangan konsentrasi.

Tanda + menunjukkan data tersensor (mahasiswa belum kehilangan konsentrasi saat pengamatan berakhir).

Data (disortir berdasarkan waktu):

NoWaktu (jam)Tersensor
10.1
20.2
30.2
40.3
50.3
60.3
70.4
80.7
90.8
100.9+
111.0
121.0
131.0+
141.1
151.3
161.6
171.6
181.8
192.0+
202.0+
212.0+
222.0+
232.0+
242.0+
252.0+

Total: 25 mahasiswa, 9 tersensor, 16 event (kehilangan konsentrasi)

  • a. Tentukan taksiran untuk fungsi survival berdasarkan metode Kaplan-Meier, kemudian plot grafiknya.
  • b. Hitunglah juga taksiran variansinya dan standar errornya.

Answer

a.

Survival function at time can be estimated with Kaplan-Meier Estimator using:

where:

  • : Estimated survival time at time
  • : Event occuring at time
  • : Event remaining at time

Let

  • : Censored data at time

Applying this estimator to the data:

0.1102524/250.96
0.2202422/240.88
0.3302219/220.76
0.4101918/190.72
0.7101817/180.68
0.8101716/170.64
0.9011610.64
1.0211513/150.55
1.1101211/120.51
1.3101110/110.46
1.620108/100.37
1.81087/80.32
2.007710.32

We get:

Interval
0.11.0
0.1 0.20.96
0.2 0.30.88
0.3 0.40.76
0.4 0.70.72
0.7 0.80.68
0.8 0.90.64
0.9 1.00.64
1.0 1.10.55
1.1 1.30.51
1.3 1.60.46
1.6 1.80.37
1.8 2.00.32
2.00.32

Plotting using Python:

import seaborn
 
seaborn.lineplot(
    ests, x="Interval", y="Estimated Survival Time", 
    drawstyle="steps-post", marker='o'
).figure.savefig("/home/fazuh/Notes/assets/1774435528.png")

b.

The variance and standard error of the estimated survival function can also be estimated using Greenwood’s Formula:

Continuing from point a.,

Let

Then the estimated variance and standard error for the estimated survival function are:

0.11250.96000.00170.00170.92160.00150.0392
0.22240.88000.00380.00550.77440.00420.0650
0.33220.76000.00720.01260.57760.00730.0854
0.41190.72000.00290.01560.51840.00810.0898
0.71180.68000.00330.01880.46240.00870.0933
0.81170.64000.00370.02250.40960.00920.0960
0.90160.64000.00000.02250.40960.00920.0960
1.02150.55470.01030.03280.30770.01010.1004
1.11120.50840.00760.04030.25850.01040.1021
1.31110.46220.00910.04940.21360.01060.1028
1.62100.36980.02500.07440.13670.01020.1009
1.8180.32360.01790.09230.10470.00970.0983
2.0070.32360.00000.09230.10470.00970.0983

Appendix

Python version

from itertools import groupby
 
data: list[tuple[float, bool]] = [ (1.8, False), (2.0, True), (1.0, True), (2.0, True), (1.6, False), (0.7, False), (0.9, True), (1.6, False), (0.2, False), (0.4, False), (2.0, True), (2.0, True), (2.0, True), (1.0, False), (1.1, False), (0.3, False), (0.1, False), (0.3, False), (0.3, False), (2.0, True), (1.0, False), (1.3, False), (0.8, False), (0.2, False), (2.0, True) ]
 
def kaplan_meier(subjects: list[tuple[float, bool]]) -> dict[str, list[float]]:
    subjects_sorted = sorted(subjects, key=lambda x: x[0])
    remaining = len(subjects_sorted)
    prev = 1.0
    ests: dict[str, list[float]] = {
        "Interval": [],
        "Estimated Survival Time": []
    }
 
    for t, group in groupby(subjects_sorted, key=lambda x: x[0]):
        group = list(group)
        d = sum(1 for (_, censored) in group if not censored)
        
        s_t = prev * (1 - d / remaining)
        ests["Interval"].append(t)
        ests["Estimated Survival Time"].append(s_t)
        prev = s_t
        remaining -= len(group)
 
    return ests
 
ests = kaplan_meier(data)
 
print("| Interval | Estimated | \n| --- | --- |")
for i, (t, est) in enumerate(zip(ests["Interval"], ests["Estimated Survival Time"])):
    prev_est = 1.0 if i == 0 else ests["Estimated Survival Time"][i-1]
    prev_est = round(prev_est, 2)
    if i == 0:
        print(f"| $t <$ {t} | {prev_est:.2f} |")
    else:
        print(f"| {ests['Interval'][i-1]} $\\leq t <$ {t} | {prev_est:.2f} |")
# last row: t >= last event time
print(f"| $t \\geq$ {ests['Interval'][-1]} | {round(ests["Estimated Survival Time"][-1], 2):.2f} |")

Data: Original ordering

NoWaktu (jam)Tersensor
11.8
22.0+
31.0+
42.0+
51.6
60.7
70.9+
81.6
90.2
100.4
112.0+
122.0+
132.0+
141.0
151.1
160.3
170.1
180.3
190.3
202.0+
211.0
221.3
230.8
240.2
252.0+