Skip to contents

Generate model predictions against a specified set of explanatory levels with bootstrapped confidence intervals.

Usage

bootPredict(fit, newdata, R = 100, type = "response", ...)

Arguments

fit

An object of class lm or glm

newdata

A data.frame

R

Number of simulations. Note default R=100 is very low.

type

he type of prediction required, see predict.glm. The default for glm models is on the scale of the response variable. Thus for a binomial model the default predictions are predicted probabilities.

...

Further arguments to be passed to boot::boot

Value

An object of class "data.frame"

Examples

data(GBSG2,package="TH.data")
fit=glm(cens~horTh+pnodes,data=GBSG2,family="binomial")
newdata=expand.grid(horTh=factor(c(1,2),labels=c("no","yes")),pnodes=1:51)
bootPredict(fit,newdata)
#>     horTh pnodes  estimate     lower     upper
#> 1      no      1 0.3671628 0.3126764 0.4269445
#> 2     yes      1 0.2814584 0.2252174 0.3593819
#> 3      no      2 0.3927672 0.3417797 0.4458494
#> 4     yes      2 0.3039568 0.2480698 0.3771263
#> 5      no      3 0.4189750 0.3706082 0.4681277
#> 6     yes      3 0.3274340 0.2703583 0.3949465
#> 7      no      4 0.4456481 0.3993581 0.4907026
#> 8     yes      4 0.3518080 0.2905775 0.4146516
#> 9      no      5 0.4726379 0.4244542 0.5222734
#> 10    yes      5 0.3769795 0.3053335 0.4371384
#> 11     no      6 0.4997887 0.4480589 0.5553061
#> 12    yes      6 0.4028326 0.3189937 0.4657147
#> 13     no      7 0.5269407 0.4676993 0.5859942
#> 14    yes      7 0.4292372 0.3375572 0.4982285
#> 15     no      8 0.5539343 0.4857528 0.6182272
#> 16    yes      8 0.4560509 0.3570262 0.5259330
#> 17     no      9 0.5806134 0.5042088 0.6520915
#> 18    yes      9 0.4831217 0.3769850 0.5529038
#> 19     no     10 0.6068295 0.5257039 0.6841504
#> 20    yes     10 0.5102919 0.3973717 0.5804500
#> 21     no     11 0.6324443 0.5445426 0.7147166
#> 22    yes     11 0.5374015 0.4181180 0.6134194
#> 23     no     12 0.6573325 0.5578985 0.7434084
#> 24    yes     12 0.5642918 0.4391504 0.6482779
#> 25     no     13 0.6813846 0.5756382 0.7699533
#> 26    yes     13 0.5908091 0.4603911 0.6836304
#> 27     no     14 0.7045073 0.5932151 0.7945091
#> 28    yes     14 0.6168084 0.4817593 0.7180994
#> 29     no     15 0.7266252 0.6105566 0.8170642
#> 30    yes     15 0.6421564 0.4993408 0.7501853
#> 31     no     16 0.7476805 0.6276229 0.8389630
#> 32    yes     16 0.6667336 0.5161004 0.7797393
#> 33     no     17 0.7676327 0.6443769 0.8590624
#> 34    yes     17 0.6904365 0.5328297 0.8066977
#> 35     no     18 0.7864578 0.6600467 0.8769103
#> 36    yes     18 0.7131789 0.5494911 0.8310405
#> 37     no     19 0.8041469 0.6739743 0.8926994
#> 38    yes     19 0.7348919 0.5660472 0.8528523
#> 39     no     20 0.8207047 0.6876013 0.9066754
#> 40    yes     20 0.7555247 0.5824617 0.8722809
#> 41     no     21 0.8361480 0.7009224 0.9189932
#> 42    yes     21 0.7750433 0.5986996 0.8894765
#> 43     no     22 0.8505034 0.7139426 0.9298081
#> 44    yes     22 0.7934296 0.6147274 0.9046099
#> 45     no     23 0.8638059 0.7266170 0.9392721
#> 46    yes     23 0.8106802 0.6305131 0.9173253
#> 47     no     24 0.8760972 0.7389351 0.9475297
#> 48    yes     24 0.8268046 0.6460271 0.9283603
#> 49     no     25 0.8874238 0.7508885 0.9547167
#> 50    yes     25 0.8418238 0.6612418 0.9380151
#> 51     no     26 0.8978357 0.7624703 0.9609580
#> 52    yes     26 0.8557676 0.6761321 0.9464416
#> 53     no     27 0.9073851 0.7736759 0.9663679
#> 54    yes     27 0.8686741 0.6906752 0.9537772
#> 55     no     28 0.9161253 0.7845023 0.9710495
#> 56    yes     28 0.8805867 0.7048511 0.9601486
#> 57     no     29 0.9241097 0.7949479 0.9750950
#> 58    yes     29 0.8915537 0.7186424 0.9656720
#> 59     no     30 0.9313909 0.8050129 0.9785868
#> 60    yes     30 0.9016260 0.7320344 0.9704520
#> 61     no     31 0.9380204 0.8146990 0.9815974
#> 62    yes     31 0.9108563 0.7450148 0.9745829
#> 63     no     32 0.9440478 0.8240091 0.9841909
#> 64    yes     32 0.9192981 0.7575741 0.9781482
#> 65     no     33 0.9495206 0.8329472 0.9864233
#> 66    yes     33 0.9270045 0.7697052 0.9812223
#> 67     no     34 0.9544839 0.8415186 0.9883437
#> 68    yes     34 0.9340278 0.7814034 0.9838703
#> 69     no     35 0.9589802 0.8497295 0.9899948
#> 70    yes     35 0.9404188 0.7926663 0.9861496
#> 71     no     36 0.9630496 0.8575868 0.9914137
#> 72    yes     36 0.9462263 0.8034934 0.9881101
#> 73     no     37 0.9667293 0.8650985 0.9926326
#> 74    yes     37 0.9514970 0.8139206 0.9897956
#> 75     no     38 0.9700539 0.8722730 0.9936792
#> 76    yes     38 0.9562749 0.8240434 0.9912438
#> 77     no     39 0.9730556 0.8791191 0.9945778
#> 78    yes     39 0.9606016 0.8337263 0.9924878
#> 79     no     40 0.9757639 0.8856463 0.9953490
#> 80    yes     40 0.9645161 0.8429762 0.9935559
#> 81     no     41 0.9782061 0.8918643 0.9960108
#> 82    yes     41 0.9680546 0.8518013 0.9944727
#> 83     no     42 0.9804072 0.8977832 0.9965786
#> 84    yes     42 0.9712507 0.8602109 0.9952596
#> 85     no     43 0.9823899 0.9034132 0.9970657
#> 86    yes     43 0.9741357 0.8682154 0.9959347
#> 87     no     44 0.9841753 0.9087645 0.9974836
#> 88    yes     44 0.9767380 0.8758260 0.9965138
#> 89     no     45 0.9857822 0.9138475 0.9978419
#> 90    yes     45 0.9790842 0.8829960 0.9970106
#> 91     no     46 0.9872281 0.9186727 0.9981493
#> 92    yes     46 0.9811982 0.8893224 0.9974366
#> 93     no     47 0.9885287 0.9232503 0.9984129
#> 94    yes     47 0.9831023 0.8953473 0.9978020
#> 95     no     48 0.9896982 0.9275904 0.9986389
#> 96    yes     48 0.9848165 0.9010807 0.9981153
#> 97     no     49 0.9907496 0.9317033 0.9988328
#> 98    yes     49 0.9863593 0.9065329 0.9983840
#> 99     no     50 0.9916946 0.9355987 0.9989990
#> 100   yes     50 0.9877472 0.9117140 0.9986143
#> 101    no     51 0.9925437 0.9392864 0.9991415
#> 102   yes     51 0.9889955 0.9166343 0.9988118
library(survival)
fit=coxph(Surv(time,cens)~age+horTh+progrec+pnodes,data=GBSG2)