DynForest
methodologyDynForest
is a random
forest methodology which can include both time-fixed predictors of any
nature and time-dependent predictors possibly measured at irregular
times. The purpose of DynForest
is to predict an outcome
which can be categorical, continuous or survival (with possibly
competing events).
The random forest should first be built on a learning dataset of N subjects including: Y the outcome; ℳx an ensemble of P time-fixed predictors; ℳz an ensemble of Q time-dependent predictors. The random forest consists of an ensemble of B trees which are grown as detailed below.
The tree building process, summarized in Figure 1, aims to recursively partition the subjects into groups/nodes that are the most homogeneous regarding the outcome Y.
For each tree b (b = 1, ..., B), we first draw a bootstrap sample from the original dataset of N subjects (N draws among the N subjects with replacement). The subjects excluded by the bootstrap constitute the out-of-bag (OOB) sample, noted OOBb for tree b. At each node d ∈ 𝒟b of the tree, we recursively repeat the following steps using the N(d) subjects located at node d:
An ensemble of ℳ(d) = {ℳx(d), ℳz(d)} candidate predictors are randomly selected among {ℳx, ℳz} (see Figure 1B). The size of ℳ(d) is defined by the hyperparameter mtry.
For each time-dependent predictor in ℳz(d):
We define ℳ⋆(d) = {ℳx(d), ℳz⋆(d)} our new ensemble of candidate features.
For each candidate feature W ∈ ℳ⋆(d):
We split the subjects into the two groups that minimize (for continuous and categorical outcome) or maximize (for survival outcome) the quantity defined previously. We denote {W0d, c0d} the optimal couple used to split the subjects and assign them to the left and right daughter nodes 2d and 2d + 1, respectively (see Figure 1D and A).
Step 1 to 5 are iterated on the daughter nodes until stopping criteria are met.
We define two stopping criteria: nodesize
the minimal
number of subjects in a node required to reiterate the split and
minsplit
the minimal number of events required to split the
node. minsplit
is only defined with survival outcome. In
the following, we call leaves the terminal nodes.
In each leaf h ∈ ℋb of tree b, a summary πhb is computed using the individuals belonging to the leaf. The leaf summary is defined according to the outcome:
NOTE: Step 2 involves the estimation of a parametric mixed model for each time-dependent predictor. The specification of this model should be carefully determined in preliminary analyses by the user, keeping in mind that there should be a trade-off between goodness-of-fit and parameter parsimony. The critical point is to adequately specify the trajectory shape over time at the population and individual levels. Different bases of time functions can be considered (e.g., fractional polynomials, splines, adhoc) and compared in terms of fit.
The overall OOB prediction π̂⋆ for a subject ⋆ can be computed by averaging the tree-based predictions of ⋆ over the random forest as follows: where 𝒪⋆ is the ensemble of trees where ⋆ is OOB and |𝒪⋆| denotes its cardinal The prediction π̂h⋆b is obtained by dropping down subject ⋆ along tree b. At each node d ∈ 𝒟b, the subject ⋆ is assigned to the left or right node according to his/her data and the optimal couple {W0d, c0d}. W0d is a random-effect feature, its value for ⋆ is predicted from the individual repeated measures using the estimated parameters from the linear mixed model.
With a survival outcome, the OOB prediction described in the previous
paragraph can be extended to compute the individual probability of event
from a landmark time s by
exploiting the repeated measures of subject ⋆ only until s. For a new subject ⋆, we thus define the individual probability
of event, noted π̂⋆(s, t),
as the probability of experiencing the event by time s + t given the information
prior to landmark time s:
where π̂h⋆b(s, t)
is the tree-based probability of event at time s + t computed by dropping
down ⋆ along the tree by considering
longitudinal predictors collected until s and time-fixed predictors. Note
that any horizon t can be
considered provided s + t remains in the time
window on which the random forest was trained. In the
DynForest
package, by default, the probability is computed
at all the observed event times after the landmark time.
Using the OOB individual predictions, an OOB prediction error can be internally assessed. The OOB prediction error quantifies the difference between the observed and the predicted values. It is defined according to the nature of Y as:
with T the time-to-event, k the cause of interest and ω̂(t) the estimated weights using Inverse Probability of Censoring Weights (IPCW) technique that accounts for censoring (Gerds and Schumacher 2006).
The OOB error of prediction is used to particular to tune the random
forest by determining the hyperparameters (i.e., mtry
,
nodesize
and minsplit
) which give the smallest
OOB prediction error.
The variable importance (VIMP) measures the loss of predictive performance (Ishwaran et al. 2008) when removing the link between a predictor and the outcome. The link is removed by permuting the predictor values at the subject level for time-fixed predictors or at observation level for time-dependent predictors. A large VIMP value indicates a good prediction ability for the predictor.
However, in case of correlated predictors, the VIMP may not properly quantify the variable importance (Gregorutti, Michel, and Saint-Pierre 2017) as the information of the predictor may still be present. To better handle situations with highly correlated predictors, the grouped variable importance (gVIMP) can be computed indirectly. It consists in simultaneously evaluate the importance of a group of predictors defined by the user. The computation is the same as for the VIMP except the permutation is performed simultaneously on all the predictors of the group. A large gVIMP value indicates a good prediction ability for the group of predictors.
The minimal depth is another statistic to quantify the importance of a variable. It assesses the distance between the root node and the first node for which the predictor is used to split the subjects (1 for first level, 2 for second level, 3 for third level, …). This statistic can be computed at the predictor level or at the feature level, allowing to fully understand the tree building process.
We strongly advice to compute the minimal depth with
mtry
hyperparameter chosen at its maximum to ensure that
all predictors are systematically among candidate predictors for
splitting the subjects.