impTS: Imputing Time-Series Data

imputeTimeSeriesLabR Documentation

Imputing Time-Series Data

Description

imputeTimeSeriesLab does imputation for time-series data.

Usage

imputeTimeSeriesLab(
  labData,
  idColName,
  labItemColName,
  windowColName,
  valueColName,
  impMethod,
  imputeOverallMean = FALSe
)

Arguments

labData

a file or dataframe of laboratory test data with at least 4 columns about patient ID, lab item, test value and test date, respectively.

idColName

the column name that records patient ID in labData.

labItemColName

the column name that records lab item in labData. If lab code is combined by multiple columns, then just simply add + operator between column names, e.g., A + B.

windowColName

the column name that records time window sequence in labData.

valueColName

the column name that records lab test value in labData. If there are more than one value column to be imputed, just simply add & operator between column names, e.g., A & B, then imputation of multiple columns can be done simultaneously.

impMethod

desired imputation method:mean, interpolation or nocb.

imputeOverallMean

TRUE = If an individual never performed for a test before the data point, the mean of the test from all the individuals in the dataset can be used to impute. Default is FALSE

Details

Two imputation methods are provided: mean or interpolation. If choosing mean method, the imputation is based the mean of all other non-null values among all the windows of the specific lab item for certain patient. If interpolation, the imputation uses linear interpolation method, and other out-of-range null values will be imputed by mean of known values. If nocb, the imputation method is "next observation carried backward".

Value

A data.table with imputed data.

Examples


timeSeriesData <- getTimeSeriesLab(labData = labSample,
                                   idColName = SUBJECT_ID,
                                   labItemColName = ITEMID,
                                   dateColName = CHARTTIME,
                                   valueColName = VALUENUM,
                                   indexDate = first,
                                   gapDate = 360,
                                   completeWindows = TRUE)
imputeTSData <- imputeTimeSeriesLab(labData = timeSeriesData,
                                 idColName = ID,
                                 labItemColName = ITEMID,
                                 windowColName = Window,
                                 valueColName = Max & Min & Mean & Nearest,
                                 impMethod = mean,
                                 imputeOverallMean=FALSE)
head(imputeTSData)

DHLab-TSENG/lab documentation built on Sept. 1, 2023, 9:03 p.m.