Learn R Programming

SBMTrees (version 1.2)

apply_locf_nocb: Impute Missing Values Using LOCF and NOCB

Description

Imputes missing values in a matrix by applying Last Observation Carried Forward (LOCF) followed by Next Observation Carried Backward (NOCB) for each subject.

Usage

apply_locf_nocb(X, subject_id)

Value

A matrix with missing values imputed using LOCF and NOCB.

Arguments

X

A matrix where rows represent observations and columns represent variables.

subject_id

A vector of subject IDs corresponding to the rows of X.

Examples

Run this code
X <- matrix(c(NA, 2, NA, 4, 5, NA, 7, 8, NA, NA), nrow = 5, byrow = TRUE)
subject_id <- c(1, 1, 1, 2, 2)
apply_locf_nocb(X, subject_id)

Run the code above in your browser using DataLab