rfPredVar: rfPredVar

Description Usage Arguments Details Value Examples

View source: R/rfPredVar.R

Description

Generate predictions and prediction variances from a random forest based on the infinitesimal jackknife.

Usage

1
2
rfPredVar(random.forest, rf.data, pred.data = rf.data, CI = FALSE,
  tree.type = "rf", prog.bar = FALSE)

Arguments

random.forest

A random forest trained with keep.inbag=TRUE. See details for more information.

rf.data

The data used to train rf

pred.data

The data used to predict with the forest; defaults to rf.data if not given

CI

Should 95% confidence intervals based on the CLT be returned along with predictions and prediction variances?

tree.type

either 'ci' for conditional inference tree or 'rf' for traditional CART tree

prog.bar

should progress bar be shown? (only applicable when tree.type='ci')

Details

The random forest trained with keep.inbag=TRUE is supplied only for the purpose of defining the resampling scheme. The function builds a new random forest based on the tree.type setting. However, the resamples are maintained identically to the supplied random forest. This allows for direct comparison of the tree methods without having to account for variation in resampling.

Currently, the CI methods are much more computationally intensive because there is no C implementation of the CI random forest method that indicates the number of times that each sample is included in each resample. In order to carry out our simulations using V_IJ^B, we had to use a pure R implementation of CI random forests. This is different for CART random forests, where a C implementation already exists in the randomForest package. However, it should be noted that the difference in computational times is due to the random forest creation step, not the implementation of V_IJ^B. This should not be an issue in the future when a C implementation of CI random forests is created.

Note: This function does not use the default predict method for forests produced by cforest. The predictions here are the direct averages of all tree predictions, instead of using the observation weights. Therefore, predictions from this function will likely differ from predict.cforest when using subsampling.

This function currently only works with regression forests – not classification forests.

Value

A data frame with the predictions and prediction variances (and optionally 95% confidence interval)

Examples

1
2
3
4
5
library(randomForest)
data(airquality)
d <- na.omit(airquality)
rf <- randomForest(Ozone ~ .,data=d,keep.inbag=TRUE,sampsize=30,replace=FALSE,ntree=500)
rfPredVar(rf,rf.data=d,CI=TRUE,tree.type='rf')

Example output

Loading required package: randomForest
randomForest 4.6-14
Type rfNews() to see new features/changes/bug fixes.
        pred pred.ij.var        l.ci      u.ci
1   40.68394  10.3243791   20.448533  60.91935
2   31.23464   2.1249845   27.069750  35.39954
3   24.42364   4.9763487   14.670175  34.17710
4   26.23401   4.9245955   16.581976  35.88604
7   30.41251  11.7472413    7.388340  53.43668
8   20.82393   5.1863699   10.658836  30.98903
9   18.08028   7.0128366    4.335370  31.82518
12  23.84250   1.9964695   19.929488  27.75550
13  24.32984   2.3206905   19.781374  28.87831
14  23.22877   1.9498478   19.407141  27.05040
15  16.41163   2.1531510   12.191536  20.63173
16  22.89714   3.3257768   16.378736  29.41554
17  24.42264   4.6504045   15.308014  33.53726
18  17.12517   4.9267799    7.468861  26.78148
19  24.17524   2.8559941   18.577593  29.77288
20  15.60213   3.5943783    8.557277  22.64698
21  14.80434   5.1228547    4.763728  24.84495
22  22.47148   5.3485178   11.988575  32.95438
23  16.07760   4.7919063    6.685632  25.46956
24  21.97477   2.2999363   17.466980  26.48256
28  25.07361   6.0356704   13.243909  36.90330
29  43.75174  18.8493608    6.807675  80.69581
30  67.92751  86.0774362 -100.781165 236.63618
31  45.20698   3.3241004   38.691860  51.72209
38  31.40482   5.6779091   20.276322  42.53332
40  54.43472   6.6966972   41.309434  67.56000
41  47.22202   3.6473395   40.073365  54.37067
44  34.53692  11.0752420   12.829844  56.24399
47  26.37849   3.7915776   18.947130  33.80984
48  26.48912   6.2648569   14.210225  38.76801
49  18.62717  -0.3822833   19.376428  17.87791
50  21.06895   4.0076580   13.214087  28.92382
51  22.34322   4.4901967   13.542595  31.14384
62  85.41890  79.9764037  -71.331971 242.16977
63  60.33807  22.7640628   15.721323 104.95481
64  45.03540  10.1288603   25.183199  64.88760
66  69.78987   8.1555914   53.805201  85.77453
67  45.10477   8.7085353   28.036351  62.17318
68  81.65542  17.4971821   47.361572 115.94927
69  80.55342  16.6550312   47.910158 113.19668
70  82.81652  19.1353453   45.311931 120.32111
71  70.88492  11.8755704   47.609229  94.16061
73  25.74753   2.9004357   20.062779  31.43228
74  35.45849   9.2057600   17.415528  53.50144
76  23.44657   9.5001710    4.826574  42.06656
77  49.26942   7.6943699   34.188731  64.35011
78  39.32425   2.8524770   33.733500  44.91500
79  67.34612  22.9123487   22.438741 112.25350
80  74.28935   6.1825912   62.171696  86.40701
81  53.71845   4.5642399   44.772707  62.66420
82  26.51204   6.7764517   13.230442  39.79364
85  63.86172  11.0388360   42.225998  85.49744
86  71.10199  21.6278259   28.712226 113.49175
87  38.91070  16.9229689    5.742291  72.07911
88  47.59893   8.4102798   31.115088  64.08278
89  73.74812   8.2436453   57.590871  89.90537
90  68.61989   6.3177802   56.237264  81.00251
91  63.49962   7.1383454   49.508719  77.49052
92  55.50592   8.8667743   38.127361  72.88448
93  44.81673  18.3713230    8.809602  80.82386
94  29.59337  22.1735327  -13.865959  73.05269
95  38.12710  23.4200750   -7.775403  84.02960
99  90.84453  34.9696685   22.305243 159.38382
100 68.61757  14.6060237   39.990286  97.24485
101 74.81873  19.2278297   37.132880 112.50459
104 54.10463   7.3973183   39.606156  68.60311
105 38.04923   5.3443980   27.574406  48.52406
106 37.75507  15.7235580    6.937459  68.57267
108 23.27051   4.7597069   13.941655  32.59936
109 43.74520  20.6211303    3.328527  84.16187
110 30.68584   6.2496176   18.436817  42.93487
111 33.02927   3.8656576   25.452717  40.60582
112 34.17393   4.6873041   24.986986  43.36088
113 27.09758   1.3505187   24.450608  29.74454
114 17.27018   1.5299276   14.271573  20.26878
116 44.38040  24.7751155   -4.177934  92.93873
117 79.65520 126.8141159 -168.895900 328.20630
118 71.22003  10.3968061   50.842668  91.59740
120 70.22293  13.4450248   43.871169  96.57470
121 91.06390  31.7532246   28.828723 153.29908
122 82.41903  11.8553475   59.182979 105.65509
123 79.91493  10.0492894   60.218688  99.61118
124 72.15672  15.2593623   42.248921 102.06452
125 79.39492   4.1839329   71.194566  87.59528
126 83.12062   3.2672144   76.717001  89.52425
127 79.75546   4.6926379   70.558056  88.95286
128 49.13521   6.9421416   35.528864  62.74156
129 38.64165   6.0320986   26.818949  50.46434
130 35.69016   6.3746106   23.196154  48.18417
131 32.23633   5.7188431   21.027601  43.44505
132 27.45174   2.4345158   22.680174  32.22330
133 27.58210   1.2041738   25.221967  29.94224
134 34.67612   5.4935957   23.908873  45.44337
135 24.01117   0.2648451   23.492079  24.53025
136 43.31077  12.3259993   19.152258  67.46929
137 17.84842   2.2848305   13.370235  22.32661
138 20.98007   1.5734511   17.896163  24.06398
139 38.17963   3.3778651   31.559134  44.80012
140 24.87453   1.8581234   21.232678  28.51639
141 18.40092   1.7382313   14.994050  21.80779
142 24.90554   1.0068481   22.932151  26.87892
143 39.84663  19.4323806    1.759862  77.93339
144 23.34297   1.5864256   20.233634  26.45231
145 19.15875   0.9492059   17.298345  21.01916
146 30.88619   5.1948743   20.704428  41.06796
147 20.41757   4.8593395   10.893435  29.94170
148 21.08585   3.2237037   14.767506  27.40419
149 39.15747   5.9789174   27.439003  50.87593
151 31.59813  11.1922658    9.661695  53.53457
152 33.58547   9.7879199   14.401495  52.76944
153 36.83620   5.3753407   26.300725  47.37167

RFinfer documentation built on May 30, 2017, 12:20 a.m.