Learn R Programming

AgeTopicModels (version 0.1.0)

age_imputation: imputing missing age if you can't find some of them The function does two stage imputation: i. if the individual has other age label -- use the mean, min, or max of other age labels for the missing ones. ii. if the individual has no age label -- use the mean, min, max for all the diagnosis codes iii. if there is no age info available for any of this code, we will impute it as the mean of all age codes in the data

Description

imputing missing age if you can't find some of them The function does two stage imputation: i. if the individual has other age label -- use the mean, min, or max of other age labels for the missing ones. ii. if the individual has no age label -- use the mean, min, max for all the diagnosis codes iii. if there is no age info available for any of this code, we will impute it as the mean of all age codes in the data

Usage

age_imputation(rec_data_missing_age, method = "mean")

Value

a data frame that is imputed and ready for wrapper_ATM

Arguments

rec_data_missing_age

a data frame with missing age info

method

use one of the three choices "mean", "min", "max"

Examples

Run this code
rec_data_missing_age <- HES_age_example
 rec_data_missing_age$age_diag[1:10000] <- NA
 rec_data_imputed <- age_imputation(rec_data_missing_age, method= "mean")
 cor(rec_data_imputed$age_diag[1:10000], HES_age_example$age_diag[1:10000])
 rec_data_imputed <- age_imputation(rec_data_missing_age, method= "min")
 cor(rec_data_imputed$age_diag[1:10000], HES_age_example$age_diag[1:10000])
 rec_data_imputed <- age_imputation(rec_data_missing_age, method= "max")
 cor(rec_data_imputed$age_diag[1:10000], HES_age_example$age_diag[1:10000])

Run the code above in your browser using DataLab