Key variables:

From the description of the exercise, we have the following key variables: agecensor: Age at last observation (death or censoring). died0121: Event status (1 = died, 0 = censored). Aageint: Age at baseline interview.

loading the libraries and data

library(survival)
library(ggsurvfit)
## Loading required package: ggplot2
library(gtsummary)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(readr)
data2<-read_csv("C:\\Users\\anami\\OneDrive\\Documents\\EHA\\MHAS0121.csv")
## Rows: 9636 Columns: 39
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (3): locsize01, died18, died21
## dbl (36): id, perwght01, mobirth, yrbirth, female, moint, yrint, schooling, ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Creating the Survival Object and fitting Kaplan-Meier Model

surv_obj <- Surv(time = data2$agecensor, event = data2$died0121)

# Fit the Kaplan-Meier model
km_fit <- survfit(surv_obj ~ 1, data = data2)
# Print summary to get survival function and standard errors
summary(km_fit)
## Call: survfit(formula = surv_obj ~ 1, data = data2)
## 
## 2071 observations deleted due to missingness 
##   time n.risk n.event survival  std.err lower 95% CI upper 95% CI
##   51.2   7565       2  0.99974 0.000187     0.999369       1.0000
##   51.6   7563       1  0.99960 0.000229     0.999155       1.0000
##   52.1   7562       1  0.99947 0.000264     0.998953       1.0000
##   52.2   7561       1  0.99934 0.000295     0.998760       0.9999
##   52.3   7560       1  0.99921 0.000324     0.998573       0.9998
##   52.4   7559       2  0.99894 0.000374     0.998210       0.9997
##   52.7   7557       1  0.99881 0.000396     0.998034       0.9996
##   53.0   7556       3  0.99841 0.000458     0.997517       0.9993
##   53.1   7553       2  0.99815 0.000494     0.997181       0.9991
##   53.2   7551       1  0.99802 0.000511     0.997015       0.9990
##   53.2   7550       1  0.99788 0.000528     0.996850       0.9989
##   53.4   7549       1  0.99775 0.000544     0.996686       0.9988
##   53.6   7548       1  0.99762 0.000560     0.996523       0.9987
##   53.7   7547       1  0.99749 0.000575     0.996361       0.9986
##   53.8   7546       2  0.99722 0.000605     0.996039       0.9984
##   54.1   7544       1  0.99709 0.000619     0.995879       0.9983
##   54.2   7543       3  0.99670 0.000660     0.995403       0.9980
##   54.2   7540       1  0.99656 0.000673     0.995245       0.9979
##   54.3   7539       1  0.99643 0.000686     0.995088       0.9978
##   54.4   7538       1  0.99630 0.000698     0.994931       0.9977
##   54.8   7537       1  0.99617 0.000710     0.994775       0.9976
##   54.9   7536       1  0.99603 0.000723     0.994619       0.9975
##   55.0   7535       1  0.99590 0.000734     0.994464       0.9973
##   55.1   7534       1  0.99577 0.000746     0.994309       0.9972
##   55.2   7533       2  0.99551 0.000769     0.993999       0.9970
##   55.3   7531       1  0.99537 0.000780     0.993845       0.9969
##   55.4   7530       1  0.99524 0.000791     0.993692       0.9968
##   55.5   7529       1  0.99511 0.000802     0.993538       0.9967
##   55.6   7528       2  0.99484 0.000823     0.993232       0.9965
##   55.8   7526       1  0.99471 0.000834     0.993080       0.9963
##   55.8   7525       2  0.99445 0.000854     0.992775       0.9961
##   55.9   7523       3  0.99405 0.000884     0.992320       0.9958
##   56.1   7520       2  0.99379 0.000903     0.992018       0.9956
##   56.2   7518       3  0.99339 0.000932     0.991566       0.9952
##   56.2   7515       1  0.99326 0.000941     0.991416       0.9951
##   56.3   7514       4  0.99273 0.000977     0.990817       0.9946
##   56.5   7510       1  0.99260 0.000986     0.990668       0.9945
##   56.6   7509       1  0.99247 0.000994     0.990519       0.9944
##   56.7   7508       2  0.99220 0.001011     0.990221       0.9942
##   56.8   7506       2  0.99194 0.001028     0.989923       0.9940
##   56.8   7504       2  0.99167 0.001045     0.989626       0.9937
##   57.0   7502       2  0.99141 0.001061     0.989330       0.9935
##   57.2   7500       1  0.99128 0.001069     0.989182       0.9934
##   57.2   7499       1  0.99114 0.001077     0.989034       0.9933
##   57.3   7498       3  0.99075 0.001101     0.988592       0.9929
##   57.4   7495       4  0.99022 0.001132     0.988003       0.9924
##   57.5   7491       3  0.98982 0.001154     0.987562       0.9921
##   57.6   7488       1  0.98969 0.001161     0.987416       0.9920
##   57.7   7487       3  0.98929 0.001183     0.986976       0.9916
##   57.8   7484       4  0.98876 0.001212     0.986392       0.9911
##   57.9   7480       2  0.98850 0.001226     0.986100       0.9909
##   58.0   7478       1  0.98837 0.001233     0.985954       0.9908
##   58.1   7477       1  0.98824 0.001240     0.985809       0.9907
##   58.2   7476       2  0.98797 0.001253     0.985517       0.9904
##   58.3   7474       2  0.98771 0.001267     0.985227       0.9902
##   58.4   7472       2  0.98744 0.001280     0.984936       0.9900
##   58.5   7470       3  0.98705 0.001300     0.984501       0.9896
##   58.6   7467       3  0.98665 0.001320     0.984066       0.9892
##   58.7   7464       2  0.98638 0.001332     0.983777       0.9890
##   58.8   7462       4  0.98586 0.001358     0.983199       0.9885
##   58.8   7458       1  0.98572 0.001364     0.983054       0.9884
##   58.9   7457       3  0.98533 0.001382     0.982621       0.9880
##   59.0   7454       3  0.98493 0.001401     0.982189       0.9877
##   59.1   7451       2  0.98467 0.001413     0.981901       0.9874
##   59.2   7449       4  0.98414 0.001437     0.981326       0.9870
##   59.2   7445       3  0.98374 0.001454     0.980895       0.9866
##   59.3   7442       3  0.98334 0.001471     0.980465       0.9862
##   59.5   7439       1  0.98321 0.001477     0.980321       0.9861
##   59.6   7438       1  0.98308 0.001483     0.980178       0.9860
##   59.7   7437       2  0.98282 0.001494     0.979891       0.9857
##   59.8   7435       2  0.98255 0.001505     0.979605       0.9855
##   59.9   7433       3  0.98215 0.001522     0.979176       0.9851
##   60.0   7430       3  0.98176 0.001539     0.978747       0.9848
##   60.1   7427       4  0.98123 0.001560     0.978176       0.9843
##   60.2   7423       5  0.98057 0.001587     0.977463       0.9837
##   60.2   7418       4  0.98004 0.001608     0.976893       0.9832
##   60.3   7414       6  0.97925 0.001639     0.976039       0.9825
##   60.5   7408       6  0.97845 0.001669     0.975187       0.9817
##   60.6   7402       6  0.97766 0.001699     0.974336       0.9810
##   60.7   7396       3  0.97726 0.001714     0.973910       0.9806
##   60.8   7393       2  0.97700 0.001724     0.973627       0.9804
##   60.8   7391       4  0.97647 0.001743     0.973061       0.9799
##   60.9   7387       5  0.97581 0.001766     0.972354       0.9793
##   61.0   7382       4  0.97528 0.001785     0.971788       0.9788
##   61.1   7378       3  0.97488 0.001799     0.971365       0.9784
##   61.2   7375       1  0.97475 0.001804     0.971223       0.9783
##   61.2   7374       2  0.97449 0.001813     0.970941       0.9780
##   61.3   7372       7  0.97356 0.001845     0.969954       0.9772
##   61.4   7365       4  0.97303 0.001862     0.969390       0.9767
##   61.5   7361       4  0.97250 0.001880     0.968827       0.9762
##   61.6   7357       3  0.97211 0.001893     0.968405       0.9758
##   61.7   7354       3  0.97171 0.001906     0.967983       0.9755
##   61.8   7351       4  0.97118 0.001923     0.967421       0.9750
##   61.8   7347       6  0.97039 0.001949     0.966578       0.9742
##   61.9   7341       2  0.97013 0.001957     0.966297       0.9740
##   62.0   7339       1  0.96999 0.001962     0.966157       0.9738
##   62.1   7338       6  0.96920 0.001986     0.965315       0.9731
##   62.2   7332       4  0.96867 0.002003     0.964754       0.9726
##   62.2   7328       5  0.96801 0.002023     0.964053       0.9720
##   62.3   7323       3  0.96761 0.002035     0.963633       0.9716
##   62.4   7320       8  0.96656 0.002067     0.962514       0.9706
##   62.5   7312       6  0.96576 0.002091     0.961675       0.9699
##   62.6   7306       3  0.96537 0.002102     0.961255       0.9695
##   62.7   7303       4  0.96484 0.002118     0.960696       0.9690
##   62.8   7299       1  0.96471 0.002122     0.960557       0.9689
##   62.8   7298       6  0.96391 0.002144     0.959719       0.9681
##   62.9   7292       4  0.96338 0.002159     0.959161       0.9676
##   63.0   7288       5  0.96272 0.002178     0.958464       0.9670
##   63.1   7283       9  0.96153 0.002211     0.957209       0.9659
##   63.2   7274      13  0.95981 0.002258     0.955400       0.9643
##   63.2   7261       6  0.95902 0.002279     0.954565       0.9635
##   63.3   7255       3  0.95863 0.002290     0.954148       0.9631
##   63.4   7252       1  0.95849 0.002293     0.954009       0.9630
##   63.5   7251       7  0.95757 0.002318     0.953036       0.9621
##   63.6   7244       7  0.95664 0.002342     0.952064       0.9612
##   63.7   7237       5  0.95598 0.002359     0.951370       0.9606
##   63.8   7232       2  0.95572 0.002365     0.951093       0.9604
##   63.8   7230       8  0.95466 0.002392     0.949983       0.9594
##   63.9   7222       3  0.95426 0.002402     0.949567       0.9590
##   64.0   7219       1  0.95413 0.002405     0.949428       0.9589
##   64.1   7218       2  0.95387 0.002412     0.949151       0.9586
##   64.2   7216       3  0.95347 0.002422     0.948735       0.9582
##   64.2   7213       7  0.95254 0.002444     0.947766       0.9573
##   64.3   7206       3  0.95215 0.002454     0.947350       0.9570
##   64.4   7203       7  0.95122 0.002477     0.946381       0.9561
##   64.5   7196       5  0.95056 0.002492     0.945689       0.9555
##   64.6   7191       4  0.95003 0.002505     0.945136       0.9550
##   64.7   7187       4  0.94950 0.002518     0.944583       0.9545
##   64.8   7183       9  0.94831 0.002545     0.943339       0.9533
##   64.8   7174       7  0.94739 0.002567     0.942372       0.9524
##   64.9   7167       4  0.94686 0.002579     0.941819       0.9519
##   65.0   7163      13  0.94514 0.002618     0.940025       0.9503
##   65.1   7150      12  0.94356 0.002653     0.938370       0.9488
##   65.2   7137       7  0.94263 0.002674     0.937405       0.9479
##   65.2   7129       6  0.94184 0.002691     0.936578       0.9471
##   65.3   7123       3  0.94144 0.002700     0.936164       0.9467
##   65.4   7120       7  0.94051 0.002719     0.935200       0.9459
##   65.5   7113       5  0.93985 0.002734     0.934511       0.9452
##   65.6   7106       6  0.93906 0.002750     0.933685       0.9445
##   65.7   7100      11  0.93761 0.002781     0.932171       0.9431
##   65.8   7089       7  0.93668 0.002800     0.931207       0.9422
##   65.8   7082       8  0.93562 0.002822     0.930107       0.9412
##   65.9   7074       6  0.93483 0.002838     0.929282       0.9404
##   66.0   7068       4  0.93430 0.002849     0.928732       0.9399
##   66.1   7064       5  0.93364 0.002862     0.928045       0.9393
##   66.2   7058       7  0.93271 0.002880     0.927083       0.9384
##   66.2   7051       6  0.93192 0.002896     0.926259       0.9376
##   66.3   7044       8  0.93086 0.002917     0.925160       0.9366
##   66.4   7035      11  0.92940 0.002945     0.923649       0.9352
##   66.5   7023       6  0.92861 0.002960     0.922825       0.9344
##   66.6   7014       6  0.92782 0.002976     0.922002       0.9337
##   66.7   7008       7  0.92689 0.002993     0.921041       0.9328
##   66.8   7000       3  0.92649 0.003001     0.920629       0.9324
##   66.8   6997       3  0.92609 0.003008     0.920217       0.9320
##   66.9   6994       6  0.92530 0.003023     0.919394       0.9312
##   67.0   6988       8  0.92424 0.003043     0.918296       0.9302
##   67.1   6980       7  0.92331 0.003060     0.917336       0.9293
##   67.2   6973      10  0.92199 0.003084     0.915965       0.9281
##   67.2   6963       8  0.92093 0.003103     0.914868       0.9270
##   67.3   6955       8  0.91987 0.003122     0.913772       0.9260
##   67.4   6947       9  0.91868 0.003143     0.912539       0.9249
##   67.5   6938       8  0.91762 0.003162     0.911444       0.9238
##   67.6   6930      10  0.91630 0.003185     0.910075       0.9226
##   67.7   6920      12  0.91471 0.003212     0.908433       0.9210
##   67.8   6908       9  0.91352 0.003232     0.907202       0.9199
##   67.8   6899       7  0.91259 0.003248     0.906244       0.9190
##   67.9   6892       5  0.91193 0.003259     0.905561       0.9183
##   68.0   6886       8  0.91087 0.003277     0.904467       0.9173
##   68.1   6877      10  0.90954 0.003299     0.903100       0.9160
##   68.2   6866      13  0.90782 0.003327     0.901323       0.9144
##   68.2   6853      11  0.90636 0.003350     0.899820       0.9130
##   68.3   6842      10  0.90504 0.003372     0.898454       0.9117
##   68.4   6832      10  0.90371 0.003393     0.897089       0.9104
##   68.5   6821      14  0.90186 0.003422     0.895177       0.9086
##   68.6   6807      13  0.90014 0.003448     0.893403       0.9069
##   68.7   6794      11  0.89868 0.003471     0.891902       0.9055
##   68.8   6783      19  0.89616 0.003509     0.889311       0.9031
##   68.8   6764      12  0.89457 0.003532     0.887675       0.9015
##   68.9   6751       8  0.89351 0.003548     0.886585       0.9005
##   69.0   6742       9  0.89232 0.003565     0.885358       0.8993
##   69.1   6732       9  0.89113 0.003583     0.884131       0.8982
##   69.2   6723      19  0.88861 0.003619     0.881543       0.8957
##   69.2   6702      13  0.88688 0.003643     0.879772       0.8941
##   69.3   6687       9  0.88569 0.003660     0.878546       0.8929
##   69.4   6676      19  0.88317 0.003695     0.875957       0.8904
##   69.5   6657       7  0.88224 0.003708     0.875004       0.8895
##   69.6   6650      10  0.88091 0.003726     0.873642       0.8882
##   69.7   6639      15  0.87892 0.003753     0.871599       0.8863
##   69.8   6621      12  0.87733 0.003774     0.869965       0.8848
##   69.8   6607      12  0.87574 0.003795     0.868331       0.8832
##   69.9   6594      11  0.87428 0.003814     0.866833       0.8818
##   70.0   6583      13  0.87255 0.003837     0.865063       0.8801
##   70.1   6569      12  0.87096 0.003857     0.863429       0.8785
##   70.2   6552      11  0.86949 0.003876     0.861931       0.8771
##   70.2   6540      11  0.86803 0.003894     0.860432       0.8757
##   70.3   6528      13  0.86630 0.003916     0.858662       0.8740
##   70.4   6514      15  0.86431 0.003941     0.856619       0.8721
##   70.5   6496      11  0.86284 0.003959     0.855120       0.8706
##   70.6   6485       7  0.86191 0.003970     0.854167       0.8697
##   70.7   6477      11  0.86045 0.003988     0.852669       0.8683
##   70.8   6466       6  0.85965 0.003997     0.851852       0.8675
##   70.8   6459      13  0.85792 0.004018     0.850082       0.8658
##   70.9   6445      15  0.85592 0.004041     0.848039       0.8639
##   71.0   6430      14  0.85406 0.004063     0.846133       0.8621
##   71.1   6410       9  0.85286 0.004077     0.844907       0.8609
##   71.2   6388       5  0.85219 0.004085     0.844225       0.8602
##   71.2   6361       5  0.85152 0.004093     0.843540       0.8596
##   71.3   6331      11  0.85004 0.004110     0.842027       0.8581
##   71.4   6296       8  0.84896 0.004122     0.840923       0.8571
##   71.5   6255       7  0.84801 0.004133     0.839951       0.8562
##   71.6   6218       8  0.84692 0.004146     0.838836       0.8551
##   71.7   6180      12  0.84528 0.004165     0.837155       0.8535
##   71.8   6156       9  0.84404 0.004179     0.835891       0.8523
##   71.8   6123      11  0.84253 0.004197     0.834341       0.8508
##   71.9   6091      14  0.84059 0.004219     0.832362       0.8489
##   72.0   6039       7  0.83962 0.004230     0.831366       0.8479
##   72.1   5989      12  0.83793 0.004249     0.829646       0.8463
##   72.2   5943      14  0.83596 0.004272     0.827628       0.8444
##   72.2   5894      14  0.83397 0.004294     0.825599       0.8424
##   72.3   5849      12  0.83226 0.004314     0.823850       0.8408
##   72.4   5827      15  0.83012 0.004338     0.821661       0.8387
##   72.5   5795      13  0.82826 0.004359     0.819758       0.8368
##   72.6   5752      12  0.82653 0.004378     0.817993       0.8352
##   72.7   5722       8  0.82537 0.004391     0.816812       0.8340
##   72.8   5697      10  0.82393 0.004407     0.815332       0.8326
##   72.8   5657      11  0.82232 0.004425     0.813696       0.8310
##   72.9   5629      12  0.82057 0.004445     0.811905       0.8293
##   73.0   5590      11  0.81896 0.004463     0.810256       0.8277
##   73.1   5561      10  0.81748 0.004479     0.808752       0.8263
##   73.2   5526       9  0.81615 0.004493     0.807392       0.8250
##   73.2   5495      10  0.81467 0.004510     0.805875       0.8236
##   73.3   5463      12  0.81288 0.004529     0.804048       0.8218
##   73.4   5426       8  0.81168 0.004542     0.802824       0.8206
##   73.5   5396       5  0.81093 0.004551     0.802056       0.8199
##   73.6   5364       9  0.80957 0.004566     0.800667       0.8186
##   73.7   5325      14  0.80744 0.004589     0.798493       0.8165
##   73.8   5288      17  0.80484 0.004617     0.795843       0.8139
##   73.8   5248      16  0.80239 0.004644     0.793338       0.8115
##   73.9   5210       6  0.80146 0.004653     0.792395       0.8106
##   74.0   5192      21  0.79822 0.004688     0.789086       0.8075
##   74.1   5147       7  0.79714 0.004700     0.787978       0.8064
##   74.2   5115       5  0.79636 0.004708     0.787183       0.8056
##   74.2   5082      12  0.79448 0.004728     0.785264       0.8038
##   74.3   5037       8  0.79321 0.004742     0.783976       0.8026
##   74.4   5009      16  0.79068 0.004769     0.781390       0.8001
##   74.5   4970       9  0.78925 0.004784     0.779929       0.7987
##   74.6   4942      17  0.78653 0.004812     0.777159       0.7960
##   74.7   4909       8  0.78525 0.004826     0.775851       0.7948
##   74.8   4878      15  0.78284 0.004851     0.773387       0.7924
##   74.8   4847       7  0.78171 0.004863     0.772234       0.7913
##   74.9   4808      15  0.77927 0.004888     0.769746       0.7889
##   75.0   4767       9  0.77780 0.004904     0.768246       0.7875
##   75.1   4735      14  0.77550 0.004927     0.765900       0.7852
##   75.2   4705      11  0.77368 0.004946     0.764051       0.7834
##   75.2   4677      16  0.77104 0.004973     0.761352       0.7808
##   75.3   4639       9  0.76954 0.004989     0.759826       0.7794
##   75.4   4606      10  0.76787 0.005006     0.758123       0.7777
##   75.5   4580      11  0.76603 0.005024     0.756242       0.7759
##   75.6   4547      13  0.76384 0.005047     0.754009       0.7738
##   75.7   4509      14  0.76147 0.005071     0.751591       0.7715
##   75.8   4474       9  0.75993 0.005086     0.750030       0.7700
##   75.8   4451       9  0.75840 0.005102     0.748464       0.7685
##   75.9   4429       8  0.75703 0.005115     0.747067       0.7671
##   76.0   4394      14  0.75461 0.005139     0.744609       0.7648
##   76.1   4363       8  0.75323 0.005153     0.743198       0.7634
##   76.2   4336      17  0.75028 0.005183     0.740189       0.7605
##   76.2   4302      14  0.74784 0.005207     0.737701       0.7581
##   76.3   4273       7  0.74661 0.005219     0.736453       0.7569
##   76.4   4241      10  0.74485 0.005236     0.734659       0.7552
##   76.5   4214       9  0.74326 0.005252     0.733038       0.7536
##   76.6   4179       5  0.74237 0.005260     0.732132       0.7528
##   76.7   4158      16  0.73951 0.005288     0.729222       0.7500
##   76.8   4123       8  0.73808 0.005302     0.727760       0.7485
##   76.8   4097       8  0.73664 0.005316     0.726291       0.7471
##   76.9   4073      11  0.73465 0.005336     0.724265       0.7452
##   77.0   4037      11  0.73265 0.005355     0.722226       0.7432
##   77.1   4003      12  0.73045 0.005377     0.719988       0.7411
##   77.2   3970       5  0.72953 0.005386     0.719051       0.7402
##   77.2   3947      11  0.72750 0.005405     0.716980       0.7382
##   77.3   3920      11  0.72546 0.005425     0.714901       0.7362
##   77.4   3888      11  0.72340 0.005445     0.712810       0.7342
##   77.5   3855      16  0.72040 0.005474     0.709752       0.7312
##   77.6   3821      12  0.71814 0.005495     0.707448       0.7290
##   77.7   3797       9  0.71644 0.005512     0.705715       0.7273
##   77.8   3765       9  0.71472 0.005528     0.703971       0.7256
##   77.8   3737      18  0.71128 0.005561     0.700466       0.7223
##   77.9   3697      11  0.70916 0.005580     0.698311       0.7202
##   78.0   3667      13  0.70665 0.005604     0.695752       0.7177
##   78.1   3631       7  0.70529 0.005617     0.694365       0.7164
##   78.2   3601      14  0.70255 0.005643     0.691574       0.7137
##   78.2   3567      10  0.70058 0.005661     0.689569       0.7118
##   78.3   3539      16  0.69741 0.005691     0.686345       0.7087
##   78.4   3505      11  0.69522 0.005711     0.684117       0.7065
##   78.5   3480       9  0.69342 0.005727     0.682287       0.7047
##   78.6   3454       6  0.69222 0.005739     0.681062       0.7036
##   78.7   3429      10  0.69020 0.005757     0.679007       0.7016
##   78.8   3400      10  0.68817 0.005776     0.676941       0.6996
##   78.8   3369       6  0.68694 0.005787     0.675694       0.6984
##   78.9   3349      17  0.68346 0.005819     0.672146       0.6950
##   79.0   3318      17  0.67996 0.005851     0.668583       0.6915
##   79.1   3285       9  0.67809 0.005868     0.666688       0.6897
##   79.2   3265      12  0.67560 0.005890     0.664153       0.6872
##   79.2   3236      14  0.67268 0.005917     0.661180       0.6844
##   79.3   3211       8  0.67100 0.005931     0.659476       0.6827
##   79.4   3182      13  0.66826 0.005956     0.656688       0.6800
##   79.5   3149      13  0.66550 0.005980     0.653883       0.6773
##   79.6   3121      10  0.66337 0.005999     0.651715       0.6752
##   79.7   3091      17  0.65972 0.006031     0.648006       0.6716
##   79.8   3054      11  0.65734 0.006051     0.645590       0.6693
##   79.8   3033      10  0.65518 0.006070     0.643387       0.6672
##   79.9   3003      25  0.64972 0.006117     0.637844       0.6618
##   80.0   2965       8  0.64797 0.006132     0.636062       0.6601
##   80.1   2945      11  0.64555 0.006152     0.633603       0.6577
##   80.2   2923      14  0.64246 0.006178     0.630462       0.6547
##   80.2   2888      13  0.63957 0.006202     0.627525       0.6518
##   80.3   2862       7  0.63800 0.006215     0.625936       0.6503
##   80.4   2846       7  0.63643 0.006228     0.624342       0.6488
##   80.5   2830      11  0.63396 0.006248     0.621830       0.6463
##   80.6   2810       8  0.63215 0.006263     0.619997       0.6445
##   80.7   2794      11  0.62966 0.006283     0.617470       0.6421
##   80.8   2770      10  0.62739 0.006301     0.615162       0.6399
##   80.8   2746       9  0.62533 0.006318     0.613074       0.6378
##   80.9   2726      12  0.62258 0.006340     0.610280       0.6351
##   81.0   2703      14  0.61936 0.006365     0.607007       0.6320
##   81.1   2679      13  0.61635 0.006389     0.603957       0.6290
##   81.2   2649      13  0.61333 0.006412     0.600888       0.6260
##   81.2   2625      15  0.60982 0.006439     0.597332       0.6226
##   81.3   2590      16  0.60606 0.006468     0.593510       0.6189
##   81.4   2565       9  0.60393 0.006484     0.591354       0.6168
##   81.5   2543      10  0.60155 0.006502     0.588945       0.6144
##   81.6   2522      10  0.59917 0.006519     0.586526       0.6121
##   81.7   2496       9  0.59701 0.006536     0.584335       0.6100
##   81.8   2474      11  0.59435 0.006555     0.581643       0.6073
##   81.8   2454       7  0.59266 0.006568     0.579924       0.6057
##   81.9   2432      10  0.59022 0.006586     0.577453       0.6033
##   82.0   2407       7  0.58851 0.006599     0.575713       0.6016
##   82.1   2387      11  0.58579 0.006619     0.572963       0.5989
##   82.2   2360      15  0.58207 0.006646     0.569188       0.5952
##   82.2   2333      11  0.57933 0.006666     0.566406       0.5925
##   82.3   2310      21  0.57406 0.006704     0.561069       0.5873
##   82.4   2276      11  0.57128 0.006723     0.558257       0.5846
##   82.5   2259      14  0.56774 0.006748     0.554671       0.5811
##   82.6   2233      16  0.56368 0.006776     0.550551       0.5771
##   82.7   2207      10  0.56112 0.006793     0.547964       0.5746
##   82.8   2186      12  0.55804 0.006814     0.544845       0.5716
##   82.8   2165       9  0.55572 0.006829     0.542497       0.5693
##   82.9   2147      15  0.55184 0.006855     0.538566       0.5654
##   83.0   2114      12  0.54871 0.006875     0.535396       0.5623
##   83.1   2088      15  0.54476 0.006901     0.531406       0.5585
##   83.2   2060      14  0.54106 0.006924     0.527660       0.5548
##   83.2   2035       8  0.53894 0.006938     0.525508       0.5527
##   83.3   2017      10  0.53626 0.006955     0.522804       0.5501
##   83.4   1999      15  0.53224 0.006980     0.518734       0.5461
##   83.5   1976       7  0.53035 0.006991     0.516827       0.5442
##   83.6   1956      11  0.52737 0.007010     0.513810       0.5413
##   83.7   1937      11  0.52438 0.007028     0.510782       0.5383
##   83.8   1914      18  0.51945 0.007057     0.505796       0.5335
##   83.8   1888      12  0.51614 0.007076     0.502459       0.5302
##   83.9   1868       7  0.51421 0.007087     0.500504       0.5283
##   84.0   1853       6  0.51254 0.007097     0.498822       0.5266
##   84.1   1834      16  0.50807 0.007123     0.494303       0.5222
##   84.2   1814       5  0.50667 0.007130     0.492888       0.5208
##   84.2   1802      14  0.50274 0.007152     0.488912       0.5170
##   84.3   1780      11  0.49963 0.007169     0.485774       0.5139
##   84.4   1767      12  0.49624 0.007187     0.482348       0.5105
##   84.5   1745      14  0.49226 0.007208     0.478329       0.5066
##   84.6   1724      10  0.48940 0.007222     0.475447       0.5038
##   84.7   1705       6  0.48768 0.007231     0.473709       0.5021
##   84.8   1692      10  0.48480 0.007245     0.470800       0.4992
##   84.8   1673      12  0.48132 0.007263     0.467292       0.4958
##   84.9   1654       9  0.47870 0.007275     0.464650       0.4932
##   85.0   1636      14  0.47460 0.007295     0.460518       0.4891
##   85.1   1610       8  0.47224 0.007306     0.458139       0.4868
##   85.2   1594      15  0.46780 0.007327     0.453658       0.4824
##   85.2   1571      10  0.46482 0.007341     0.450655       0.4794
##   85.3   1558       9  0.46214 0.007353     0.447949       0.4768
##   85.4   1536      10  0.45913 0.007366     0.444916       0.4738
##   85.5   1516      12  0.45549 0.007382     0.441253       0.4702
##   85.6   1487       7  0.45335 0.007392     0.439092       0.4681
##   85.7   1474      16  0.44843 0.007413     0.434132       0.4632
##   85.8   1450      14  0.44410 0.007431     0.429771       0.4589
##   85.8   1425      17  0.43880 0.007453     0.424434       0.4537
##   85.9   1403      14  0.43442 0.007470     0.420026       0.4493
##   86.0   1380      14  0.43002 0.007486     0.415590       0.4449
##   86.1   1360       9  0.42717 0.007497     0.412726       0.4421
##   86.2   1343       8  0.42463 0.007506     0.410166       0.4396
##   86.2   1328       7  0.42239 0.007514     0.407914       0.4374
##   86.3   1312      10  0.41917 0.007525     0.404675       0.4342
##   86.4   1295       5  0.41755 0.007531     0.403047       0.4326
##   86.5   1279       8  0.41494 0.007540     0.400419       0.4300
##   86.6   1262       8  0.41231 0.007549     0.397773       0.4274
##   86.7   1245       6  0.41032 0.007557     0.395774       0.4254
##   86.8   1234       8  0.40766 0.007566     0.393098       0.4228
##   86.8   1220       7  0.40532 0.007574     0.390745       0.4204
##   86.9   1208       7  0.40297 0.007582     0.388383       0.4181
##   87.0   1196      11  0.39927 0.007594     0.384656       0.4144
##   87.1   1180      17  0.39351 0.007612     0.378875       0.4087
##   87.2   1160       1  0.39317 0.007613     0.378534       0.4084
##   87.2   1152      10  0.38976 0.007623     0.375104       0.4050
##   87.3   1129      10  0.38631 0.007633     0.371635       0.4016
##   87.4   1113       7  0.38388 0.007640     0.369194       0.3991
##   87.5   1099       3  0.38283 0.007643     0.368141       0.3981
##   87.6   1090       6  0.38072 0.007649     0.366024       0.3960
##   87.7   1075       6  0.37860 0.007656     0.363888       0.3939
##   87.8   1064       3  0.37753 0.007659     0.362816       0.3928
##   87.8   1055       9  0.37431 0.007668     0.359580       0.3896
##   87.9   1035      10  0.37069 0.007679     0.355946       0.3861
##   88.0   1017       4  0.36924 0.007683     0.354481       0.3846
##   88.1   1009      11  0.36521 0.007695     0.350437       0.3806
##   88.2    992       6  0.36300 0.007701     0.348218       0.3784
##   88.2    980       8  0.36004 0.007709     0.345243       0.3755
##   88.3    964      13  0.35518 0.007722     0.340367       0.3706
##   88.4    948      11  0.35106 0.007732     0.336232       0.3665
##   88.5    932      12  0.34654 0.007741     0.331697       0.3621
##   88.6    916       5  0.34465 0.007745     0.329800       0.3602
##   88.7    901      15  0.33891 0.007757     0.324046       0.3545
##   88.8    881       4  0.33737 0.007759     0.322504       0.3529
##   88.8    873       7  0.33467 0.007764     0.319792       0.3502
##   88.9    861       7  0.33195 0.007769     0.317065       0.3475
##   89.0    846      10  0.32802 0.007776     0.313133       0.3436
##   89.1    830       4  0.32644 0.007778     0.311549       0.3421
##   89.2    824       4  0.32486 0.007781     0.309962       0.3405
##   89.2    815      15  0.31888 0.007789     0.303973       0.3345
##   89.3    793       9  0.31526 0.007794     0.300350       0.3309
##   89.4    781       9  0.31163 0.007797     0.296714       0.3273
##   89.5    770       8  0.30839 0.007800     0.293476       0.3241
##   89.6    757      13  0.30309 0.007803     0.288180       0.3188
##   89.7    740       5  0.30105 0.007804     0.286133       0.3167
##   89.8    729       9  0.29733 0.007805     0.282419       0.3130
##   89.8    716       6  0.29484 0.007806     0.279929       0.3105
##   89.9    703       4  0.29316 0.007806     0.278253       0.3089
##   90.0    696       6  0.29063 0.007807     0.275728       0.3063
##   90.1    689      11  0.28599 0.007807     0.271095       0.3017
##   90.2    677       5  0.28388 0.007806     0.268987       0.2996
##   90.2    667       5  0.28175 0.007805     0.266863       0.2975
##   90.3    660      11  0.27706 0.007802     0.262179       0.2928
##   90.4    646       6  0.27448 0.007800     0.259613       0.2902
##   90.5    636       8  0.27103 0.007797     0.256172       0.2868
##   90.6    622      11  0.26624 0.007792     0.251396       0.2820
##   90.7    607       6  0.26361 0.007789     0.248774       0.2793
##   90.8    597       7  0.26052 0.007785     0.245696       0.2762
##   90.8    588       7  0.25741 0.007780     0.242609       0.2731
##   90.9    577       4  0.25563 0.007777     0.240833       0.2713
##   91.0    569       6  0.25293 0.007772     0.238151       0.2686
##   91.1    559       2  0.25203 0.007771     0.237250       0.2677
##   91.2    554       4  0.25021 0.007768     0.235439       0.2659
##   91.2    543      13  0.24422 0.007757     0.229479       0.2599
##   91.3    525       5  0.24189 0.007753     0.227165       0.2576
##   91.4    518       6  0.23909 0.007747     0.224380       0.2548
##   91.5    509       7  0.23580 0.007740     0.221112       0.2515
##   91.6    498       7  0.23249 0.007731     0.217819       0.2481
##   91.7    487       5  0.23010 0.007725     0.215448       0.2458
##   91.8    481       4  0.22819 0.007720     0.213548       0.2438
##   91.8    475       7  0.22483 0.007710     0.210210       0.2405
##   91.9    466      11  0.21952 0.007693     0.204948       0.2351
##   92.0    454       5  0.21710 0.007683     0.202552       0.2327
##   92.1    446       5  0.21467 0.007674     0.200141       0.2302
##   92.2    435      10  0.20973 0.007655     0.195253       0.2253
##   92.2    422       4  0.20774 0.007646     0.193285       0.2233
##   92.3    416       7  0.20425 0.007631     0.189827       0.2198
##   92.4    408       3  0.20275 0.007624     0.188341       0.2183
##   92.5    402       4  0.20073 0.007615     0.186346       0.2162
##   92.6    396       8  0.19667 0.007595     0.182339       0.2121
##   92.7    385       5  0.19412 0.007581     0.179815       0.2096
##   92.8    379       9  0.18951 0.007555     0.175266       0.2049
##   92.8    369       3  0.18797 0.007546     0.173746       0.2034
##   92.9    362       4  0.18589 0.007534     0.171698       0.2013
##   93.0    355       6  0.18275 0.007515     0.168600       0.1981
##   93.1    347       6  0.17959 0.007495     0.165486       0.1949
##   93.2    339       6  0.17641 0.007474     0.162356       0.1917
##   93.2    332       4  0.17429 0.007459     0.160264       0.1895
##   93.3    326       3  0.17268 0.007447     0.158686       0.1879
##   93.4    322       3  0.17107 0.007436     0.157104       0.1863
##   93.5    318       2  0.17000 0.007428     0.156046       0.1852
##   93.6    313       9  0.16511 0.007391     0.151241       0.1803
##   93.7    303       5  0.16239 0.007369     0.148567       0.1775
##   93.8    296       3  0.16074 0.007355     0.146952       0.1758
##   93.8    290       4  0.15852 0.007337     0.144776       0.1736
##   93.9    285       3  0.15685 0.007322     0.143139       0.1719
##   94.0    281       7  0.15295 0.007287     0.139310       0.1679
##   94.1    273       5  0.15015 0.007261     0.136568       0.1651
##   94.2    268       4  0.14790 0.007238     0.134377       0.1628
##   94.2    264       4  0.14566 0.007215     0.132187       0.1605
##   94.3    259       3  0.14398 0.007197     0.130540       0.1588
##   94.4    255       2  0.14285 0.007184     0.129437       0.1576
##   94.5    253       3  0.14115 0.007166     0.127785       0.1559
##   94.6    248       4  0.13888 0.007140     0.125565       0.1536
##   94.7    241       2  0.13772 0.007127     0.124440       0.1524
##   94.8    237       2  0.13656 0.007114     0.123307       0.1512
##   94.8    235       7  0.13249 0.007066     0.119343       0.1471
##   94.9    227       9  0.12724 0.007000     0.114235       0.1417
##   95.0    215       8  0.12251 0.006936     0.109638       0.1369
##   95.1    206       3  0.12072 0.006912     0.107908       0.1351
##   95.2    203       6  0.11715 0.006859     0.104453       0.1314
##   95.2    196       3  0.11536 0.006832     0.102719       0.1296
##   95.3    191       3  0.11355 0.006804     0.100966       0.1277
##   95.4    188       3  0.11174 0.006775     0.099216       0.1258
##   95.5    184       1  0.11113 0.006766     0.098630       0.1252
##   95.6    183       1  0.11052 0.006756     0.098043       0.1246
##   95.7    181       2  0.10930 0.006736     0.096864       0.1233
##   95.8    177       5  0.10621 0.006686     0.093885       0.1202
##   95.8    171       3  0.10435 0.006655     0.092089       0.1182
##   95.9    168       3  0.10249 0.006622     0.090296       0.1163
##   96.0    165       3  0.10062 0.006589     0.088504       0.1144
##   96.1    162       3  0.09876 0.006554     0.086715       0.1125
##   96.2    158       2  0.09751 0.006530     0.085515       0.1112
##   96.2    156       4  0.09501 0.006481     0.083119       0.1086
##   96.3    152       1  0.09438 0.006469     0.082520       0.1080
##   96.5    148       1  0.09375 0.006456     0.081909       0.1073
##   96.6    144       2  0.09244 0.006432     0.080660       0.1060
##   96.7    139       5  0.08912 0.006370     0.077469       0.1025
##   97.0    132       2  0.08777 0.006345     0.076174       0.1011
##   97.1    129       1  0.08709 0.006332     0.075522       0.1004
##   97.2    127       2  0.08572 0.006306     0.074207       0.0990
##   97.2    122       1  0.08501 0.006294     0.073533       0.0983
##   97.3    120       3  0.08289 0.006255     0.071494       0.0961
##   97.4    117       3  0.08076 0.006214     0.069459       0.0939
##   97.5    113       3  0.07862 0.006171     0.067410       0.0917
##   97.6    108       3  0.07644 0.006127     0.065323       0.0894
##   97.7    103       1  0.07569 0.006112     0.064614       0.0887
##   97.8    101       4  0.07270 0.006051     0.061753       0.0856
##   97.8     97       3  0.07045 0.006001     0.059615       0.0832
##   98.1     91       1  0.06967 0.005985     0.058877       0.0824
##   98.2     89       3  0.06732 0.005935     0.056642       0.0800
##   98.2     86       4  0.06419 0.005862     0.053674       0.0768
##   98.3     80       1  0.06339 0.005843     0.052913       0.0759
##   98.4     79       2  0.06179 0.005805     0.051396       0.0743
##   98.6     77       1  0.06098 0.005784     0.050638       0.0734
##   98.7     76       2  0.05938 0.005742     0.049127       0.0718
##   98.8     74       2  0.05777 0.005698     0.047619       0.0701
##   98.8     72       2  0.05617 0.005652     0.046116       0.0684
##   98.9     70       1  0.05537 0.005628     0.045366       0.0676
##   99.1     68       1  0.05455 0.005604     0.044605       0.0667
##   99.2     67       2  0.05292 0.005553     0.043086       0.0650
##   99.2     65       1  0.05211 0.005527     0.042329       0.0642
##   99.6     61       1  0.05126 0.005502     0.041531       0.0633
##   99.8     60       2  0.04955 0.005450     0.039939       0.0615
##  100.0     57       2  0.04781 0.005395     0.038322       0.0596
##  100.1     54       1  0.04692 0.005368     0.037499       0.0587
##  100.2     53       1  0.04604 0.005339     0.036678       0.0578
##  100.2     52       1  0.04515 0.005309     0.035859       0.0569
##  100.3     51       1  0.04427 0.005278     0.035042       0.0559
##  100.7     48       1  0.04335 0.005248     0.034188       0.0550
##  100.8     47       1  0.04242 0.005217     0.033337       0.0540
##  101.1     46       1  0.04150 0.005185     0.032488       0.0530
##  101.2     44       2  0.03961 0.005118     0.030753       0.0510
##  101.3     41       3  0.03672 0.005009     0.028101       0.0480
##  101.4     38       1  0.03575 0.004970     0.027223       0.0469
##  101.6     36       1  0.03476 0.004930     0.026321       0.0459
##  101.7     34       1  0.03373 0.004890     0.025391       0.0448
##  101.8     33       1  0.03271 0.004847     0.024467       0.0437
##  101.9     31       2  0.03060 0.004759     0.022562       0.0415
##  102.0     29       2  0.02849 0.004659     0.020679       0.0393
##  102.1     27       3  0.02533 0.004485     0.017898       0.0358
##  102.3     24       1  0.02427 0.004421     0.016984       0.0347
##  102.4     23       2  0.02216 0.004281     0.015175       0.0324
##  102.7     20       1  0.02105 0.004208     0.014228       0.0311
##  103.0     18       1  0.01988 0.004133     0.013228       0.0299
##  103.1     17       1  0.01871 0.004052     0.012241       0.0286
##  103.4     16       1  0.01754 0.003964     0.011266       0.0273
##  103.5     15       1  0.01637 0.003869     0.010305       0.0260
##  104.2     14       1  0.01520 0.003765     0.009358       0.0247
##  105.0     10       1  0.01368 0.003683     0.008075       0.0232
##  106.1      9       1  0.01216 0.003574     0.006839       0.0216
##  106.2      8       1  0.01064 0.003435     0.005654       0.0200
##  106.3      7       1  0.00912 0.003264     0.004525       0.0184
##  107.0      4       1  0.00684 0.003145     0.002779       0.0168
##  109.9      3       1  0.00456 0.002804     0.001367       0.0152
##  113.0      2       1  0.00228 0.002137     0.000363       0.0143
km_table <- summary(km_fit)

cumulative hazard function

# Extract cumulative hazard from the Kaplan-Meier fit
km_summary <- summary(km_fit)

# Cumulative hazard can be computed as: -log(survival probability)
cum_hazard <- -log(km_summary$surv)

# Plot cumulative hazard
plot(km_summary$time, cum_hazard, type = "s", 
     xlab = "Time", ylab = "Cumulative Hazard", 
     main = "Cumulative Hazard Function")

### Plot Kaplan-Meier survival curve

library(survminer)
## Loading required package: ggpubr
## 
## Attaching package: 'survminer'
## The following object is masked from 'package:survival':
## 
##     myeloma
ggsurvplot(km_fit, 
           risk.table = TRUE, 
           conf.int = TRUE, 
           xlab = "Age", 
           ylab = "Survival Probability",
           title = "Kaplan-Meier Survival Curve")

#### Smoothed hazard estimate

# Calculate the smoothed hazard function
# Hazard estimate: hazard = (n.event / n.risk)

km_summary <- summary(km_fit)
hazard <- km_summary$n.event / km_summary$n.risk

# Create a data frame for plotting
hazard_data <- data.frame(
  time = km_summary$time,
  hazard = hazard
)

# Plot the hazard function with a smooth line
ggplot(hazard_data, aes(x = time, y = hazard)) +
  geom_line(color = "blue") +  # Original hazard step line
  geom_smooth(method = "loess", color = "red", se = FALSE) +  # Smoothed line
  labs(title = "Smoothed Hazard Function", x = "Time", y = "Hazard Rate")
## `geom_smooth()` using formula = 'y ~ x'

### by Gender

# Kaplan-Meier by gender
km_fit_gender <- survfit(Surv(agecensor, died0121) ~ female, data = data2)

# Plot survival by gender
ggsurvplot(km_fit_gender, 
           conf.int = TRUE, 
           pval = TRUE,  # Include p-value for statistical significance
           legend.labs = c("Male", "Female"),
           title = "Survival by Gender",
           xlab = "Age", 
           ylab = "Survival Probability")

by locality size

km_fit_locsize <- survfit(Surv(agecensor, died0121) ~ locsize01, data = data2)

# Plot survival by locality size
ggsurvplot(km_fit_locsize, 
           conf.int = TRUE, 
           pval = TRUE, 
           legend.labs = c("100,000+", "15,000 - 99,999", "2,500 - 14,999", "<2,500"),
           title = "Survival by Locality Size",
           xlab = "Age", 
           ylab = "Survival Probability")

by schooling level

km_fit_schooling <- survfit(Surv(agecensor, died0121) ~ educlevel, data = data2)

# Plot survival by schooling level
ggsurvplot(km_fit_schooling, 
           conf.int = TRUE, 
           pval = TRUE, 
           legend.labs = c("No schooling", "1-5 years", "6-8 years", "9+ years"),
           title = "Survival by Schooling Level",
           xlab = "Age", 
           ylab = "Survival Probability")

### Statistical Test to Compare Survival Between Groups

# Log-rank test for gender
survdiff(Surv(agecensor, died0121) ~ female, data = data2)
## Call:
## survdiff(formula = Surv(agecensor, died0121) ~ female, data = data2)
## 
## n=7565, 2071 observations deleted due to missingness.
## 
##             N Observed Expected (O-E)^2/E (O-E)^2/V
## female=0 3450     1898     1645      39.0        67
## female=1 4115     2096     2349      27.3        67
## 
##  Chisq= 67  on 1 degrees of freedom, p= 3e-16

Interpretation: For males, the observed number of deaths (1,898) exceeds the expected number (1,645), while for females, the observed deaths (2,096) fall below the expected count (2,349). This indicates that males have a higher-than-expected mortality rate, whereas females have a lower-than-expected rate. The Chi-square statistic of 67 shows a significant difference between the survival curves for males and females.The extremely small p-value (3e-16) confirms that this difference is highly statistically significant, far below the typical threshold of 0.05, suggesting a clear survival difference between genders in the dataset.

# Log-rank test for locality size
survdiff(Surv(agecensor, died0121) ~ locsize01, data = data2)
## Call:
## survdiff(formula = Surv(agecensor, died0121) ~ locsize01, data = data2)
## 
## n=7565, 2071 observations deleted due to missingness.
## 
##                              N Observed Expected (O-E)^2/E (O-E)^2/V
## locsize01=< 2,500         1309      690      767      7.74      9.65
## locsize01=100,000 - +     4350     2266     2194      2.38      5.31
## locsize01=15,000 - 99,999 1167      627      599      1.35      1.59
## locsize01=2,500 - 14,999   739      411      435      1.28      1.44
## 
##  Chisq= 12.9  on 3 degrees of freedom, p= 0.005

Interpretation: The log-rank test indicates a difference in survival across the four locality size groups (p = 0.005). Individuals in rural areas (< 2,500 inhabitants) and small urban areas (2,500-14,999 inhabitants) show slightly lower mortality rates than expected, while those in large urban areas (100,000+ inhabitants) exhibit a slightly higher mortality rate. In medium urban areas (15,000-99,999 inhabitants), the survival rates closely align with expectations. Overall, the results suggest that locality size influences mortality, with distinct survival patterns across rural, small urban, medium urban, and large urban areas.

# Log-rank test for schooling level
survdiff(Surv(agecensor, died0121) ~ educlevel, data = data2)
## Call:
## survdiff(formula = Surv(agecensor, died0121) ~ educlevel, data = data2)
## 
## n=7552, 2084 observations deleted due to missingness.
## 
##                  N Observed Expected (O-E)^2/E (O-E)^2/V
## educlevel=0   2024     1275     1411    13.121    21.128
## educlevel=15  2676     1461     1439     0.344     0.542
## educlevel=68  1620      759      677     9.929    12.154
## educlevel=919 1232      488      456     2.223     2.557
## 
##  Chisq= 26.8  on 3 degrees of freedom, p= 6e-06

Interpretation: The Chi-square statistic of 26.8 indicates a significant difference in survival rates across the four education levels. The p-value (6e-06) is exceptionally small, far below the standard significance threshold of 0.05, highlighting a highly statistically significant difference in survival among the education groups.

Longitudinal vs Synthetic cohort approach

The analysis is mainly longitudinal, tracking the same individuals over multiple waves (2001, 2003, 2012, 2015, 2018, and 2021) to collect data on their survival status over time. However, it also incorporates a synthetic cohort element by adding new individuals in subsequent waves to maintain representativeness of the 50+ population. Refresher samples were drawn in 2012 (ages 50-61) and 2018 (ages 50-56), introducing new participants, which mirrors the synthetic cohort approach. Therefore, the study can be considered a combination of both longitudinal and synthetic cohort methods.