knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
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.
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.
DynForest
package version 1.2.0 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")
library(DynForest) 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 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")]))
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)
summary(res_dyn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.