impute                 package:Hmisc                 R Documentation

_G_e_n_e_r_i_c _F_u_n_c_t_i_o_n_s _a_n_d _M_e_t_h_o_d_s _f_o_r _I_m_p_u_t_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     These functions do simple and 'transcan'  imputation and print,
     summarize, and subscript variables that have NAs filled-in with
     imputed values.  The simple imputation method involves filling in
     NAs with constants, with a specified single-valued function of the
     non-NAs, or from a sample (with replacement) from the non-NA
     values (this is useful in multiple imputation). More complex
     imputations can be done with the 'transcan' function, which also
     works with the generic methods shown here, i.e., 'impute' can take
     a 'transcan' object and use  the imputed values created by
     'transcan' (with 'imputed=TRUE')  to fill-in NAs. The 'print'
     method places * after variable values that were imputed. The
     'summary' method summarizes all imputed values and then uses the
     next 'summary' method available for the variable. The subscript
     method preserves attributes of the variable and subsets the list
     of imputed values corresponding with how the variable was
     subsetted.  The 'is.imputed' function is for checking if
     observations are imputed.

_U_s_a_g_e:

     impute(x, ...)

     ## Default S3 method:
     impute(x, fun=median, ...)

     ## S3 method for class 'impute':
     print(x, ...)

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

     is.imputed(x)

_A_r_g_u_m_e_n_t_s:

       x: a vector or an object created by 'transcan', or a vector
          needing basic unconditional imputation.  If there are no
          'NA's and 'x' is a vector, it is returned unchanged. 

     fun: the name of a function to use in computing the (single) 
          imputed value from the non-NAs.  The default is 'median'. If
          instead of specifying a function as 'fun', a single value or
          vector (numeric, or character if 'object' is a factor) is
          specified, those values are used for insertion.  'fun' can
          also be the character string '"random"' to draw random values
          for imputation, with the random values not forced to be the
          same if there are multiple NAs. For a vector of constants,
          the vector must be of length one (indicating the same value
          replaces all NAs) or must be as long as the number of NAs, in
          which case the values correspond to consecutive NAs to
          replace.  For a factor 'object', constants for imputation may
          include character values not in the current levels of
          'object'.  In that case new levels are added. If 'object' is
          of class '"factor"', 'fun' is ignored and the most frequent
          category is used for imputation. 

  object: an object of class '"impute"'

     ...: ignored

_V_a_l_u_e:

     a vector with class '"impute"' placed in front of existing
     classes. For 'is.imputed', a vector of logical values is returned
     (all 'TRUE' if 'object' is not of class 'impute').

_A_u_t_h_o_r(_s):

     Frank Harrell 
      Department of Biostatistics 
      Vanderbilt University 
      f.harrell@vanderbilt.edu

_S_e_e _A_l_s_o:

     'transcan', 'impute.transcan', 'describe', 'na.include', 'sample'

_E_x_a_m_p_l_e_s:

     age <- c(1,2,NA,4)
     age.i <- impute(age)
     # Could have used impute(age,2.5), impute(age,mean), impute(age,"random")
     age.i
     summary(age.i)
     is.imputed(age.i)

