imp.sc: Imputation methods for special cases

imp.scR Documentation

Imputation methods for special cases

Description

imp.sc imputes value for special cases.

Usage

imp.sc(
  db,
  sc.all = c(NA, NaN, Inf, -Inf),
  sc.replace = c(NA, NaN, Inf, -Inf),
  method.num = "automatic",
  p.val = 0.05
)

Arguments

db

Data frame of risk factors supplied for imputation.

sc.all

Vector of all special case elements. Default values are c(NA, NaN, Inf).

sc.replace

Vector of special case element to be replaced. Default values are c(NA, NaN, Inf).

method.num

Imputation method for numeric risk factors. Available options are:
"automatic", "mean", "median", "zero".

p.val

Significance level of p-value for Pearson normality test. Applicable only if method.num is automatic.

Value

This function returns list of two data frames. The first data frame contains analyzed risk factors with imputed values for special cases, while the second data frame presents the imputation report. Using the imputation report, for each risk factor, user can inspect imputed info (info), imputation method (imputation.method), imputed value (imputed.value), number of imputed observations (imputation.num) and imputed mode (imputed.mode - applicable only for categorical risk factors) for each risk factor.

Examples

suppressMessages(library(PDtoolkit))
data(gcd)
gcd$age[1:20] <- NA
gcd$age.bin <- ndr.bin(x = gcd$age, y = gcd$qual, sc.method = "separately", y.type = "bina")[[2]]
gcd$dummy1 <- NA
#select risk factors for which we want to impute missing values (NA)
db.imp <- gcd[, c("age", "age.bin", "dummy1")]
colSums(is.na(db.imp))
imput.res <- imp.sc(db = db.imp, 
	      method.num = "automatic",
	      p.val = 0.05)
#analyzed risk factors with imputed values
head(imput.res[[1]])
#imputation report
imput.res[[2]]

PDtoolkit documentation built on Sept. 20, 2023, 9:06 a.m.