This function calculates the optimal mtry for a given Random Forest (RF) model in a specified range of values. The optimal mtry value can then be used in the grf model.
rf.mtry.optim(formula, dataset, min.mtry=NULL, max.mtry=NULL, mtry.step,
cv.method="repeatedcv", cv.folds=10, ...)
A list is returned of class train as in the function train
in the caret
package.
the model to be fitted using the function train
of the R package caret
.
a numeric data frame of at least two suitable variables (one dependent and one independent)
the minimum mtry value for its optimisation (function expand.grid
)
the maximum mtry value for its optimisation (function expand.grid
)
the step in the sequence of mtry values for its optimisation (function expand.grid
)
the resampling method in the function trainControl
of the R package caret
. Default option is "repeatedcv" and alternative option is "cv".
the number of folds (argument "number" in the function trainControl
). Default value is 10)
additional arguments affecting the function trainControl
)
Stamatis Kalogirou <stamatis@lctools.science>, Stefanos Georganos <sgeorgan@ulb.ac.be>
Based on the train
function of the caret
package, this function sets up a grid of tuning parameters for a number of random forest routines, fits each model and calculates a resampling based performance measure to choose the best mtry value.
Kuhn, M. (2008). Building Predictive Models in R Using the caret Package. Journal of Statistical Software, 28(5), 1 - 26. doi: <http://dx.doi.org/10.18637/jss.v028.i05>
Georganos, S. and Kalogirou, S. (2022) A Forest of Forests: A Spatially Weighted and Computationally Efficient Formulation of Geographical Random Forests. ISPRS, International Journal of Geo-Information, 2022, 11, 471. <https://www.mdpi.com/2220-9964/11/9/471>
# \donttest{
data(Income)
Coords <- Income[ ,1:2]
results <- rf.mtry.optim(Income01 ~ UnemrT01 + PrSect01, Income)
# }
Run the code above in your browser using DataLab