print and summary method for "imputation" class.

# S3 method for class 'imputation'
summary(object, ...)

Arguments

object

an object of class "imputation", usually, a result of a call to imputate_na() or imputate_outlier().

...

further arguments passed to or from other methods.

Details

summary.imputation() tries to be smart about formatting two kinds of imputation.

See also

imputate_na, imputate_outlier, summary.imputation.

Examples

# Generate data for the example
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 20), "platelets"] <- NA
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "smoking"] <- NA

# Impute missing values -----------------------------
# If the variable of interest is a numerical variables
platelets <- imputate_na(heartfailure2, platelets, yvar = death_event, method = "rpart")
summary(platelets)
#> * Impute missing values based on Recursive Partitioning and Regression Trees
#>  - method : rpart
#> 
#> * Information of Imputation (before vs after)
#>                     Original   Imputation
#> described_variables "value"    "value"   
#> n                   "279"      "299"     
#> na                  "20"       " 0"      
#> mean                "263003.5" "263166.1"
#> sd                  "99157.03" "96308.95"
#> se_mean             "5936.376" "5569.691"
#> IQR                 "90500"    "85500"   
#> skewness            "1.509088" "1.537292"
#> kurtosis            "6.322138" "6.758119"
#> p00                 "25100"    "25100"   
#> p01                 "59580"    "61780"   
#> p05                 "129700"   "131800"  
#> p10                 "153000"   "159000"  
#> p20                 "195200"   "202200"  
#> p25                 "211500"   "216000"  
#> p30                 "221000"   "223000"  
#> p40                 "237000"   "237000"  
#> p50                 "260000"   "257000"  
#> p60                 "265000"   "265000"  
#> p70                 "283600.0" "282637.8"
#> p75                 "302000"   "301500"  
#> p80                 "318400"   "317400"  
#> p90                 "371600"   "368000"  
#> p95                 "429100"   "422500"  
#> p99                 "560160"   "544560"  
#> p100                "850000"   "850000"  

# If the variable of interest is a categorical variables
smoking <- imputate_na(heartfailure2, smoking, yvar = death_event, method = "rpart")
summary(smoking)
#> * Impute missing values based on Recursive Partitioning and Regression Trees
#>  - method : rpart
#> 
#> * Information of Imputation (before vs after)
#>      original imputation original_percent imputation_percent
#> No        200        204            66.89              68.23
#> Yes        94         95            31.44              31.77
#> <NA>        5          0             1.67               0.00

# Impute outliers ----------------------------------
# If the variable of interest is a numerical variable
platelets <- imputate_outlier(heartfailure2, platelets, method = "capping")
summary(platelets)
#> Impute outliers with capping
#> 
#> * Information of Imputation (before vs after)
#>                     Original     Imputation  
#> described_variables "value"      "value"     
#> n                   "279"        "279"       
#> na                  "20"         "20"        
#> mean                "263003.5"   "259308.9"  
#> sd                  "99157.03"   "77943.41"  
#> se_mean             "5936.376"   "4666.350"  
#> IQR                 "90500"      "90500"     
#> skewness            "1.5090881"  "0.3714559" 
#> kurtosis            " 6.3221379" "-0.1898946"
#> p00                 "25100"      "87000"     
#> p01                 " 59580"     "121340"    
#> p05                 "129700"     "129970"    
#> p10                 "153000"     "153000"    
#> p20                 "195200"     "195200"    
#> p25                 "211500"     "211500"    
#> p30                 "221000"     "221000"    
#> p40                 "237000"     "237000"    
#> p50                 "260000"     "260000"    
#> p60                 "265000"     "265000"    
#> p70                 "283600"     "283600"    
#> p75                 "302000"     "302000"    
#> p80                 "318400"     "318400"    
#> p90                 "371600"     "371600"    
#> p95                 "429100"     "427210"    
#> p99                 "560160"     "429100"    
#> p100                "850000"     "429100"