This function combines two compatible (same decision, same training data structure and same depth) models into a single ensemble. It can be used to distribute model training, perform it on batches of data, save checkouts or precisely investigate its course.

```
# S3 method for rFerns
merge(
x,
y,
dropModel = FALSE,
ignoreObjectConsistency = FALSE,
trueY = NULL,
...
)
```

x

Object of a class `rFerns`

; a first model to be merged.

y

Object of a class `rFerns`

; a second model to be merged.
Can also be `NULL`

, `x`

is immediately returned in that case.
Has to have be built on the same kind of training data as `x`

, with the same depth.

dropModel

If `TRUE`

, model structure will be dropped to save size.
This disallows prediction using the merged model, but retains importance and OOB approximations.

ignoreObjectConsistency

If `TRUE`

, merge will be done even if both models were built on a different sets of objects.
This drops OOB approximations.

trueY

Copy of the training decision, used to re-construct OOB error and confusion matrix.
Can be omitted, OOB error and confusion matrix will disappear in that case; ignored when `ignoreObjectConsistency`

is `TRUE`

.

...

Ignored, for S3 gerneric/method consistency.

An object of class `rFerns`

, which is a list with the following components:

The merged model in case both `x`

and `y`

had model structures included and `dropModel`

was `FALSE`

.
Otherwise `NULL`

.

OOB approximation of accuracy, if can be computed.
Namely, when `oobScores`

could be and `trueY`

is provided.

The merged importance scores in case both `x`

and `y`

had importance calculated.
Shadow importance appears only if both models had it enabled.

OOB scores, if can be computed; namely if both models had it calculated and `ignoreObjectConsistency`

was not used.

A vector of OOB predictions of class for each object in training set, if can be computed.

OOB confusion matrix, if can be computed.
Namely, when `oobScores`

could be and `trueY`

is provided.

Time used to train the model, calculated as a sum of training times of `x`

and `y`

.

Numerical vector of three elements: `classes`

, `depth`

and `ferns`

.

Copy of `levels(Y)`

after purging unused levels.

Copy of the train set structure.

Set to `TRUE`

to mark that merging was done.

# NOT RUN { set.seed(77) #Fetch Iris data data(iris) #Build models rFerns(Species~.,data=iris)->modelA rFerns(Species~.,data=iris)->modelB modelAB<-merge(modelA,modelB) print(modelA) print(modelAB) # }