rescale_prepped_covariates: Rescale observed covariates

Description Usage Arguments Value

View source: R/covariate_prep_functions.R

Description

Rescale covariates so that each covariate has mean zero and variance 1 when measured at all observations in the dataset. Optionally, this function allows for rescaling based only on observations in the training subset of the data, as denoted by a field in the dataset

Usage

1
2
3
4
5
6
rescale_prepped_covariates(
  input_data,
  covar_names,
  subset_field = NULL,
  subset_field_values = NULL
)

Arguments

input_data

Data.table of the full dataset containing observations along with covariate data

covar_names

[char] vector of covariate names. All of these should be included as fields in the 'input_data'.

subset_field

[char, optional] Fill this option to rescale based on only observations from the training data (not the test data). This argument gives the field to subset on

subset_field_values

[optional] Fill this option to rescale based on only observations from the training data (not the test data). This argument gives the values of 'subset_field' indicating that an observation was in the training dataset and should be used for rescaling

Value

Named list containing two data.tables: - 'data_rescaled': Prepared dataset with rescaled covariate values - 'covariate_scaling_factors': Mean and SD of the original dataset (use to back-transform the scaled covariates)


njhenry/covidemr documentation built on Feb. 2, 2022, 2:31 a.m.