print.DynForest {DynForest}R Documentation

Print function

Description

This function displays a brief summary regarding the trees (for class DynForest), a data frame with variable importance (for class DynForestVIMP) or the grouped variable importance (for class DynForestgVIMP).

Usage

## S3 method for class 'DynForest'
print(x, ...)

## S3 method for class 'DynForestVIMP'
print(x, ...)

## S3 method for class 'DynForestgVIMP'
print(x, ...)

## S3 method for class 'DynForestVarDepth'
print(x, ...)

## S3 method for class 'DynForestOOB'
print(x, ...)

## S3 method for class 'DynForestPred'
print(x, ...)

Arguments

x

Object inheriting from classes DynForest, DynForestVIMP or DynForestgVIMP.

...

Optional parameters to be passed to the low level function

See Also

DynForest var_depth compute_VIMP compute_gVIMP compute_OOBerror

Examples


data(pbc2)

# Get Gaussian distribution for longitudinal predictors
pbc2$serBilir <- log(pbc2$serBilir)
pbc2$SGOT <- log(pbc2$SGOT)
pbc2$albumin <- log(pbc2$albumin)
pbc2$alkaline <- log(pbc2$alkaline)

# Sample 100 subjects
set.seed(1234)
id <- unique(pbc2$id)
id_sample <- sample(id, 100)
id_row <- which(pbc2$id%in%id_sample)

pbc2_train <- pbc2[id_row,]

timeData_train <- pbc2_train[,c("id","time",
                                "serBilir","SGOT",
                                "albumin","alkaline")]

# Create object with longitudinal association for each predictor
timeVarModel <- list(serBilir = list(fixed = serBilir ~ time,
                                     random = ~ time),
                     SGOT = list(fixed = SGOT ~ time + I(time^2),
                                 random = ~ time + I(time^2)),
                     albumin = list(fixed = albumin ~ time,
                                    random = ~ time),
                     alkaline = list(fixed = alkaline ~ time,
                                     random = ~ time))

# Build fixed data
fixedData_train <- unique(pbc2_train[,c("id","age","drug","sex")])

# Build outcome data
Y <- list(type = "surv",
          Y = unique(pbc2_train[,c("id","years","event")]))

# Run DynForest function
res_dyn <- DynForest(timeData = timeData_train, fixedData = fixedData_train,
                     timeVar = "time", idVar = "id",
                     timeVarModel = timeVarModel, Y = Y,
                     ntree = 50, nodesize = 5, minsplit = 5,
                     cause = 2, ncores = 2, seed = 1234)

# Print function
print(res_dyn)

# Compute VIMP statistic
res_dyn_VIMP <- compute_VIMP(DynForest_obj = res_dyn, ncores = 2, seed = 1234)

# Print function
print(res_dyn_VIMP)

# Compute gVIMP statistic
res_dyn_gVIMP <- compute_gVIMP(DynForest_obj = res_dyn,
                               group = list(group1 = c("serBilir","SGOT"),
                                            group2 = c("albumin","alkaline")),
                               ncores = 2, seed = 1234)

# Print function
print(res_dyn_gVIMP)

# Run var_depth function
res_varDepth <- var_depth(res_dyn)

# Print function
print(res_varDepth)




[Package DynForest version 1.1.3 Index]