ce.mimp: Mean or median imputation

Description Usage Arguments Value Note Author(s) References Examples

View source: R/ce.mimp.R

Description

A function that detects the location of missing values by class, then imputes the missing values that occur in the features, using mean or median imputation, as selected by the user. If the feature is nominal then imputation is done using the mode.

Usage

1
ce.mimp(w.cl, method = c("mean", "median"), atr, nomatr = 0)

Arguments

w.cl

dataset with missing values.

method

either "mean" or "median"

atr

list of relevant features

nomatr

list of nominal features, imputation is done using mode

Value

w.cl

the original matrix with values imputed

Note

A description of all the imputations carried out may be stored in a report that is later saved to the current workspace. To produce the report, lines at the end of the code must be uncommented. The report objects name starts with Imput.rep.

Author(s)

Caroline Rodriguez and Edgar Acuna

References

Acuna, E. and Rodriguez, C. (2004). The treatment of missing values and its effect in the classifier accuracy. In D. Banks, L. House, F.R. McMorris, P. Arabie, W. Gaul (Eds). Classification, Clustering and Data Mining Applications. Springer-Verlag Berlin-Heidelberg, 639-648.

Examples

1
2
3
data(hepatitis)
#--------Mean Imputation---------- 
hepa.mean.imp=ce.impute(hepatitis,"mean",1:19)

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE 
3: .onUnload failed in unloadNamespace() for 'rgl', details:
  call: fun(...)
  error: object 'rgl_quit' not found 

Summary of imputations using substitution of  mean (mode for nominal features):
       Row Column Class Imput.value
  [1,]   1     19     2   66.571429
  [2,]   2     19     2   66.571429
  [3,]   3     19     2   66.571429
  [4,]   4      4     2    1.540984
  [5,]   5     16     2  101.313725
  [6,]   5     19     2   66.571429
  [7,]   7     15     1    2.543333
  [8,]   7     16     1  122.375000
  [9,]   7     17     1   99.833333
 [10,]   7     18     1    3.151852
 [11,]   7     19     1   43.500000
 [12,]   8     16     2  101.313725
 [13,]   8     17     2   82.438017
 [14,]   8     18     2    3.977679
 [15,]   8     19     2   66.571429
 [16,]   9     16     2  101.313725
 [17,]   9     19     2   66.571429
 [18,]  10     16     2  101.313725
 [19,]  10     19     2   66.571429
 [20,]  15     15     2    1.146218
 [21,]  15     16     2  101.313725
 [22,]  15     18     2    3.977679
 [23,]  15     19     2   66.571429
 [24,]  17     19     2   66.571429
 [25,]  27     19     2   66.571429
 [26,]  32      9     1    1.888889
 [27,]  32     10     1    1.518519
 [28,]  32     16     1  122.375000
 [29,]  32     18     1    3.151852
 [30,]  32     19     1   43.500000
 [31,]  36     19     1   43.500000
 [32,]  38     19     2   66.571429
 [33,]  42      9     2    1.813559
 [34,]  42     10     2    1.598291
 [35,]  42     11     2    1.848739
 [36,]  42     12     2    1.756303
 [37,]  42     13     2    1.949580
 [38,]  42     14     2    1.941176
 [39,]  42     19     2   66.571429
 [40,]  45     15     2    1.146218
 [41,]  45     16     2  101.313725
 [42,]  45     18     2    3.977679
 [43,]  45     19     2   66.571429
 [44,]  46     19     2   66.571429
 [45,]  47     19     2   66.571429
 [46,]  51     19     2   66.571429
 [47,]  52     19     2   66.571429
 [48,]  56     18     2    3.977679
 [49,]  56     19     2   66.571429
 [50,]  57      6     2    1.426230
 [51,]  57      7     2    1.688525
 [52,]  57      8     2    1.819672
 [53,]  57      9     2    1.813559
 [54,]  57     10     2    1.598291
 [55,]  57     11     2    1.848739
 [56,]  57     12     2    1.756303
 [57,]  57     13     2    1.949580
 [58,]  57     14     2    1.941176
 [59,]  57     15     2    1.146218
 [60,]  57     16     2  101.313725
 [61,]  57     17     2   82.438017
 [62,]  57     18     2    3.977679
 [63,]  57     19     2   66.571429
 [64,]  60     18     2    3.977679
 [65,]  60     19     2   66.571429
 [66,]  66     16     2  101.313725
 [67,]  66     19     2   66.571429
 [68,]  67     19     2   66.571429
 [69,]  68     16     1  122.375000
 [70,]  70     19     2   66.571429
 [71,]  71     19     2   66.571429
 [72,]  72     18     1    3.151852
 [73,]  72     19     1   43.500000
 [74,]  73      9     2    1.813559
 [75,]  73     10     2    1.598291
 [76,]  73     11     2    1.848739
 [77,]  73     12     2    1.756303
 [78,]  73     13     2    1.949580
 [79,]  73     14     2    1.941176
 [80,]  73     19     2   66.571429
 [81,]  74     16     2  101.313725
 [82,]  75     19     2   66.571429
 [83,]  77     19     1   43.500000
 [84,]  80     19     2   66.571429
 [85,]  81     16     2  101.313725
 [86,]  81     19     2   66.571429
 [87,]  84     11     2    1.848739
 [88,]  84     12     2    1.756303
 [89,]  84     13     2    1.949580
 [90,]  84     14     2    1.941176
 [91,]  84     19     2   66.571429
 [92,]  87     18     1    3.151852
 [93,]  88     19     1   43.500000
 [94,]  89     19     1   43.500000
 [95,]  92     16     1  122.375000
 [96,]  92     19     1   43.500000
 [97,]  93      9     2    1.813559
 [98,]  93     10     2    1.598291
 [99,]  93     16     2  101.313725
[100,]  93     19     2   66.571429
[101,]  94     16     2  101.313725
[102,]  94     19     2   66.571429
[103,]  98     19     2   66.571429
[104,] 100     15     2    1.146218
[105,] 100     16     2  101.313725
[106,] 100     18     2    3.977679
[107,] 100     19     2   66.571429
[108,] 102     16     2  101.313725
[109,] 102     18     2    3.977679
[110,] 102     19     2   66.571429
[111,] 106     16     2  101.313725
[112,] 106     19     2   66.571429
[113,] 107      9     1    1.888889
[114,] 107     10     1    1.518519
[115,] 107     19     1   43.500000
[116,] 108     16     2  101.313725
[117,] 108     18     2    3.977679
[118,] 108     19     2   66.571429
[119,] 111     19     2   66.571429
[120,] 113     19     2   66.571429
[121,] 114     19     2   66.571429
[122,] 115     19     2   66.571429
[123,] 116     18     2    3.977679
[124,] 116     19     2   66.571429
[125,] 117     16     2  101.313725
[126,] 117     19     2   66.571429
[127,] 119      9     1    1.888889
[128,] 119     10     1    1.518519
[129,] 119     15     1    2.543333
[130,] 119     16     1  122.375000
[131,] 119     17     1   99.833333
[132,] 119     18     1    3.151852
[133,] 119     19     1   43.500000
[134,] 120     19     2   66.571429
[135,] 121     19     1   43.500000
[136,] 123     18     2    3.977679
[137,] 123     19     2   66.571429
[138,] 124     16     2  101.313725
[139,] 124     19     2   66.571429
[140,] 127      9     2    1.813559
[141,] 127     10     2    1.598291
[142,] 127     16     2  101.313725
[143,] 127     19     2   66.571429
[144,] 132     16     1  122.375000
[145,] 132     19     1   43.500000
[146,] 133     19     2   66.571429
[147,] 137     16     2  101.313725
[148,] 137     19     2   66.571429
[149,] 141     19     2   66.571429
[150,] 142      9     1    1.888889
[151,] 142     10     1    1.518519
[152,] 143     16     2  101.313725
[153,] 145     16     1  122.375000
[154,] 145     19     1   43.500000
[155,] 147     19     1   43.500000
[156,] 148      9     1    1.888889
[157,] 148     10     1    1.518519
[158,] 148     11     1    1.612903
[159,] 148     12     1    1.290323
[160,] 148     13     1    1.548387
[161,] 148     14     1    1.645161
[162,] 149     10     2    1.598291
[163,] 149     19     2   66.571429
[164,] 150     19     2   66.571429
[165,] 151     16     1  122.375000
[166,] 152     19     2   66.571429
[167,] 153     19     2   66.571429

Total number of imputations per class: 

  1   2 
 45 122 

Total number of imputations:  167 

dprep documentation built on May 29, 2017, 11:01 a.m.