fn.folds_by_observation: Assign cross-fitting folds by observation rather than by row

View source: R/other-functions.R

fn.folds_by_observationR Documentation

Assign cross-fitting folds by observation rather than by row

Description

In a bootstrap sample the same original observation appears more than once. Assigning folds row by row would place copies of one observation in different folds, so a forest would train on one copy and predict another and the prediction would not be out of sample. This assigns one fold per distinct original observation, stratified by (S,Z) cell so every fold still sees all K \times J study-group combinations, and gives every copy that fold.

Usage

fn.folds_by_observation(data, orig_idx, n_folds = 5L)

Arguments

data

Structured data list for the (possibly resampled) data

orig_idx

Integer vector (length N) of original row numbers, i.e. indx.b from checkSample. For unresampled data this is seq_len(N) and the result matches row-wise assignment.

n_folds

Number of folds (default 5)

Value

Integer vector of fold assignments (length N)


WMAP documentation built on Oct. 6, 2026, 1:07 a.m.