Test of degrees of freedom (DFs) for Flexible Parametric Survival Models (FPMs).
Usage
fpm_test_dfs(
formula,
dfs_bh = 0,
dfs_tvc = NULL,
by_vars = NULL,
same_dfs_tvc = FALSE,
data,
control = list()
)
Arguments
- formula
A R-formula that is passed to the stpm2 call.
- dfs_bh
A vector of DFs to be tested for the baseline hazard function.
- dfs_tvc
A list of variables with a vector of DFs that should be tested for time varying effects, e.g.
list(case = 1:10, female = 1:3)
.- by_vars
A character vector of factor variable names used to fit stratified FPMs. One FPM will be fitted for each combination of factor levels specified. This is especially useful, when testing stratified FPMs.
- same_dfs_tvc
If
TRUE
no combinations of DFs between the different tvc variables will be tested. Instead only DFs from the minimum DF specified until the largest specified DF indfs_tvc
will be tested for all variables specified indfs_tvc
at the same time.- data
A data set that should be used to fit the FPM.
- control
An optional list of additional parameters passed to
rstpm2::stpm2()
.
Value
A data.frame
with one row per combination of baseline hazards
and tvc dfs and the corresponding AIC and BIC. If the by_vars
argument is specified a list
of data.frame
s with one data.frame
for each strata will be returned.
Examples
require(rstpm2)
data(brcancer)
data(colon)
fpm_test_dfs(Surv(rectime, censrec) ~ hormon + x1,
dfs_bh = 1:5,
dfs_tvc = list(hormon = 1:3,
x1 = 1:5),
data = brcancer)
#> df_bh df_tvc_hormon df_tvc_x1 aic bic
#> 1 1 1 1 5273.176 5300.361
#> 2 2 1 1 5225.531 5257.247
#> 3 3 1 1 5224.389 5260.636
#> 4 4 1 1 5224.228 5265.006
#> 5 5 1 1 5226.415 5271.724
#> 6 1 2 1 5261.060 5292.776
#> 7 2 2 1 5227.531 5263.778
#> 8 3 2 1 5226.337 5267.115
#> 9 4 2 1 5226.164 5271.472
#> 10 5 2 1 5228.339 5278.179
#> 11 1 3 1 5261.663 5297.910
#> 12 2 3 1 5227.806 5268.584
#> 13 3 3 1 5228.194 5273.502
#> 14 4 3 1 5228.085 5277.924
#> 15 5 3 1 5230.277 5284.647
#> 16 1 1 2 5229.449 5261.165
#> 17 2 1 2 5227.157 5263.404
#> 18 3 1 2 5226.353 5267.131
#> 19 4 1 2 5226.157 5271.465
#> 20 5 1 2 5228.360 5278.200
#> 21 1 2 2 5231.445 5267.692
#> 22 2 2 2 5229.140 5269.918
#> 23 3 2 2 5228.277 5273.586
#> 24 4 2 2 5228.055 5277.895
#> 25 5 2 2 5230.250 5284.620
#> 26 1 3 2 5231.557 5272.335
#> 27 2 3 2 5229.457 5274.766
#> 28 3 3 2 5230.125 5279.965
#> 29 4 3 2 5229.965 5284.336
#> 30 5 3 2 5232.179 5291.080
#> 31 1 1 3 5228.259 5264.506
#> 32 2 1 3 5226.579 5267.357
#> 33 3 1 3 5227.448 5272.757
#> 34 4 1 3 5227.309 5277.149
#> 35 5 1 3 5228.715 5283.086
#> 36 1 2 3 5230.238 5271.016
#> 37 2 2 3 5228.494 5273.803
#> 38 3 2 3 5229.349 5279.188
#> 39 4 2 3 5229.188 5283.559
#> 40 5 2 3 5230.588 5289.490
#> 41 1 3 3 5232.093 5277.402
#> 42 2 3 3 5230.253 5280.092
#> 43 3 3 3 5230.888 5285.258
#> 44 4 3 3 5230.882 5289.784
#> 45 5 3 3 5232.180 5295.613
#> 46 1 1 4 5226.623 5267.401
#> 47 2 1 4 5225.600 5270.908
#> 48 3 1 4 5226.557 5276.397
#> 49 4 1 4 5225.276 5279.646
#> 50 5 1 4 5227.164 5286.065
#> 51 1 2 4 5228.600 5273.909
#> 52 2 2 4 5227.508 5277.348
#> 53 3 2 4 5228.453 5282.824
#> 54 4 2 4 5227.152 5286.054
#> 55 5 2 4 5229.101 5292.534
#> 56 1 3 4 5230.539 5280.379
#> 57 2 3 4 5229.375 5283.746
#> 58 3 3 4 5230.244 5289.146
#> 59 4 3 4 5228.893 5292.326
#> 60 5 3 4 5230.801 5298.765
#> 61 1 1 5 5228.639 5273.947
#> 62 2 1 5 5227.720 5277.560
#> 63 3 1 5 5228.587 5282.958
#> 64 4 1 5 5229.706 5288.608
#> 65 5 1 5 5226.502 5289.934
#> 66 1 2 5 5230.604 5280.444
#> 67 2 2 5 5229.614 5283.984
#> 68 3 2 5 5230.454 5289.356
#> 69 4 2 5 5231.533 5294.966
#> 70 5 2 5 5228.395 5296.358
#> 71 1 3 5 5232.555 5286.925
#> 72 2 3 5 5231.497 5290.399
#> 73 3 3 5 5232.225 5295.657
#> 74 4 3 5 5233.331 5301.295
#> 75 5 3 5 5230.058 5302.552
fpm_test_dfs(Surv(rectime, censrec) ~ hormon + x1,
dfs_bh = 1:5,
dfs_tvc = list(hormon = 1:3,
x1 = 1:5),
same_dfs_tvc = TRUE,
data = brcancer)
#> df_bh df_tvc_hormon df_tvc_x1 aic bic
#> 1 1 1 1 5273.176 5300.361
#> 2 2 1 1 5225.531 5257.247
#> 3 3 1 1 5224.389 5260.636
#> 4 4 1 1 5224.228 5265.006
#> 5 5 1 1 5226.415 5271.724
#> 6 1 2 2 5231.445 5267.692
#> 7 2 2 2 5229.140 5269.918
#> 8 3 2 2 5228.277 5273.586
#> 9 4 2 2 5228.055 5277.895
#> 10 5 2 2 5230.250 5284.620
#> 11 1 3 3 5232.093 5277.402
#> 12 2 3 3 5230.253 5280.092
#> 13 3 3 3 5230.888 5285.258
#> 14 4 3 3 5230.882 5289.784
#> 15 5 3 3 5232.180 5295.613
#> 16 1 4 4 5231.859 5286.230
#> 17 2 4 4 5230.659 5289.560
#> 18 3 4 4 5231.398 5294.831
#> 19 4 4 4 5230.417 5298.380
#> 20 5 4 4 5232.231 5304.725
#> 21 1 5 5 5235.967 5299.399
#> 22 2 5 5 5234.843 5302.807
#> 23 3 5 5 5235.562 5308.056
#> 24 4 5 5 5236.779 5313.804
#> 25 5 5 5 5233.780 5315.336
fpm_test_dfs(Surv(surv_mm, status == "Dead: cancer") ~ age + year8594,
dfs_bh = 1:5,
dfs_tvc = list(age = 1:5,
year8594 = 1:5),
by_vars = c("sex", "stage"),
same_dfs_tvc = TRUE,
data = colon)
#> data$filter_vars: Female Distant
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 19910.36 19946.46
#> 2 2 1 1 19108.25 19150.36
#> 3 3 1 1 19103.12 19151.24
#> 4 4 1 1 19066.01 19120.15
#> 5 5 1 1 19056.21 19116.37
#> 6 1 2 2 19161.85 19209.97
#> 7 2 2 2 19083.41 19137.55
#> 8 3 2 2 19075.22 19135.37
#> 9 4 2 2 19046.74 19112.91
#> 10 5 2 2 19038.99 19111.17
#> 11 1 3 3 19157.92 19218.07
#> 12 2 3 3 19093.61 19159.78
#> 13 3 3 3 19079.55 19151.73
#> 14 4 3 3 19045.80 19124.00
#> 15 5 3 3 19039.36 19123.58
#> 16 1 4 4 19123.37 19195.55
#> 17 2 4 4 19050.70 19128.90
#> 18 3 4 4 19053.69 19137.90
#> 19 4 4 4 19052.60 19142.83
#> 20 5 4 4 19039.49 19135.74
#> 21 1 5 5 19114.91 19199.12
#> 22 2 5 5 19041.97 19132.20
#> 23 3 5 5 19045.82 19142.06
#> 24 4 5 5 19042.50 19144.76
#> 25 5 5 5 19047.11 19155.39
#> ------------------------------------------------------------
#> data$filter_vars: Female Localised
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 12816.17 12853.39
#> 2 2 1 1 12777.10 12820.53
#> 3 3 1 1 12757.68 12807.31
#> 4 4 1 1 12748.49 12804.32
#> 5 5 1 1 12726.04 12788.07
#> 6 1 2 2 12778.44 12828.07
#> 7 2 2 2 12757.54 12813.37
#> 8 3 2 2 12748.10 12810.13
#> 9 4 2 2 12741.36 12809.60
#> 10 5 2 2 12715.91 12790.35
#> 11 1 3 3 12770.15 12832.18
#> 12 2 3 3 12759.63 12827.87
#> 13 3 3 3 12713.68 12788.13
#> 14 4 3 3 12738.91 12819.56
#> 15 5 3 3 12695.52 12782.37
#> 16 1 4 4 12753.24 12827.69
#> 17 2 4 4 12739.71 12820.36
#> 18 3 4 4 12691.80 12778.65
#> 19 4 4 4 12710.48 12803.53
#> 20 5 4 4 12681.97 12781.23
#> 21 1 5 5 12733.72 12820.57
#> 22 2 5 5 12717.99 12811.04
#> 23 3 5 5 12681.77 12781.03
#> 24 4 5 5 12675.73 12781.19
#> 25 5 5 5 12689.82 12801.49
#> ------------------------------------------------------------
#> data$filter_vars: Female Regional
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 5952.186 5982.049
#> 2 2 1 1 5806.142 5840.983
#> 3 3 1 1 5793.497 5833.315
#> 4 4 1 1 5792.245 5837.040
#> 5 5 1 1 5795.235 5845.008
#> 6 1 2 2 5822.548 5862.366
#> 7 2 2 2 5790.532 5835.328
#> 8 3 2 2 5786.644 5836.416
#> 9 4 2 2 5785.365 5840.116
#> 10 5 2 2 5788.126 5847.854
#> 11 1 3 3 5809.844 5859.617
#> 12 2 3 3 5787.374 5842.124
#> 13 3 3 3 5789.635 5849.362
#> 14 4 3 3 5788.528 5853.232
#> 15 5 3 3 5791.095 5860.777
#> 16 1 4 4 5811.373 5871.101
#> 17 2 4 4 5790.004 5854.709
#> 18 3 4 4 5790.800 5860.481
#> 19 4 4 4 5790.946 5865.605
#> 20 5 4 4 5794.530 5874.167
#> 21 1 5 5 5812.406 5882.088
#> 22 2 5 5 5791.221 5865.880
#> 23 3 5 5 5792.403 5872.039
#> 24 4 5 5 5789.055 5873.669
#> 25 5 5 5 5793.863 5883.454
#> ------------------------------------------------------------
#> data$filter_vars: Female Unknown
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 7318.245 7350.007
#> 2 2 1 1 7056.949 7094.005
#> 3 3 1 1 7047.460 7089.810
#> 4 4 1 1 7034.825 7082.468
#> 5 5 1 1 7035.344 7088.281
#> 6 1 2 2 7057.288 7099.637
#> 7 2 2 2 7059.040 7106.683
#> 8 3 2 2 7051.296 7104.233
#> 9 4 2 2 7035.997 7094.228
#> 10 5 2 2 7036.330 7099.854
#> 11 1 3 3 7049.032 7101.969
#> 12 2 3 3 7051.028 7109.259
#> 13 3 3 3 7048.968 7112.492
#> 14 4 3 3 7038.370 7107.188
#> 15 5 3 3 7033.605 7107.717
#> 16 1 4 4 7035.770 7099.294
#> 17 2 4 4 7037.618 7106.437
#> 18 3 4 4 7036.754 7110.865
#> 19 4 4 4 7034.617 7114.023
#> 20 5 4 4 7034.479 7119.179
#> 21 1 5 5 7034.149 7108.261
#> 22 2 5 5 7036.055 7115.461
#> 23 3 5 5 7036.868 7121.568
#> 24 4 5 5 7037.394 7127.387
#> 25 5 5 5 7034.957 7130.244
#> ------------------------------------------------------------
#> data$filter_vars: Male Distant
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 13851.44 13885.39
#> 2 2 1 1 13322.99 13362.61
#> 3 3 1 1 13320.39 13365.66
#> 4 4 1 1 13294.14 13345.07
#> 5 5 1 1 13289.76 13346.35
#> 6 1 2 2 13367.60 13412.87
#> 7 2 2 2 13306.17 13357.10
#> 8 3 2 2 13299.90 13356.49
#> 9 4 2 2 13278.82 13341.07
#> 10 5 2 2 13274.81 13342.72
#> 11 1 3 3 13366.98 13423.57
#> 12 2 3 3 13314.53 13376.78
#> 13 3 3 3 13295.35 13363.26
#> 14 4 3 3 13272.67 13346.24
#> 15 5 3 3 13272.33 13351.56
#> 16 1 4 4 13341.56 13409.47
#> 17 2 4 4 13281.68 13355.25
#> 18 3 4 4 13282.21 13361.44
#> 19 4 4 4 13277.40 13362.28
#> 20 5 4 4 13274.06 13364.61
#> 21 1 5 5 13336.76 13415.99
#> 22 2 5 5 13277.38 13362.26
#> 23 3 5 5 13273.70 13364.24
#> 24 4 5 5 13274.85 13371.05
#> 25 5 5 5 13275.30 13377.16
#> ------------------------------------------------------------
#> data$filter_vars: Male Localised
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 8797.116 8832.341
#> 2 2 1 1 8766.320 8807.417
#> 3 3 1 1 8738.177 8785.144
#> 4 4 1 1 8713.604 8766.442
#> 5 5 1 1 8678.198 8736.907
#> 6 1 2 2 8771.776 8818.744
#> 7 2 2 2 8760.261 8813.099
#> 8 3 2 2 8738.895 8797.604
#> 9 4 2 2 8715.307 8779.888
#> 10 5 2 2 8679.480 8749.931
#> 11 1 3 3 8750.802 8809.511
#> 12 2 3 3 8749.943 8814.523
#> 13 3 3 3 8714.162 8784.613
#> 14 4 3 3 8712.658 8788.981
#> 15 5 3 3 8670.669 8752.862
#> 16 1 4 4 8723.055 8793.506
#> 17 2 4 4 8719.134 8795.456
#> 18 3 4 4 8683.367 8765.560
#> 19 4 4 4 8700.195 8788.259
#> 20 5 4 4 8662.301 8756.235
#> 21 1 5 5 8688.808 8771.001
#> 22 2 5 5 8684.310 8772.373
#> 23 3 5 5 8658.309 8752.244
#> 24 4 5 5 8648.992 8748.798
#> 25 5 5 5 8668.150 8773.827
#> ------------------------------------------------------------
#> data$filter_vars: Male Regional
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 3831.836 3859.270
#> 2 2 1 1 3804.296 3836.302
#> 3 3 1 1 3781.278 3817.856
#> 4 4 1 1 3781.690 3822.841
#> 5 5 1 1 3782.409 3828.132
#> 6 1 2 2 3807.213 3843.792
#> 7 2 2 2 3795.772 3836.922
#> 8 3 2 2 3781.959 3827.682
#> 9 4 2 2 3781.601 3831.896
#> 10 5 2 2 3782.001 3836.869
#> 11 1 3 3 3786.688 3832.411
#> 12 2 3 3 3784.731 3835.026
#> 13 3 3 3 3785.284 3840.152
#> 14 4 3 3 3784.453 3843.893
#> 15 5 3 3 3785.261 3849.273
#> 16 1 4 4 3782.109 3836.977
#> 17 2 4 4 3780.479 3839.919
#> 18 3 4 4 3782.177 3846.189
#> 19 4 4 4 3782.621 3851.205
#> 20 5 4 4 3785.934 3859.091
#> 21 1 5 5 3784.403 3848.415
#> 22 2 5 5 3782.816 3851.401
#> 23 3 5 5 3784.882 3858.039
#> 24 4 5 5 3782.452 3860.181
#> 25 5 5 5 3786.952 3869.253
#> ------------------------------------------------------------
#> data$filter_vars: Male Unknown
#> df_bh df_tvc_age df_tvc_year8594 aic bic
#> 1 1 1 1 3938.297 3967.011
#> 2 2 1 1 3846.137 3879.636
#> 3 3 1 1 3834.367 3872.652
#> 4 4 1 1 3828.330 3871.400
#> 5 5 1 1 3826.891 3874.746
#> 6 1 2 2 3849.247 3887.532
#> 7 2 2 2 3845.147 3888.218
#> 8 3 2 2 3822.626 3870.482
#> 9 4 2 2 3821.391 3874.033
#> 10 5 2 2 3820.821 3878.248
#> 11 1 3 3 3835.434 3883.290
#> 12 2 3 3 3829.243 3881.884
#> 13 3 3 3 3815.527 3872.954
#> 14 4 3 3 3818.337 3880.550
#> 15 5 3 3 3820.013 3887.011
#> 16 1 4 4 3830.062 3887.489
#> 17 2 4 4 3819.273 3881.485
#> 18 3 4 4 3819.603 3886.602
#> 19 4 4 4 3811.115 3882.899
#> 20 5 4 4 3814.368 3890.938
#> 21 1 5 5 3826.864 3893.862
#> 22 2 5 5 3817.493 3889.277
#> 23 3 5 5 3808.589 3885.158
#> 24 4 5 5 3812.816 3894.171
#> 25 5 5 5 3811.558 3897.699