predict.rfcca {RFCCA} | R Documentation |
Predict method for rfcca objects
Description
Obtain predicted canonical correlations using a rfcca forest for training or new data.
Usage
## S3 method for class 'rfcca'
predict(
object,
newdata,
membership = FALSE,
finalcca = c("cca", "scca", "rcca"),
...
)
Arguments
object |
An object of class |
newdata |
Test data of the set of subject-related covariates (Z). A
data.frame with numeric values and factors. If missing, the out-of-bag
predictions in |
membership |
Should terminal node membership information be returned? |
finalcca |
Which CCA should be used for final canonical correlation
estimation? Choices are |
... |
Optional arguments to be passed to other methods. |
Value
An object of class (rfcca,predict)
which is a list with the
following components:
call |
The original grow call to |
n |
Sample size of the test data ( |
ntree |
Number of trees grown. |
xvar |
Data frame of x-variables. |
xvar.names |
A character vector of the x-variable names. |
yvar |
Data frame of y-variables. |
yvar.names |
A character vector of the y-variable names. |
zvar |
Data frame of test z-variables. If |
zvar.names |
A character vector of the z-variable names. |
forest |
The |
membership |
A matrix recording terminal node membership for the test data where each cell represents the node number that an observation falls in for that tree. |
predicted |
Test set predicted canonical correlations based on the
selected final canonical correlation estimation method. If |
predicted.coef |
Predicted canonical weight vectors for x- and y- variables. |
finalcca |
The selected CCA used for final canonical correlation estimations. |
See Also
Examples
## load generated example data
data(data, package = "RFCCA")
set.seed(2345)
## define train/test split
smp <- sample(1:nrow(data$X), size = round(nrow(data$X) * 0.7),
replace = FALSE)
train.data <- lapply(data, function(x) {x[smp, ]})
test.Z <- data$Z[-smp, ]
## train rfcca
rfcca.obj <- rfcca(X = train.data$X, Y = train.data$Y, Z = train.data$Z,
ntree = 100)
## predict without new data (OOB predictions will be returned)
pred.obj <- predict(rfcca.obj)
pred.oob <- pred.obj$predicted
## predict with new test data
pred.obj2 <- predict(rfcca.obj, newdata = test.Z)
pred <- pred.obj2$predicted
## print predict objects
print(pred.obj)
print(pred.obj2)