PTBdefault             package:accuracy             R Documentation

_R_e_t_u_r_n_s _a _d_e_f_a_u_l_t _p_e_r_t_u_r_b_a_t_i_o_n _f_u_n_c_t_i_o_n _f_o_r _a _g_i_v_e_n _v_e_c_t_o_r.

_D_e_s_c_r_i_p_t_i_o_n:

     This function returns a function that can be used to  repeatedly
     peturb the vector given to it.

_U_s_a_g_e:

     PTBdefaultfn(vec, q = 0.99)
     PTBdefault(vec, q=0.99)

_A_r_g_u_m_e_n_t_s:

     vec: the vector which will be subject to perturbation

       q: for discrete vectors, the reclassification probability. For
          continuous vectors, perturbations will have  1-q relative
          uniform noise added. 

_D_e_t_a_i_l_s:

     For numeric discrete values, and ordered factors,
     'reclass.mat.diag' will be used to generate the default
     reclassification matrix. For character vectors, unordered factors,
     and logicals, 'relass.mat.random' is used.

_V_a_l_u_e:

     A function that can be used to perturb the vector.

_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', 'PTBdiscrete',  'PTBus',  'reclass.mat.random'

_E_x_a_m_p_l_e_s:

     x=1:100
      # perturb using the default method
     rpx=replicate(100,PTBdefault(x),simplify=FALSE)
     # how many matches to original vector? mean should be close to 95
             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)                                
     # This produces equivalent results, but is faster, 
     # since reclass matrices are not recalculated on each replication   

     fx=PTBdefaultfn(x,q=.95) 
     rpx=replicate(100,fx(x),simplify=FALSE) 
             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)                        

