rMultinom               package:Hmisc               R Documentation

_G_e_n_e_r_a_t_e _M_u_l_t_i_n_o_m_i_a_l _R_a_n_d_o_m _V_a_r_i_a_b_l_e_s _w_i_t_h _V_a_r_y_i_n_g _P_r_o_b_a_b_i_l_i_t_i_e_s

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

     Given a matrix of multinomial probabilities where rows correspond
     to observations and columns to categories (and each row sums to
     1), generates a matrix with the same number of rows as has 'probs'
     and with 'm' columns.  The columns represent multinomial cell
     numbers, and within a row the columns are all samples from the
     same multinomial distribution.  The code is a modification of that
     in the 'impute.polyreg' function in the 'MICE' package.

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

     rMultinom(probs, m)

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

   probs: matrix of probabilities

       m: number of samples for each row of 'probs'

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

     an integer matrix having 'm' columns

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

     'rbinom'

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

     set.seed(1)
     w <- rMultinom(rbind(c(.1,.2,.3,.4),c(.4,.3,.2,.1)),200)
     t(apply(w, 1, table)/200)

