misclass                package:simex                R Documentation

_G_e_n_e_r_a_t_e_s _M_i_s_c_l_a_s_s_i_f_i_e_d _D_a_t_a

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

     Takes a 'data.frame' and produces misclassifed data. 
     Probabilities for the missclassification are given in the
     'mc.matrix'.

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

     misclass(data.org, mc.matrix, k)

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

data.org: 'data.frame' containing the factor variabels. Must be
          'factors'.

mc.matrix: a 'list' of matrices giving the probabilities for the
          misclassification.  Names of the 'list' must correspond to
          the variable names in 'data.org'. The 'colnames' must be
          named according to the factor levels

       k: the exponent for the misclassification matrix 

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

     'data.frame' containing the misclassified variables

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

     Wolfgang Lederer

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

     'mcsimex', 'check.mc.matrix'

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

     x1 <- factor(rbinom(100,1,0.5))
     x2 <- factor(rbinom(100,2,0.5))

     p1 <- matrix(c(1,0,0,1), nrow = 2)
     p2 <- matrix(c(0.8,0.1,0.1,0.1,0.8,0.1,0.1,0.1,0.8), nrow = 3)

     colnames(p1) <- levels(x1)
     colnames(p2) <- levels(x2)

     x <- data.frame(x1 = x1, x2 = x2)
     mc.matrix <- list(x1 = p1, x2 = p2)

     x.mc <- misclass(data.org = x, mc.matrix = mc.matrix,k = 1)

     identical(x[,1],x.mc[,1]) # T
     identical(x[,2],x.mc[,2]) # F

