Last data update: 2014.03.03

R: rfPredVar
rfPredVarR Documentation

rfPredVar

Description

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

Usage

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

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')

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RFinfer)
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RFinfer/rfPredVar.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rfPredVar
> ### Title: rfPredVar
> ### Aliases: rfPredVar
> 
> ### ** Examples
> 
> 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')
        pred pred.ij.var        l.ci      u.ci
1   39.73059   7.7524290   24.536107  54.92507
2   28.08966   5.3934353   17.518717  38.66059
3   23.27279   4.6994501   14.062036  32.48354
4   25.55576   2.8853263   19.900620  31.21089
7   30.50232   0.3362483   29.843288  31.16136
8   20.40332   4.5428612   11.499478  29.30717
9   18.02975   5.6730639    6.910745  29.14875
12  24.34909   3.5935495   17.305861  31.39232
13  24.02742   3.5286015   17.111490  30.94335
14  22.81916   2.8134339   17.304927  28.33338
15  16.07831   1.4318998   13.271841  18.88478
16  23.07562   2.6820216   17.818957  28.33229
17  24.19359   3.6119483   17.114300  31.27288
18  16.43428   3.9431801    8.705788  24.16277
19  24.04042   2.5801882   18.983346  29.09750
20  15.80358   2.5859445   10.735221  20.87194
21  14.85775   4.6487349    5.746393  23.96910
22  23.15846   4.0936340   15.135080  31.18183
23  16.09588   4.2558752    7.754517  24.43724
24  20.93836   6.0948229    8.992722  32.88399
28  23.65311   3.2268074   17.328686  29.97754
29  44.30468  13.9360810   16.990461  71.61889
30  63.99303  73.0960907  -79.272680 207.25873
31  44.80748  10.7149831   23.806498  65.80846
38  29.58468   4.5451332   20.676380  38.49298
40  53.97851  22.6419014    9.601200  98.35582
41  46.54811   8.4399548   30.006104  63.09012
44  33.98474  10.5327850   13.340865  54.62862
47  26.42692   3.2943231   19.970168  32.88368
48  25.53707   4.8165143   16.096870  34.97726
49  17.93672   0.7151919   16.534972  19.33847
50  20.12607   2.4597945   15.304957  24.94717
51  21.39639   2.1847047   17.114446  25.67833
62  81.95700  62.3725557  -40.290963 204.20496
63  56.94240  20.9293277   15.921671  97.96313
64  44.04623   4.9025078   34.437495  53.65497
66  68.39603   5.4603222   57.693999  79.09807
67  44.41333   6.9680357   30.756234  58.07043
68  79.59537   8.8335027   62.282019  96.90871
69  81.66075  15.0602578   52.143187 111.17831
70  82.97542   9.2236249   64.897444 101.05339
71  70.26052  13.9028709   43.011390  97.50964
73  27.11210   9.0286387    9.416293  44.80791
74  36.82667   1.6172964   33.656824  39.99651
76  24.05843   8.3078986    7.775251  40.34162
77  49.94617   6.9466774   36.330929  63.56140
78  39.24203   1.4917598   36.318238  42.16583
79  65.49678   9.4161530   47.041463  83.95210
80  73.82062  16.4010844   41.675082 105.96615
81  51.51692   3.6778475   44.308468  58.72537
82  25.65840   3.7076386   18.391562  32.92524
85  62.61268  14.6601063   33.879403  91.34596
86  69.36035  38.9114292   -6.904650 145.62535
87  38.02567  17.8217922    3.095596  72.95574
88  46.05172   4.7864008   36.670543  55.43289
89  72.66075  14.0059433   45.209606 100.11189
90  69.36155  14.2209857   41.488930  97.23417
91  64.06288  10.8400394   42.816797  85.30897
92  55.01027  18.0118009   19.707786  90.31275
93  43.65397  13.2214869   17.740328  69.56760
94  28.97340  19.5917356   -9.425696  67.37250
95  36.73327  24.5386688  -11.361640  84.82817
99  89.35283  30.2100907   30.142144 148.56352
100 67.32147  18.3430264   31.369796 103.27314
101 74.63043  28.0188461   19.714504 129.54636
104 51.72103   7.4424839   37.134033  66.30803
105 37.81927  11.1299493   16.004967  59.63357
106 39.29910  18.8354647    2.382268  76.21593
108 21.80953   2.3460731   17.211315  26.40775
109 43.57627  18.7980031    6.732858  80.41968
110 29.37670   2.8691692   23.753232  35.00017
111 32.75123   9.0001891   15.111187  50.39128
112 34.93680   6.2462894   22.694298  47.17930
113 27.80877   5.8392693   16.364009  39.25352
114 17.99217   3.3074527   11.509679  24.47465
116 45.28803  12.4163074   20.952518  69.62355
117 76.85893 127.2356704 -172.518398 326.23626
118 69.51257  26.9025324   16.784572 122.24056
120 69.24370   9.2311753   51.150929  87.33647
121 90.49773  31.2680205   29.213539 151.78193
122 82.15027  11.7832413   59.055538 105.24500
123 80.97900  11.9652435   57.527554 104.43045
124 70.47533  41.5921501  -11.043787 151.99445
125 79.60430  21.8391098   36.800427 122.40816
126 81.93923  19.1283170   44.448417 119.43004
127 80.68966  18.2616341   44.897518 116.48181
128 49.23223  17.3232758   15.279233  83.18523
129 36.80272  11.8646974   13.548341  60.05710
130 35.82631  15.3023164    5.834322  65.81830
131 32.86494   4.2788315   24.478589  41.25130
132 28.54241   3.4639057   21.753281  35.33154
133 29.17500   0.8022814   27.602558  30.74744
134 34.66659   7.9499767   19.084924  50.24826
135 24.42233   3.0970240   18.352270  30.49238
136 44.14613   4.7936915   34.750671  53.54160
137 16.62505   1.5137115   13.658229  19.59187
138 20.21532   1.4183392   17.435422  22.99521
139 38.81493   5.1367092   28.747169  48.88270
140 23.55698   2.0953378   19.450196  27.66377
141 17.40132   1.3228870   14.808505  19.99413
142 24.78888   1.6194201   21.614877  27.96289
143 41.05297  35.8821131  -29.274682 111.38062
144 22.91002   3.6530365   15.750196  30.06984
145 18.32773   0.9136855   16.536943  20.11852
146 31.70482   9.6288819   12.832554  50.57708
147 19.05232   4.5018807   10.228792  27.87584
148 20.55829   4.3839757   11.965858  29.15073
149 38.15310   9.6559904   19.227707  57.07849
151 30.05972   9.7277813   10.993615  49.12582
152 32.69517  10.8326918   11.463482  53.92685
153 33.42828   9.8413951   14.139503  52.71706
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>