get_hazard_1d()
takes as input the results of a model
estimated by fit1ts
and it returns the estimated values of the smooth log-hazard
and the smooth hazard together with their standard errors.
If the model includes covariates, then only the baseline (log-)hazard is returned. It is possible to provide values that define a new grid for evaluation of the estimated hazard. If not specified, the hazard is evaluated on the same grid used for the binning of the data, and therefore the estimation of the model. The function will check if the parameters for the new grid provided by the user are compatible with those originally used to construct the B-splines for estimating the model. If not, the grid will be adjusted accordingly and a warning will be returned.
Arguments
- fitted_model
is an object of class
"haz1ts"
, the output of the functionfit1ts()
.- plot_grid
(optional) A named vector containing the parameters to build a new grid of intervals over
s
for plotting the estimated hazard on a finer grid. This must be of the form:plot_grid = c(smin, smax, ds)
, wheresmin
,smax
are the minimum and maximum values desired for the intervals overs
, andds
is the distance between intervals overs
. If not specified, the plotting is done using the same B-splines basis as for the estimation. The function will check if the parameters for the grid provided by the user are compatible with those originally used to construct the B-splines for estimating the model. If not, the grid will be adjusted accordingly and a warning will be returned.
Value
A list with the following elements:
new_plot_grid
A list of parameters that specify the new grid, of the form list("ints", "smin", "smax", "ds")hazard
A vector containing the estimated hazard values.loghazard
A vector containing the estimated log-hazard values.log10hazard
A vector containing the estimated log10-hazard values.SE_hazard
A vector containing the estimated SEs for the hazard.SE_loghazard
A vector containing the estimated SEs for the log-hazard.SE_log10hazard
A vector containing the estimated SEs for the log10-hazard.
Examples
## preparing data - no covariates
dt1ts <- prepare_data(
data = reccolon2ts,
s_in = "entrys",
s_out = "timesr",
events = "status",
ds = 180
)
## fitting the model with fit1ts() - default options
mod1 <- fit1ts(dt1ts)
# Obtain 1d hazard
get_hazard_1d(mod1)
#> $new_plot_grid
#> $new_plot_grid$ints
#> [1] 90 270 450 630 810 990 1170 1350 1530 1710 1890 2070 2250 2430 2610
#> [16] 2790
#>
#> $new_plot_grid$smin
#> [1] 0
#>
#> $new_plot_grid$smax
#> [1] 2880
#>
#> $new_plot_grid$ds
#> [1] 180
#>
#>
#> $hazard
#> [,1]
#> [1,] 0.0016988333
#> [2,] 0.0019695613
#> [3,] 0.0021209669
#> [4,] 0.0020828343
#> [5,] 0.0018476973
#> [6,] 0.0014788553
#> [7,] 0.0011208230
#> [8,] 0.0008589210
#> [9,] 0.0006857186
#> [10,] 0.0005704956
#> [11,] 0.0004843834
#> [12,] 0.0004147194
#> [13,] 0.0003556485
#> [14,] 0.0003044944
#> [15,] 0.0002602157
#> [16,] 0.0002222208
#>
#> $loghazard
#> [,1]
#> [1,] -6.377814
#> [2,] -6.229944
#> [3,] -6.155883
#> [4,] -6.174026
#> [5,] -6.293815
#> [6,] -6.516487
#> [7,] -6.793692
#> [8,] -7.059834
#> [9,] -7.285043
#> [10,] -7.469005
#> [11,] -7.632634
#> [12,] -7.787908
#> [13,] -7.941568
#> [14,] -8.096858
#> [15,] -8.254000
#> [16,] -8.411839
#>
#> $log10hazard
#> [,1]
#> [1,] -2.769849
#> [2,] -2.705630
#> [3,] -2.673466
#> [4,] -2.681345
#> [5,] -2.733369
#> [6,] -2.830074
#> [7,] -2.950463
#> [8,] -3.066047
#> [9,] -3.163854
#> [10,] -3.243748
#> [11,] -3.314811
#> [12,] -3.382246
#> [13,] -3.448979
#> [14,] -3.516421
#> [15,] -3.584666
#> [16,] -3.653215
#>
#> $SE_hazard
#> [,1]
#> [1,] 0.0002161506
#> [2,] 0.0001986968
#> [3,] 0.0002119584
#> [4,] 0.0002286974
#> [5,] 0.0002340677
#> [6,] 0.0002211469
#> [7,] 0.0001985653
#> [8,] 0.0001798950
#> [9,] 0.0001718013
#> [10,] 0.0001761723
#> [11,] 0.0001915551
#> [12,] 0.0002151796
#> [13,] 0.0002431200
#> [14,] 0.0002708438
#> [15,] 0.0002951042
#> [16,] 0.0003141728
#>
#> $SE_loghazard
#> [,1]
#> [1,] 0.12723475
#> [2,] 0.10088377
#> [3,] 0.09993482
#> [4,] 0.10980104
#> [5,] 0.12668078
#> [6,] 0.14953926
#> [7,] 0.17716029
#> [8,] 0.20944295
#> [9,] 0.25054203
#> [10,] 0.30880568
#> [11,] 0.39546162
#> [12,] 0.51885596
#> [13,] 0.68359643
#> [14,] 0.88948704
#> [15,] 1.13407509
#> [16,] 1.41378670
#>
#> $SE_log10hazard
#> [,1]
#> [1,] 0.05525735
#> [2,] 0.04381326
#> [3,] 0.04340114
#> [4,] 0.04768599
#> [5,] 0.05501676
#> [6,] 0.06494408
#> [7,] 0.07693974
#> [8,] 0.09095992
#> [9,] 0.10880902
#> [10,] 0.13411260
#> [11,] 0.17174680
#> [12,] 0.22533628
#> [13,] 0.29688216
#> [14,] 0.38629931
#> [15,] 0.49252255
#> [16,] 0.61399976
#>
# Change grid
get_hazard_1d(mod1,
plot_grid = c(smin = 0, smax = 2730, ds = 30)
)
#> $new_plot_grid
#> $new_plot_grid$ints
#> [1] 0 30 60 90 120 150 180 210 240 270 300 330 360 390 420
#> [16] 450 480 510 540 570 600 630 660 690 720 750 780 810 840 870
#> [31] 900 930 960 990 1020 1050 1080 1110 1140 1170 1200 1230 1260 1290 1320
#> [46] 1350 1380 1410 1440 1470 1500 1530 1560 1590 1620 1650 1680 1710 1740 1770
#> [61] 1800 1830 1860 1890 1920 1950 1980 2010 2040 2070 2100 2130 2160 2190 2220
#> [76] 2250 2280 2310 2340 2370 2400 2430 2460 2490 2520 2550 2580 2610 2640 2670
#> [91] 2700 2730
#>
#> $new_plot_grid$smin
#> smin
#> 0
#>
#> $new_plot_grid$smax
#> smax
#> 2730
#>
#> $new_plot_grid$ds
#> ds
#> 30
#>
#>
#> $hazard
#> [,1]
#> [1,] 0.0015531449
#> [2,] 0.0016039464
#> [3,] 0.0016553387
#> [4,] 0.0017068761
#> [5,] 0.0017580617
#> [6,] 0.0018083487
#> [7,] 0.0018571420
#> [8,] 0.0019038023
#> [9,] 0.0019476517
#> [10,] 0.0019879819
#> [11,] 0.0020241054
#> [12,] 0.0020555587
#> [13,] 0.0020819756
#> [14,] 0.0021030190
#> [15,] 0.0021183879
#> [16,] 0.0021278224
#> [17,] 0.0021311093
#> [18,] 0.0021280874
#> [19,] 0.0021186510
#> [20,] 0.0021027599
#> [21,] 0.0020804771
#> [22,] 0.0020519454
#> [23,] 0.0020173666
#> [24,] 0.0019770000
#> [25,] 0.0019311584
#> [26,] 0.0018802047
#> [27,] 0.0018245467
#> [28,] 0.0017646315
#> [29,] 0.0017009838
#> [30,] 0.0016345851
#> [31,] 0.0015666028
#> [32,] 0.0014980900
#> [33,] 0.0014299740
#> [34,] 0.0013630548
#> [35,] 0.0012980070
#> [36,] 0.0012353868
#> [37,] 0.0011756410
#> [38,] 0.0011191065
#> [39,] 0.0010658700
#> [40,] 0.0010158559
#> [41,] 0.0009689748
#> [42,] 0.0009251306
#> [43,] 0.0008842219
#> [44,] 0.0008461449
#> [45,] 0.0008107949
#> [46,] 0.0007780681
#> [47,] 0.0007478591
#> [48,] 0.0007199763
#> [49,] 0.0006941594
#> [50,] 0.0006701727
#> [51,] 0.0006478056
#> [52,] 0.0006268694
#> [53,] 0.0006071944
#> [54,] 0.0005886277
#> [55,] 0.0005710313
#> [56,] 0.0005542805
#> [57,] 0.0005382807
#> [58,] 0.0005229690
#> [59,] 0.0005082888
#> [60,] 0.0004941878
#> [61,] 0.0004806180
#> [62,] 0.0004675349
#> [63,] 0.0004548976
#> [64,] 0.0004426683
#> [65,] 0.0004308121
#> [66,] 0.0004193013
#> [67,] 0.0004081174
#> [68,] 0.0003972437
#> [69,] 0.0003866646
#> [70,] 0.0003763654
#> [71,] 0.0003663324
#> [72,] 0.0003565528
#> [73,] 0.0003470145
#> [74,] 0.0003377063
#> [75,] 0.0003286199
#> [76,] 0.0003197528
#> [77,] 0.0003111027
#> [78,] 0.0003026673
#> [79,] 0.0002944441
#> [80,] 0.0002864304
#> [81,] 0.0002786234
#> [82,] 0.0002710201
#> [83,] 0.0002636175
#> [84,] 0.0002564122
#> [85,] 0.0002493996
#> [86,] 0.0002425753
#> [87,] 0.0002359348
#> [88,] 0.0002294736
#> [89,] 0.0002231875
#> [90,] 0.0002170721
#> [91,] 0.0002111234
#> [92,] 0.0002053373
#>
#> $loghazard
#> [,1]
#> [1,] -6.467473
#> [2,] -6.435288
#> [3,] -6.403750
#> [4,] -6.373090
#> [5,] -6.343543
#> [6,] -6.315341
#> [7,] -6.288717
#> [8,] -6.263902
#> [9,] -6.241131
#> [10,] -6.220635
#> [11,] -6.202627
#> [12,] -6.187208
#> [13,] -6.174438
#> [14,] -6.164381
#> [15,] -6.157100
#> [16,] -6.152656
#> [17,] -6.151113
#> [18,] -6.152532
#> [19,] -6.156976
#> [20,] -6.164505
#> [21,] -6.175158
#> [22,] -6.188967
#> [23,] -6.205962
#> [24,] -6.226175
#> [25,] -6.249635
#> [26,] -6.276375
#> [27,] -6.306424
#> [28,] -6.339813
#> [29,] -6.376548
#> [30,] -6.416366
#> [31,] -6.458846
#> [32,] -6.503564
#> [33,] -6.550099
#> [34,] -6.598027
#> [35,] -6.646925
#> [36,] -6.696371
#> [37,] -6.745942
#> [38,] -6.795225
#> [39,] -6.843964
#> [40,] -6.892024
#> [41,] -6.939272
#> [42,] -6.985576
#> [43,] -7.030802
#> [44,] -7.074820
#> [45,] -7.117495
#> [46,] -7.158696
#> [47,] -7.198296
#> [48,] -7.236292
#> [49,] -7.272809
#> [50,] -7.307975
#> [51,] -7.341920
#> [52,] -7.374772
#> [53,] -7.406662
#> [54,] -7.437717
#> [55,] -7.468067
#> [56,] -7.497840
#> [57,] -7.527130
#> [58,] -7.555988
#> [59,] -7.584461
#> [60,] -7.612595
#> [61,] -7.640438
#> [62,] -7.668037
#> [63,] -7.695438
#> [64,] -7.722690
#> [65,] -7.749838
#> [66,] -7.776921
#> [67,] -7.803956
#> [68,] -7.830961
#> [69,] -7.857953
#> [70,] -7.884950
#> [71,] -7.911969
#> [72,] -7.939028
#> [73,] -7.966144
#> [74,] -7.993334
#> [75,] -8.020609
#> [76,] -8.047962
#> [77,] -8.075387
#> [78,] -8.102876
#> [79,] -8.130421
#> [80,] -8.158015
#> [81,] -8.185650
#> [82,] -8.213318
#> [83,] -8.241011
#> [84,] -8.268724
#> [85,] -8.296454
#> [86,] -8.324198
#> [87,] -8.351955
#> [88,] -8.379723
#> [89,] -8.407499
#> [90,] -8.435281
#> [91,] -8.463068
#> [92,] -8.490857
#>
#> $log10hazard
#> [,1]
#> [1,] -2.808788
#> [2,] -2.794810
#> [3,] -2.781113
#> [4,] -2.767798
#> [5,] -2.754966
#> [6,] -2.742718
#> [7,] -2.731155
#> [8,] -2.720378
#> [9,] -2.710489
#> [10,] -2.701588
#> [11,] -2.693767
#> [12,] -2.687070
#> [13,] -2.681524
#> [14,] -2.677157
#> [15,] -2.673995
#> [16,] -2.672065
#> [17,] -2.671394
#> [18,] -2.672011
#> [19,] -2.673941
#> [20,] -2.677210
#> [21,] -2.681837
#> [22,] -2.687834
#> [23,] -2.695215
#> [24,] -2.703993
#> [25,] -2.714182
#> [26,] -2.725795
#> [27,] -2.738845
#> [28,] -2.753346
#> [29,] -2.769300
#> [30,] -2.786592
#> [31,] -2.805041
#> [32,] -2.824462
#> [33,] -2.844672
#> [34,] -2.865487
#> [35,] -2.886723
#> [36,] -2.908197
#> [37,] -2.929725
#> [38,] -2.951129
#> [39,] -2.972296
#> [40,] -2.993168
#> [41,] -3.013687
#> [42,] -3.033797
#> [43,] -3.053439
#> [44,] -3.072555
#> [45,] -3.091089
#> [46,] -3.108982
#> [47,] -3.126180
#> [48,] -3.142682
#> [49,] -3.158541
#> [50,] -3.173813
#> [51,] -3.188555
#> [52,] -3.202823
#> [53,] -3.216672
#> [54,] -3.230159
#> [55,] -3.243340
#> [56,] -3.256270
#> [57,] -3.268991
#> [58,] -3.281524
#> [59,] -3.293889
#> [60,] -3.306108
#> [61,] -3.318200
#> [62,] -3.330186
#> [63,] -3.342086
#> [64,] -3.353922
#> [65,] -3.365712
#> [66,] -3.377474
#> [67,] -3.389215
#> [68,] -3.400943
#> [69,] -3.412666
#> [70,] -3.424390
#> [71,] -3.436125
#> [72,] -3.447876
#> [73,] -3.459652
#> [74,] -3.471461
#> [75,] -3.483306
#> [76,] -3.495186
#> [77,] -3.507096
#> [78,] -3.519034
#> [79,] -3.530997
#> [80,] -3.542981
#> [81,] -3.554982
#> [82,] -3.566998
#> [83,] -3.579026
#> [84,] -3.591061
#> [85,] -3.603104
#> [86,] -3.615153
#> [87,] -3.627208
#> [88,] -3.639267
#> [89,] -3.651330
#> [90,] -3.663396
#> [91,] -3.675464
#> [92,] -3.687532
#>
#> $SE_hazard
#> [,1]
#> [1,] 0.0002526441
#> [2,] 0.0002372673
#> [3,] 0.0002246832
#> [4,] 0.0002147725
#> [5,] 0.0002073793
#> [6,] 0.0002023037
#> [7,] 0.0001992950
#> [8,] 0.0001980467
#> [9,] 0.0001981939
#> [10,] 0.0001993134
#> [11,] 0.0002009861
#> [12,] 0.0002030734
#> [13,] 0.0002055275
#> [14,] 0.0002082876
#> [15,] 0.0002112807
#> [16,] 0.0002144226
#> [17,] 0.0002176193
#> [18,] 0.0002207690
#> [19,] 0.0002237643
#> [20,] 0.0002264999
#> [21,] 0.0002289078
#> [22,] 0.0002309377
#> [23,] 0.0002325399
#> [24,] 0.0002336667
#> [25,] 0.0002342735
#> [26,] 0.0002343199
#> [27,] 0.0002337709
#> [28,] 0.0002325976
#> [29,] 0.0002307838
#> [30,] 0.0002283782
#> [31,] 0.0002254682
#> [32,] 0.0002221440
#> [33,] 0.0002184965
#> [34,] 0.0002146153
#> [35,] 0.0002105877
#> [36,] 0.0002064975
#> [37,] 0.0002024245
#> [38,] 0.0001984429
#> [39,] 0.0001946117
#> [40,] 0.0001909752
#> [41,] 0.0001875715
#> [42,] 0.0001844333
#> [43,] 0.0001815892
#> [44,] 0.0001790646
#> [45,] 0.0001768820
#> [46,] 0.0001750624
#> [47,] 0.0001736254
#> [48,] 0.0001725819
#> [49,] 0.0001719333
#> [50,] 0.0001716781
#> [51,] 0.0001718129
#> [52,] 0.0001723322
#> [53,] 0.0001732289
#> [54,] 0.0001744938
#> [55,] 0.0001761160
#> [56,] 0.0001780824
#> [57,] 0.0001803783
#> [58,] 0.0001829888
#> [59,] 0.0001858988
#> [60,] 0.0001890928
#> [61,] 0.0001925550
#> [62,] 0.0001962690
#> [63,] 0.0002002180
#> [64,] 0.0002043844
#> [65,] 0.0002087499
#> [66,] 0.0002132913
#> [67,] 0.0002179789
#> [68,] 0.0002227841
#> [69,] 0.0002276794
#> [70,] 0.0002326386
#> [71,] 0.0002376368
#> [72,] 0.0002426501
#> [73,] 0.0002476557
#> [74,] 0.0002526318
#> [75,] 0.0002575576
#> [76,] 0.0002624145
#> [77,] 0.0002671857
#> [78,] 0.0002718561
#> [79,] 0.0002764125
#> [80,] 0.0002808430
#> [81,] 0.0002851375
#> [82,] 0.0002892872
#> [83,] 0.0002932846
#> [84,] 0.0002971232
#> [85,] 0.0003007962
#> [86,] 0.0003042976
#> [87,] 0.0003076224
#> [88,] 0.0003107666
#> [89,] 0.0003137270
#> [90,] 0.0003165012
#> [91,] 0.0003190876
#> [92,] 0.0003214851
#>
#> $SE_loghazard
#> [,1]
#> [1,] 0.16266613
#> [2,] 0.14792720
#> [3,] 0.13573247
#> [4,] 0.12582780
#> [5,] 0.11795905
#> [6,] 0.11187207
#> [7,] 0.10731274
#> [8,] 0.10402691
#> [9,] 0.10176043
#> [10,] 0.10025918
#> [11,] 0.09929628
#> [12,] 0.09879233
#> [13,] 0.09871755
#> [14,] 0.09904221
#> [15,] 0.09973657
#> [16,] 0.10077091
#> [17,] 0.10211549
#> [18,] 0.10374057
#> [19,] 0.10561642
#> [20,] 0.10771552
#> [21,] 0.11002661
#> [22,] 0.11254575
#> [23,] 0.11526904
#> [24,] 0.11819256
#> [25,] 0.12131241
#> [26,] 0.12462468
#> [27,] 0.12812546
#> [28,] 0.13181083
#> [29,] 0.13567666
#> [30,] 0.13971632
#> [31,] 0.14392175
#> [32,] 0.14828484
#> [33,] 0.15279752
#> [34,] 0.15745168
#> [35,] 0.16223925
#> [36,] 0.16715212
#> [37,] 0.17218221
#> [38,] 0.17732264
#> [39,] 0.18258487
#> [40,] 0.18799443
#> [41,] 0.19357722
#> [42,] 0.19935915
#> [43,] 0.20536612
#> [44,] 0.21162402
#> [45,] 0.21815877
#> [46,] 0.22499625
#> [47,] 0.23216320
#> [48,] 0.23970498
#> [49,] 0.24768563
#> [50,] 0.25616999
#> [51,] 0.26522293
#> [52,] 0.27490929
#> [53,] 0.28529392
#> [54,] 0.29644167
#> [55,] 0.30841739
#> [56,] 0.32128566
#> [57,] 0.33510080
#> [58,] 0.34990376
#> [59,] 0.36573463
#> [60,] 0.38263348
#> [61,] 0.40064038
#> [62,] 0.41979539
#> [63,] 0.44013860
#> [64,] 0.46171007
#> [65,] 0.48454969
#> [66,] 0.50868250
#> [67,] 0.53410838
#> [68,] 0.56082478
#> [69,] 0.58882917
#> [70,] 0.61811897
#> [71,] 0.64869165
#> [72,] 0.68054466
#> [73,] 0.71367544
#> [74,] 0.74808142
#> [75,] 0.78375533
#> [76,] 0.82067938
#> [77,] 0.85883437
#> [78,] 0.89820108
#> [79,] 0.93876032
#> [80,] 0.98049287
#> [81,] 1.02337954
#> [82,] 1.06740112
#> [83,] 1.11253840
#> [84,] 1.15877189
#> [85,] 1.20608119
#> [86,] 1.25444579
#> [87,] 1.30384513
#> [88,] 1.35425868
#> [89,] 1.40566590
#> [90,] 1.45804624
#> [91,] 1.51137918
#> [92,] 1.56564416
#>
#> $SE_log10hazard
#> [,1]
#> [1,] 0.07064500
#> [2,] 0.06424397
#> [3,] 0.05894786
#> [4,] 0.05464632
#> [5,] 0.05122896
#> [6,] 0.04858542
#> [7,] 0.04660533
#> [8,] 0.04517831
#> [9,] 0.04419400
#> [10,] 0.04354201
#> [11,] 0.04312383
#> [12,] 0.04290496
#> [13,] 0.04287249
#> [14,] 0.04301348
#> [15,] 0.04331504
#> [16,] 0.04376425
#> [17,] 0.04434819
#> [18,] 0.04505396
#> [19,] 0.04586863
#> [20,] 0.04678026
#> [21,] 0.04778395
#> [22,] 0.04887800
#> [23,] 0.05006071
#> [24,] 0.05133038
#> [25,] 0.05268531
#> [26,] 0.05412381
#> [27,] 0.05564418
#> [28,] 0.05724472
#> [29,] 0.05892362
#> [30,] 0.06067803
#> [31,] 0.06250442
#> [32,] 0.06439929
#> [33,] 0.06635912
#> [34,] 0.06838040
#> [35,] 0.07045961
#> [36,] 0.07259324
#> [37,] 0.07477778
#> [38,] 0.07701025
#> [39,] 0.07929560
#> [40,] 0.08164494
#> [41,] 0.08406952
#> [42,] 0.08658058
#> [43,] 0.08918937
#> [44,] 0.09190714
#> [45,] 0.09474515
#> [46,] 0.09771463
#> [47,] 0.10082720
#> [48,] 0.10410255
#> [49,] 0.10756850
#> [50,] 0.11125321
#> [51,] 0.11518486
#> [52,] 0.11939159
#> [53,] 0.12390158
#> [54,] 0.12874298
#> [55,] 0.13394397
#> [56,] 0.13953259
#> [57,] 0.14553243
#> [58,] 0.15196127
#> [59,] 0.15883653
#> [60,] 0.16617561
#> [61,] 0.17399590
#> [62,] 0.18231482
#> [63,] 0.19114976
#> [64,] 0.20051814
#> [65,] 0.21043726
#> [66,] 0.22091800
#> [67,] 0.23196032
#> [68,] 0.24356311
#> [69,] 0.25572526
#> [70,] 0.26844566
#> [71,] 0.28172320
#> [72,] 0.29555679
#> [73,] 0.30994530
#> [74,] 0.32488763
#> [75,] 0.34038062
#> [76,] 0.35641653
#> [77,] 0.37298703
#> [78,] 0.39008377
#> [79,] 0.40769843
#> [80,] 0.42582264
#> [81,] 0.44444809
#> [82,] 0.46356642
#> [83,] 0.48316929
#> [84,] 0.50324824
#> [85,] 0.52379441
#> [86,] 0.54479888
#> [87,] 0.56625275
#> [88,] 0.58814707
#> [89,] 0.61047294
#> [90,] 0.63322144
#> [91,] 0.65638364
#> [92,] 0.67995062
#>