coxed.npsf.tvc: Predict expected durations using the GAM method with...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/coxed.npsf.tvc.R

Description

This function is called by coxed and is not intended to be used by itself.

Usage

1
coxed.npsf.tvc(cox.model, newdata = NULL, coef = NULL, b.ind = NULL)

Arguments

cox.model

The output from a Cox proportional hazards model estimated with the coxph function in the survival package or with the cph function in the rms package

newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used

coef

A vector of new coefficients to replace the coefficients attribute of the cox.model. Used primarily for bootstrapping, to recalculate durations using new coefficients derived from a bootstrapped sample. If NULL, the original coefficients are employed

b.ind

A vector of observation numbers to pass to the estimation sample to construct the a bootstrapped sample with replacement

Details

This function employs the NPSF method of generating expected durations described in Kropko and Harden (2018). See coxed.npsf for details. This code replicates the code for cox.npsf, but works with data whose structure allows time-varying covariates, and requires using the time2 argument of the Surv function. This function requires the data to be reported as cumulative durations. The cumulative baseline hazard function model is estimated using the ending times for each interval. Then the expected durations are drawn from the Cox model and the NPSF method as with coxed.npsf.

Value

Returns a list containing the following components:

exp.dur A vector of predicted mean durations for the estimation sample if newdata is omitted, or else for the specified new data.
baseline.functions The estimated cumulative baseline hazard function and survivor function.

Author(s)

Jonathan Kropko <jkropko@virginia.edu> and Jeffrey J. Harden <jharden2@nd.edu>

References

Kropko, J. and Harden, J. J. (2018). Beyond the Hazard Ratio: Generating Expected Durations from the Cox Proportional Hazards Model. British Journal of Political Science https://doi.org/10.1017/S000712341700045X

See Also

coxed, coxed.npsf

Examples

1
2
3
4
5
6
bs.surv <- Surv(time = boxsteffensmeier$start, time2 = boxsteffensmeier$te,
     event = boxsteffensmeier$cut_hi)
bs.cox <- coxph(bs.surv ~ ec + dem + south + iv, data = boxsteffensmeier, method = "breslow")

ed <- coxed.npsf.tvc(bs.cox)
ed$exp.dur

Example output

Loading required package: rms
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package:HmiscThe following objects are masked frompackage:base:

    format.pval, units

Loading required package: SparseM

Attaching package:SparseMThe following object is masked frompackage:base:

    backsolve

Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
   [1] 79.62010 79.82079 84.06214 84.32023 84.98295 85.18166 89.78986 89.80172
   [9] 89.77165 86.15249 86.58946 86.76341 89.82306 89.84859 89.84635 89.85041
  [17] 86.97748 87.22478 87.21535 87.55361 85.07747 85.57533 86.04379 86.16286
  [25] 89.45003 89.46196 88.85061 89.02774 89.03745 89.20628 87.99580 88.01789
  [33] 87.77822 87.99593 84.68749 84.75423 85.34555 85.20419 84.67446 84.58516
  [41] 84.95998 84.87243 85.12550 85.04962 85.03288 85.63790 86.03208 88.98892
  [49] 89.03815 89.40291 82.74841 82.71968 82.80119 83.21110 83.58685 77.69574
  [57] 77.74162 77.68988 79.32545 80.01924 81.14233 89.25866 89.77456 89.77646
  [65] 89.78153 85.55297 85.95332 87.36309 86.98961 87.46827 87.66411 87.67215
  [73] 87.77723 87.76024 75.62019 75.13358 75.65046 74.72068 86.30477 86.65101
  [81] 86.68961 87.62163 87.75079 87.59486 87.91708 88.01339 76.00433 78.24625
  [89] 80.10879 84.10908 86.35357 86.70126 86.33465 86.62150 80.42750 87.44298
  [97] 87.28198 87.42049 87.66220 84.82051 83.77333 83.85939 83.67659 84.29247
 [105] 73.69441 74.20107 86.31133 86.55876 86.26020 86.69127 85.98643 85.88059
 [113] 88.87613 89.17692 89.13281 78.47663 86.76918 88.25088 88.37267 88.16850
 [121] 88.46823 88.46886 88.46164 84.36972 86.85797 86.80331 86.48354 89.85662
 [129] 89.88305 89.90771 85.91459 85.87075 85.79127 86.33085 77.00913 83.11292
 [137] 83.00488 83.25148 82.91259 83.50540 83.40370 89.85175 89.91080 89.90894
 [145] 89.92507 82.73944 82.57168 82.51363 85.39742 85.74713 85.66023 70.49995
 [153] 72.67675 74.76684 82.03483 81.77958 81.62288 79.55005 78.33376 79.26870
 [161] 80.08075 85.56314 85.40806 85.52970 85.80787 82.62210 82.93015 82.56134
 [169] 84.45602 82.09640 82.97630 82.83718 82.41371 86.33181 86.34332 86.23853
 [177] 86.60236 76.08600 85.98464 85.86255 85.54065 85.48731 85.96131 86.02138
 [185] 86.23925 78.20888 79.16946 85.91938 86.38733 86.30249 86.50064 86.48303
 [193] 86.67010 80.91720 82.07976 82.14509 82.72448 82.87054 86.81598 87.87604
 [201] 87.87366 88.31301 88.33412 78.57269 78.51938 78.52791 80.34694 84.69973
 [209] 85.56495 85.73797 86.29769 84.44260 85.64616 85.64844 86.89002 86.08152
 [217] 82.49162 82.15868 81.96049 83.54740 84.58974 84.63232 84.79966 85.54755
 [225] 89.52098 89.63284 89.75772 89.76245 76.45950 78.34015 78.86486 79.68296
 [233] 89.73460 89.77838 89.77251 79.16779 80.27499 80.97854 81.55783 89.89091
 [241] 89.90575 89.87985 89.92114 89.91817 88.55003 88.70699 88.66120 88.87486
 [249] 88.79385 89.74442 89.81162 89.80017 87.38385 87.36066 87.40480 87.78660
 [257] 87.73693 89.69655 89.70952 89.71853 89.74340 89.67067 86.24783 87.09368
 [265] 87.11065 87.29515 87.06808 76.21402 78.53404 85.53686 86.75308 86.75858
 [273] 87.54765 87.67020 86.94347 88.17179 88.13899 88.39094 88.33625 89.71419
 [281] 89.67722 81.79417 89.23518 85.08872 85.10069 85.27901 85.51290 80.79745
 [289] 80.78267 81.55633 81.81901 89.63927 89.64771 80.90045 87.96973 88.07035
 [297] 88.53314 88.41289 81.96375 85.15223 85.45779 89.67963 89.73571 89.72733
 [305] 89.72318 87.57799 88.13978 88.32264 88.34333 78.27170 79.18562 79.18357
 [313] 79.12590 78.92575 79.43878 79.40350 80.06692 86.98575 87.32659 87.38961
 [321] 87.44964 82.52264 83.20243 81.43409 82.21109 82.59121 83.60416 78.70019
 [329] 79.56724 80.37473 80.50867 88.80847 88.88336 88.85471 86.62191 86.62772
 [337] 86.64055 79.01043 79.00197 80.50361 66.50785 77.18757 77.13646 77.17317
 [345] 86.91489 87.21415 87.22120 89.51237 89.52232 89.33576 89.70864 89.73934
 [353] 89.74082 82.70335 85.00275 81.95405 86.05592 86.27925 86.32227 82.50117
 [361] 83.32135 86.73941 86.75126 87.87081 84.77158 85.02366 84.98697 86.18142
 [369] 86.19327 86.28584 88.25631 88.40441 88.41509 79.16021 79.28868 76.10612
 [377] 77.69212 76.19903 86.49973 86.76474 84.93200 85.10760 76.08938 79.41440
 [385] 79.05513 79.03599 86.45177 86.67454 86.84022 74.61327 74.42311 75.93143
 [393] 78.60648 79.82729 75.09056 76.02284 75.88418 86.65248 86.86113 81.72150
 [401] 81.33374 81.61901 81.79209 77.66593 78.50498 79.35904 84.53099 84.77663
 [409] 85.27621 85.40274 76.50528 76.51950 76.75825 89.74164 89.75395 89.75234
 [417] 89.78928 89.80917 85.53597 85.77426 86.14571 84.97839 85.14647 85.09500
 [425] 85.07552 81.79848 81.54129 81.56269 83.76764 83.87157 89.36137 89.39182
 [433] 89.41509 89.45014 75.91948 75.91948 75.92241 82.47581 82.32755 87.13061
 [441] 87.53360 87.71868 89.56850 89.63336 89.64942 89.65221 89.14661 89.26192
 [449] 89.26818 89.28051 74.69757 88.80373 88.79540 86.48819 86.57752 86.25059
 [457] 86.43112 86.37171 89.25709 89.35088 89.37263 89.40619 89.38401 84.21372
 [465] 84.58970 85.27786 85.94201 87.29569 87.27775 87.18386 83.92678 83.80093
 [473] 84.59927 84.81792 84.50168 89.78878 89.78744 89.85927 89.86253 89.97684
 [481] 88.21247 87.95010 87.75139 88.31344 88.40182 89.69773 89.71133 89.72690
 [489] 89.79070 89.81042 81.37343 88.98984 89.21362 89.22768 89.41414 89.43744
 [497] 67.85391 85.72877 85.80521 85.60191 85.83309 86.34104 84.42677 86.73467
 [505] 86.87649 87.44293 87.26391 84.79569 85.89360 86.24394 87.34105 87.32404
 [513] 87.94460 88.52541 88.63703 88.57464 85.70708 85.41439 84.90540 89.22945
 [521] 89.24611 89.21540 89.30409 89.22591 81.04458 82.26915 82.82178 83.49311
 [529] 83.88600 82.23866 83.01077 83.20490 88.58686 88.29943 88.26379 88.42546
 [537] 77.71722 78.47090 78.50852 79.93374 79.97846 75.60100 77.40710 85.19325
 [545] 85.78435 85.95495 86.80634 87.19843 87.28740 87.46556 87.51926 77.91526
 [553] 79.06002 79.50171 80.59864 80.77379 84.57358 84.76933 84.91455 85.42774
 [561] 84.98912 86.63696 87.11792 87.25288 87.43105 87.61894 85.20478 85.39565
 [569] 85.03647 85.57405 80.88689 81.30504 80.57932 81.46376 80.58708 75.70525
 [577] 78.17396 82.27863 83.03231 83.44920 83.74399 84.12430 83.30766 83.47764
 [585] 83.05386 89.45798 89.47650 89.73095 89.76325 89.75700 84.97473 86.03135
 [593] 85.90795 86.27090 86.41165 89.33732 89.39644 85.95429 86.54478 86.42575
 [601] 86.45351 86.38190 83.22678 83.85111 83.54383 83.95570 83.47299 86.09572
 [609] 86.36245 86.38063 86.80774 86.68900 84.43760 84.88734 85.35494 86.02122
 [617] 75.88487 76.80307 76.27527 87.73437 87.85380 84.32287 84.17034 83.92796
 [625] 84.28207 82.65027 83.82864 78.37693 83.49785 83.42401 82.30733 86.67634
 [633] 87.10277 87.17370 87.38135 85.26996 86.01430 85.99843 86.00387 86.36995
 [641] 81.73014 83.59217 83.69054 83.92354 74.43408 75.46782 79.02226 79.04515
 [649] 83.25856 83.81115 84.29738 84.75282 88.96361 89.18093 89.20672 89.21455
 [657] 82.36175 82.39285 83.70493 83.81878 88.98804 88.96456 88.94994 89.13917
 [665] 76.05114 78.30201 79.25835 76.15733 87.59418 87.61838 80.06318 80.17482
 [673] 79.65126 77.10347 86.87631 86.89967 87.11546 89.50687 89.48997 89.51734
 [681] 89.57092 89.58255 79.98653 80.82029 81.52366 74.98053 78.21486 78.43223
 [689] 83.20826 83.53930 83.78138 88.18648 88.22016 88.23784 88.57761 79.39839
 [697] 81.16868 81.23391 85.90811 86.17194 86.29093 86.81919 82.99802 83.26156
 [705] 83.37122 75.02146 76.52199 76.97061 76.98603 86.27165 86.94734 86.78069
 [713] 87.34165 83.14129 83.47432 66.25507 71.32693 75.56320 76.07627 76.06075
 [721] 83.40522 83.67631 83.73368 84.70813 67.80404 68.06266 70.11642 72.44150
 [729] 83.05967 83.10613 83.59962 86.60597 87.09453 87.14913 87.33618 78.48705
 [737] 79.46416 79.35299 80.00861 89.50062 89.64474 89.69837 89.69823 89.82908
 [745] 89.81839 89.80611 89.83080 88.16851 88.20598 88.44155 89.93666 86.73917
 [753] 86.74046 87.21103 87.46312 86.36826 86.09844 86.21531 87.11244 86.06159
 [761] 84.15632 85.39374 85.28202 86.62389 70.27240 70.83082 89.43911 89.46352
 [769] 89.50681 89.55999 86.77794 87.12305 87.23630 78.75589 81.66499 79.10461
 [777] 79.80617 76.38910 76.08712 76.25834 77.03468 66.66217 73.03321 75.42409
 [785] 77.87495 78.86871 86.32090 85.96711 86.34263 86.93343 86.92288 80.79526
 [793] 88.47372 88.90264 88.91693 89.08740 89.27981 86.57479 86.61715 86.58870
 [801] 87.41116 87.57564 87.61297 87.68771 87.76770 87.73628 89.57940 89.54282
 [809] 89.49907 89.59141 89.61528 89.06613 89.06062 89.10170 89.15039 89.12991
 [817] 89.54678 89.64156 89.61202 89.72226 89.77981 89.69572 89.89002 89.92313
 [825] 89.93542 89.94625 88.31474 88.36246 88.27232 88.43428 88.48175 88.52980
 [833] 88.51583 88.50471 88.53620 88.52978 89.81337 89.90698 89.92586 89.93209
 [841] 89.95708 78.16222 78.52193 79.33585 78.79873 82.64414 84.20242 85.01654
 [849] 85.65240 89.68599 89.56626 89.59175 89.68648 89.59851 87.36504 87.65498
 [857] 87.58572 87.54214 88.44198 88.58813 88.62164 88.53162 88.49827 72.62764
 [865] 73.17249 74.11932 74.16838 72.37962 68.78338 75.20857 79.62033 81.75630
 [873] 83.76369 86.95370 86.86436 86.83600 87.48452 87.29636 85.89447 85.93381
 [881] 86.05866 86.51255 86.03204 77.41964 78.41143 78.34387 80.11934 86.15341
 [889] 86.22779 89.56823 89.60685 89.61935 89.62660 89.59886 86.23859 86.23435
 [897] 86.19475 86.17733 86.09976 76.65477 77.39014 78.15157 78.09977 88.92022
 [905] 88.94749 88.93479 89.04497 89.04610 84.96349 85.48991 85.14880 85.02929
 [913] 85.39896 73.91263 76.12645 77.37872 79.16303 75.17308 73.23455 77.54979
 [921] 78.08339 80.33183 82.01892 88.40786 88.49504 88.52242 88.63500 88.90332
 [929] 89.44849 89.49044 89.47929 89.51476 89.52594 89.34501 89.40322 89.44303
 [937] 89.54523 88.18836 88.31644 88.26026 88.59286 87.60551 87.77504 87.67697
 [945] 87.78867 89.59440 89.69916 89.68741 78.66723 79.18487 79.26284 80.26341
 [953] 85.26819 85.28438 85.73269 85.90329 86.71014 86.66922 86.72399 87.02708
 [961] 85.55195 85.64667 85.74115 86.10416 80.81198 81.34991 82.61640 87.55929
 [969] 87.58921 87.86407 86.13043 85.05376 84.93990 85.41217 85.86417 85.76113
 [977] 86.29180 86.30508 86.69258 87.20039 87.19331 87.17003 87.14288 85.85751
 [985] 86.04718 85.98993 85.94204 86.72589 86.80489 86.75946 86.80462 85.42319
 [993] 85.27621 85.41497 85.82435 86.77661 86.98265 86.87055 87.10016 88.53349
[1001] 88.51589 88.45612 88.65338 72.28124 81.10995 81.56090 81.65526 82.98257
[1009] 81.32354 89.34471 89.38780 89.45069 89.48390 85.06649 85.37106 85.43770
[1017] 85.38937 85.45888 87.02343 87.12011 87.32075 87.58816 87.62541 85.86988
[1025] 87.17497 86.83794 81.71190 82.77948 83.41003 83.49383 89.88686 89.89051
[1033] 89.86900 89.86344 84.26038 84.69280 84.74528 85.28768 72.60752 74.12110
[1041] 86.38547 87.57723 87.97970 88.15773 88.90743 88.58582 89.11565 88.74006
[1049] 89.03602 89.12161 84.90461 85.08939 85.07921 85.29986 88.68695 88.71872
[1057] 88.52899 88.81579 82.00640 83.33806 75.40980 89.43991 89.54699 89.59234
[1065] 89.52145 87.91730 87.95532 87.81503 88.00599 89.50973 89.54850 89.58527
[1073] 89.31350 89.62380 89.56265 89.37703 89.31202 85.96034 86.06222 86.47457
[1081] 87.18325 87.28778 87.11038 87.11001 87.20584 78.00965 78.09237 78.41767
[1089] 85.29929 85.62105 85.61637 85.57903 89.46935 89.49545 89.48825 89.47836
[1097] 80.59957 86.11780 86.21802 86.18532 86.27786 89.14590 89.22617 89.24579
[1105] 89.24526 87.64542 87.74758 87.88142 87.97567 89.02646 89.01347 89.01386
[1113] 89.06231 81.78529 82.51182 82.60393 83.18166 75.80408 86.02037 86.57465
[1121] 86.74820 86.91941 77.40723 77.61209 78.08400 78.19999 80.79205 80.50195
[1129] 81.99420 74.22774 74.46195 76.07889 77.54401 86.73010 87.10491 87.11051
[1137] 86.72336 88.10162 88.40907 88.56715 88.66490 84.65891 89.82436 89.85063
[1145] 89.84799 89.88638 89.90335 80.16600 80.48668 81.85427 82.60117 83.15351
[1153] 79.17910 81.83704 81.96334 83.37986 83.33547 89.50589 89.51754 89.53178
[1161] 89.54147 89.59409 89.43365 89.62804 89.61334 89.61839 89.62714 88.47541
[1169] 88.89664 88.92890 89.28629 89.35966 89.01920 89.43252 89.45375 89.45968
[1177] 89.59297 82.04763 84.26743 84.80898 85.02387 85.17896 87.59613 87.63944
[1185] 87.66649 87.66829 87.64304 82.24239 83.11502 88.80709 88.65088 88.56676
[1193] 89.01660 88.97442 85.39041 86.15923 86.01493 80.12414 85.73302 87.62971
[1201] 88.64263 88.74186 89.63821 89.67114 89.65588 89.64070 89.60866 89.64260
[1209] 89.84062 89.87397 89.27747 89.40664 85.40270 85.21041 85.84120 74.11885
[1217] 74.43383 75.00096 89.36874 89.34293 89.35071 89.38541 89.39389 89.40126
[1225] 89.51909 89.48106 89.46856 89.33444 89.36986 89.38454 85.47836 86.01847
[1233] 85.98901 84.87435 85.72334 85.63589 89.56629 89.62763 85.85029 86.28244
[1241] 86.55435 85.34547 89.51684 89.65317 89.62625 88.96567 89.32971 89.34679
[1249] 86.94429 87.14150 87.45248 89.66619 89.67479 89.67687 77.86587 77.70658
[1257] 75.39592 75.98253 86.94261 87.12108 87.06050 87.31426 81.15675 82.03610
[1265] 81.96388 83.35198 89.68764 89.69716 89.79539 89.79303 89.79638 89.81790
[1273] 76.52394 76.92940 76.86885 79.62061 82.51396 82.89518 83.94813 83.78592
[1281] 89.72760 89.75122 85.05638 84.92066 85.30585 85.71836 86.99168 87.31360
[1289] 86.03792 86.09658 86.26335 86.98520 74.22437 75.50507 89.47353 89.53298
[1297] 89.52582 89.63548 89.58879 66.60217 70.67981 86.94912 87.05733 87.30315
[1305] 87.33256 87.31429 89.21814 89.35728 85.52471 86.14409 86.10664 86.76313
[1313] 85.32017 85.01659 85.58413 85.67543 86.58110 85.77127 85.42913 85.81576
[1321] 85.80733 86.67032 86.74606 86.56641 87.37097 87.51226 87.90975 87.77938
[1329] 75.25061 75.24268 76.34452 77.50794 84.06282 84.41371 84.11159 85.00696
[1337] 89.45989 89.47308 89.47141 89.51957 80.81660 82.30534 83.00647 84.37357
[1345] 84.81684 87.97192 88.21344 88.21192 88.38346 88.47813 82.74832 84.09075
[1353] 84.96312 85.96889 85.89187 86.16550 86.80424 87.02705 87.31572 87.52883
[1361] 87.78491 87.95629 85.32497 89.26133 89.22199 89.29269 85.11604 85.34444
[1369] 85.50718 85.98331 86.22704 86.38879 86.36798 76.75060 77.31475 78.95891

coxed documentation built on Aug. 2, 2020, 9:07 a.m.