reclass.mat.diag          package:accuracy          R Documentation

_F_u_n_c_t_i_o_n _t_o _p_r_o_d_u_c_e _r_e_c_l_a_s_s_i_f_i_c_a_t_i_o_n _m_a_t_r_i_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     This returns a cumulative probability matrix useful for
     reclassifying discrete variables with PTBdiscrete.

_U_s_a_g_e:

     reclass.mat.diag(n, q)

_A_r_g_u_m_e_n_t_s:

       n: number of levels of factor, character vector, or discrete
          values

       q: probability of reclassifying to same sate 

_D_e_t_a_i_l_s:

     For reclass.mat.diag, the transition probability of changing from
     level i to level j is q if i==j, 0 if abs(i-j)>1 and q, 1-q/2 if
     abs(i-j)>1 and 1>i>n and 1-q otherwise

     For reclass.mat.random, the transition probability of changing
     from level i to level j is q if i==j,  (1-q)/(n-1) otherwise.

_V_a_l_u_e:

     returns a matrix of cumulative probability distributions for
     reclassifying each level to another level

_A_u_t_h_o_r(_s):

     Micah Altman Micah_Altman@harvard.edu <URL:
     http://www.hmdc.harvard.edu/micah_altman/>

_R_e_f_e_r_e_n_c_e_s:

     Altman, M., J. Gill and M. P. McDonald.  2003.  _Numerical Issues
     in Statistical Computing for the Social Scientist_.  John Wiley &
     Sons. <URL: http://www.hmdc.harvard.edu/numerical_issues/>

_S_e_e _A_l_s_o:

     'perturb', 'reclass.mat.random'

_E_x_a_m_p_l_e_s:

       
             x<-ceiling(runif(1:100)*3)              # vector taking on 3 discrete levels
             rx <-reclass.mat.random(3,.95)  # reclassification matrix, prob of change  = .05
             rpx<-replicate(10,PTBdiscrete(x,rx),simplify=FALSE) # 100 perturbations
             if (is.R()) {
          matches <-sapply(rpx,function(y)(sum(y==x)))       # how many matches to original vector
       } else {
          # Splus variation
          matches <-sapply(rpx,substitute(function(y)(sum(y==x))))
       }
             summary(matches)                                # mean should be close to .95

