nnmiss                package:SeqKnn                R Documentation

_S_e_l_e_c_t_s _k _n_e_a_r_e_s_t _n_e_i_g_h_b_o_r_s _a_n_d _c_a_l_c_u_l_a_t_e_s _w_e_i_g_h_t_e_d _m_e_a_n _o_f _t_h_e_m

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

     A function to select k nearest neighbors using Euclidean distance,
     and estimate missing value with weighted mean of selected
     neighbors.

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

     nnmiss(x, xmiss, ismiss, K)

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

       x: data frame which contains only complete cases

   xmiss: data frame which contains incomplete cases

  ismiss: data frame with logical value(TRUE or FALSE) of  'xmiss'

       K: number of nearest neighbors

_D_e_t_a_i_l_s:

     Appropriate number of k is 10-20. However, we need to control k
     smaller in case missing rate is high, especially k is larger than
     the size of complete set.

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

     Ki-Yeol Kim and Gwan-Su Yi

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

     ## Not run: 
         data(khan05)
         x <- as.matrix(khan05)
         N <- dim(x)
         p <- N[2]
         N <- N[1]
         nas <- is.na(drop(x %*% rep(1, p)))
         xcomplete <- x[!nas, ]           ## complete set
         xbad <- x[nas, , drop = FALSE]       ## incomplete set
         xnas <- is.na(xbad)       
         xbadhat <- xbad
         xbadhat[1,]<-nnmiss(xcomplete, xbad[1,], xnas[1,], 10)
     ## End(Not run)

