Simulation of time-to-event outcomes using the piecewise constant hazard exponential function.
pw_exp_sim(hazard, n, maxtime = NULL, cutpoint = NULL)
hazard | vector. The constant hazard rates for exponential failures. |
---|---|
n | scalar. The number of outcomes for simulation. |
maxtime | scalar. maximum time before end of study. |
cutpoint | vector. The change-point vector indicating time when the hazard rates change. |
a dataset with simulated follow-up time (time) and respective event indicator (1 = event, 0 = censoring)
#> time event #> 1 100.0000000 0 #> 2 100.0000000 0 #> 3 100.0000000 0 #> 4 7.4991673 1 #> 5 100.0000000 0 #> 6 4.8591439 1 #> 7 91.0005657 1 #> 8 100.0000000 0 #> 9 100.0000000 0 #> 10 100.0000000 0 #> 11 100.0000000 0 #> 12 60.4055383 1 #> 13 47.6055833 1 #> 14 1.5355301 1 #> 15 5.9054583 1 #> 16 100.0000000 0 #> 17 74.3804656 1 #> 18 90.1231454 1 #> 19 6.0437696 1 #> 20 10.7500805 1 #> 21 82.1854934 1 #> 22 100.0000000 0 #> 23 53.1642666 1 #> 24 100.0000000 0 #> 25 34.4252416 1 #> 26 18.3882529 1 #> 27 100.0000000 0 #> 28 100.0000000 0 #> 29 43.0001581 1 #> 30 39.0621709 1 #> 31 23.6333683 1 #> 32 100.0000000 0 #> 33 6.6909784 1 #> 34 42.4113571 1 #> 35 9.3408365 1 #> 36 71.5882535 1 #> 37 100.0000000 0 #> 38 12.0275395 1 #> 39 100.0000000 0 #> 40 100.0000000 0 #> 41 100.0000000 0 #> 42 5.1564162 1 #> 43 100.0000000 0 #> 44 1.6266436 1 #> 45 58.4648914 1 #> 46 1.2095295 1 #> 47 100.0000000 0 #> 48 100.0000000 0 #> 49 34.9067081 1 #> 50 1.5585619 1 #> 51 13.9609324 1 #> 52 100.0000000 0 #> 53 100.0000000 0 #> 54 0.1392690 1 #> 55 5.2900206 1 #> 56 100.0000000 0 #> 57 16.4769432 1 #> 58 97.5481143 1 #> 59 51.9044835 1 #> 60 100.0000000 0 #> 61 100.0000000 0 #> 62 59.7090609 1 #> 63 7.0815057 1 #> 64 100.0000000 0 #> 65 100.0000000 0 #> 66 100.0000000 0 #> 67 2.6106730 1 #> 68 97.6653573 1 #> 69 100.0000000 0 #> 70 100.0000000 0 #> 71 100.0000000 0 #> 72 100.0000000 0 #> 73 100.0000000 0 #> 74 100.0000000 0 #> 75 0.2264237 1 #> 76 2.9934776 1 #> 77 100.0000000 0 #> 78 44.7013668 1 #> 79 2.5372352 1 #> 80 60.6122484 1 #> 81 100.0000000 0 #> 82 2.3428417 1 #> 83 100.0000000 0 #> 84 100.0000000 0 #> 85 100.0000000 0 #> 86 100.0000000 0 #> 87 41.5250083 1 #> 88 100.0000000 0 #> 89 100.0000000 0 #> 90 100.0000000 0 #> 91 64.3044554 1 #> 92 100.0000000 0 #> 93 100.0000000 0 #> 94 100.0000000 0 #> 95 9.3836589 1 #> 96 100.0000000 0 #> 97 100.0000000 0 #> 98 64.5021441 1 #> 99 68.9907390 1 #> 100 100.0000000 0pw_exp_sim(0.015, 100, 100)#> time event #> 1 100.0000000 0 #> 2 53.0911767 1 #> 3 49.2064921 1 #> 4 5.8441559 1 #> 5 100.0000000 0 #> 6 19.3406363 1 #> 7 33.3653128 1 #> 8 51.8039012 1 #> 9 2.1186880 1 #> 10 81.1583078 1 #> 11 100.0000000 0 #> 12 8.9158745 1 #> 13 0.6133244 1 #> 14 83.9543739 1 #> 15 100.0000000 0 #> 16 19.5708406 1 #> 17 23.1625329 1 #> 18 13.6193026 1 #> 19 77.1957318 1 #> 20 84.5505372 1 #> 21 6.8387563 1 #> 22 95.5776813 1 #> 23 5.3746252 1 #> 24 96.8721828 1 #> 25 9.4112933 1 #> 26 48.0719238 1 #> 27 15.2007471 1 #> 28 50.8915019 1 #> 29 52.2487976 1 #> 30 20.4932529 1 #> 31 1.2303210 1 #> 32 3.5065415 1 #> 33 58.3101722 1 #> 34 100.0000000 0 #> 35 100.0000000 0 #> 36 100.0000000 0 #> 37 30.4239964 1 #> 38 2.6882859 1 #> 39 73.6962955 1 #> 40 32.4024317 1 #> 41 3.2373512 1 #> 42 46.8899651 1 #> 43 16.6374917 1 #> 44 100.0000000 0 #> 45 24.7746170 1 #> 46 34.8079207 1 #> 47 8.5847636 1 #> 48 37.1272405 1 #> 49 18.5414651 1 #> 50 80.5993415 1 #> 51 75.4179909 1 #> 52 45.8975222 1 #> 53 54.4829530 1 #> 54 28.4549269 1 #> 55 100.0000000 0 #> 56 16.8608659 1 #> 57 43.7228429 1 #> 58 19.0758709 1 #> 59 27.7979016 1 #> 60 8.0046874 1 #> 61 100.0000000 0 #> 62 16.2006131 1 #> 63 100.0000000 0 #> 64 65.2601022 1 #> 65 6.7816527 1 #> 66 100.0000000 0 #> 67 100.0000000 0 #> 68 24.6192151 1 #> 69 1.9203329 1 #> 70 2.9982355 1 #> 71 34.9481219 1 #> 72 100.0000000 0 #> 73 96.9570442 1 #> 74 41.2928268 1 #> 75 7.9177652 1 #> 76 31.1639581 1 #> 77 72.7952722 1 #> 78 16.6759056 1 #> 79 100.0000000 0 #> 80 24.1064820 1 #> 81 38.7529342 1 #> 82 100.0000000 0 #> 83 71.3908869 1 #> 84 34.7810973 1 #> 85 30.8138194 1 #> 86 5.2239038 1 #> 87 2.5911248 1 #> 88 58.1098155 1 #> 89 14.7066163 1 #> 90 100.0000000 0 #> 91 100.0000000 0 #> 92 22.1187716 1 #> 93 20.3956369 1 #> 94 70.0912324 1 #> 95 18.4201467 1 #> 96 52.9290582 1 #> 97 10.5041989 1 #> 98 100.0000000 0 #> 99 32.3101574 1 #> 100 6.5627608 1