MyNixOS website logo
Description

Random Forest with Multivariate Longitudinal Predictors.

Based on random forest principle, 'DynForest' is able to include multiple longitudinal predictors to provide individual predictions. Longitudinal predictors are modeled through the random forest. The methodology is fully described for a survival outcome in: Devaux, Helmer, Genuer & Proust-Lima (2023) <doi: 10.1177/09622802231206477>.

CRANstatus Downloads R buildstatus

Description

DynForest is a R package aiming to predict an outcome using multivariate longitudinal predictors. The method is based on random forest principle where the longitudinal predictors are modeled through the random forest. DynForest currently supports continuous, categorical and survival outcome. The methodology is fully described for a survival outcome in the paper:

Devaux A., Helmer C., Genuer R. and Proust-Lima C. (2023). Random survival forests with multivariate longitudinal endogenous covariates. Statistical Methods in Medical Research. <doi:10.1177/09622802231206477>

DynForest user guide is also available in the paper:

Devaux A., Proust-Lima C. and Genuer R. (2023). Random Forests for time-fixed and time-dependent predictors: The DynForest R package. arXiv. <doi:10.48550/arXiv.2302.02670>

Installation

DynForest package version 1.1.2 could be install from the CRAN with:

install.packages("DynForest")

Development version of DynForest is also available from GitHub with:

# install.packages("devtools")
devtools::install_github("anthonydevaux/DynForest")

Quick example with survival outcome

Manage data

library(DynForest)
#> Registered S3 method overwritten by 'cmprsk':
#>   method      from
#>   plot.cuminc lcmm
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)

Build DynForest objects

# Build longitudinal data
timeData <- pbc2[,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 <- unique(pbc2[,c("id","age","drug","sex")])

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

Run DynForest() function

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

Get summary

summary(res_dyn)
#> DynForest executed for survival (competing risk) outcome 
#>  Splitting rule: Fine & Gray statistic test 
#>  Out-of-bag error type: Integrated Brier Score 
#>  Leaf statistic: Cumulative incidence function 
#> ---------------- 
#> Input 
#>  Number of subjects: 312 
#>  Longitudinal: 4 predictor(s) 
#>  Numeric: 1 predictor(s) 
#>  Factor: 2 predictor(s) 
#> ---------------- 
#> Tuning parameters 
#>  mtry: 3 
#>  nodesize: 5 
#>  minsplit: 5 
#>  ntree: 50 
#> ---------------- 
#> ---------------- 
#> DynForest summary 
#>  Average depth per tree: 5.94 
#>  Average number of leaves per tree: 20.44 
#>  Average number of subjects per leaf: 9.67 
#>  Average number of events of interest per leaf: 4.34 
#> ---------------- 
#> Computation time 
#>  Number of cores used: 15 
#>  Time difference of 1.04619 mins
#> ----------------
Metadata

Version

1.1.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows