Learn R Programming

metaforest (version 0.1.4)

predict.MetaForest: MetaForest prediction

Description

MetaForest prediction

Usage

# S3 method for MetaForest
predict(object, data = NULL, type = "response", ...)

Value

Object of class MetaForest.prediction with elements

predictionsPredicted classes/values (only for classification and regression)
num.treesNumber of trees.
num.independent.variablesNumber of independent variables.
treetypeType of forest/tree. Classification, regression or survival.
num.samplesNumber of samples.

Arguments

object

MetaForest object.

data

New test data of class data.frame.

type

Type of prediction. One of 'response', 'se', 'terminalNodes' with default 'response'. See below for details.

...

further arguments passed to or from other methods.

See Also

ranger

Examples

Run this code
set.seed(56)
data <- SimulateSMD(k_train = 100, model = es * x[,1] * x[,2])
#Conduct fixed-effects MetaForest analysis
mf.fixed <- MetaForest(formula = yi ~ ., data = data$training,
                      whichweights = "fixed", method = "DL")
predicted <- predict(mf.fixed, data = data$testing)$predictions
r2_cv <- sum((predicted - mean(data$training$yi)) ^ 2)/
         sum((data$testing$yi - mean(data$training$yi)) ^ 2)

Run the code above in your browser using DataLab