sampfle              package:sampfling              R Documentation

_R_a_n_d_o_m _S_a_m_p_l_i_n_g: _t_h_e _S_a_m_p_f_o_r_d _A_l_g_o_r_i_t_h_m

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

     'sampfle' implements the Sampford algorithm to obtain a sample
     without replacement and with unequal probabilities.  The
     probability of the sample is known a priori.

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

      sampfle(x, size, prob = NULL)

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

       x: Either a (numeric, complex, character or logical) vector of
          more than one element from which to choose, or a positive
          integer.

    size: A positive integer giving the number of items to choose.

    prob: A vector of weights for obtaining the elements of the vector
          being sampled.

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

     If 'x' has length 1, sampling takes place from '1:x'.

     The 'prob' argument gives a vector of weights for obtaining the
     elements of the vector being sampled.  They need not sum to one,
     but they should be nonnegative and, after normalizing, less than
     '1/size'.  The number of nonzero weights must be at least 'size'.

     The Sampford algorithm draws the first unit 'i' with probability
     proportional to 'prob', and subsequent units with probabilities
     proportional to 'prob/(1-size*prob[i])' with replacement.  As soon
     as a unit is repeated, the entire sample is rejected and the
     process is restarted.  Thus a sample without replacement is
     obtained.

     The algorithm produces a sample s, subset of 'x' of size n, with
     probability proportional to

            Pr[s]propto (1-sum z_i)prodfrac{z_i}{1-n z_i}

     {(1 - Sum z[i]) Prod(z[i]/(1-n*z[i]))} where z[i] is the i-th
     element of 'prob', that is, 'prob[i]'; and both the sum and the
     product extend over the drawn units, i in s.

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

     A vector, which contains the sampled units from 'x', or indices if
     'x' is an integer.

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

     Carlos Enrique Carleos Artime carleos@vodafone.es.

_R_e_f_e_r_e_n_c_e_s:

     Cochran, W.G. (1977) _Sampling techniques_, John Wiley and Sons.

     Sampford, M.R. (1967) On sampling without replacement with unequal
     probabilities of selection, _Biometrika_ 54:499-513.

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

     'samprop'

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

     library(sampfling)
     sampfle(10, 3, 1:10)
     sampfle(c("a","b","c"), 2, c(0.3,0.3,0.4))

