rnegbin                 package:MASS                 R Documentation

_S_i_m_u_l_a_t_e _N_e_g_a_t_i_v_e _B_i_n_o_m_i_a_l _V_a_r_i_a_t_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Function to generate random outcomes from a Negative Binomial
     distribution, with mean 'mu' and variance 'mu + mu^2/theta'.

_U_s_a_g_e:

     rnegbin(n, mu = n, theta = stop("'theta' must be specified"))

_A_r_g_u_m_e_n_t_s:

       n: If a scalar, the number of sample values required.  If a
          vector, 'length(n)' is the number required and 'n' is used as
          the mean vector if 'mu' is not specified. 

      mu: The vector of means.  Short vectors are recycled. 

   theta: Vector of values of the 'theta' parameter.  Short vectors are
          recycled. 

_D_e_t_a_i_l_s:

     The function uses the representation of the Negative Binomial
     distribution as a continuous mixture of Poisson distributions with
     Gamma distributed means. Unlike 'rnbinom' the index can be
     arbitrary.

_V_a_l_u_e:

     Vector of random Negative Binomial variate values.

_S_i_d_e _E_f_f_e_c_t_s:

     Changes '.Random.seed' in the usual way.

_E_x_a_m_p_l_e_s:

     # Negative Binomials with means fitted(fm) and theta = 4.5
     fm <- glm.nb(Days ~ ., data = quine)
     dummy <- rnegbin(fitted(fm), theta = 4.5)

