Zinegbin                package:VGAM                R Documentation

_Z_e_r_o-_I_n_f_l_a_t_e_d _N_e_g_a_t_i_v_e _B_i_n_o_m_i_a_l _D_i_s_t_r_i_b_u_t_i_o_n

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

     Density, distribution function, quantile function and random
     generation for the zero-inflated negative binomial distribution
     with parameter 'phi'.

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

     dzinegbin(x, phi, size, prob=NULL, munb=NULL, log=FALSE)
     pzinegbin(q, phi, size, prob=NULL, munb=NULL)
     qzinegbin(p, phi, size, prob=NULL, munb=NULL)
     rzinegbin(n, phi, size, prob=NULL, munb=NULL)

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

    x, q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations. Must be a single positive integer. 

size, prob, munb, log: Arguments matching 'dnbinom'. The argument
          'munb' corresponds to 'mu' in 'dnbinom' and has been renamed
          to emphasize the fact that it is the mean of the negative
          binomial _component_.

     phi: Probability of zero (ignoring the negative binomial
          distribution), called phi.

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

     The probability function of Y is 0 with probability phi, and a
     negative binomial distribution with probability 1-phi. Thus 

                   P(Y=0) = phi + (1-phi) * P(W=0)

     where W is distributed as a negative binomial distribution (see
     'rnbinom'.) See 'negbinomial', a 'VGAM' family function, for the
     formula of the probability density function and other details of
     the negative binomial distribution.

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

     'dzinegbin' gives the density, 'pzinegbin' gives the distribution
     function, 'qzinegbin' gives the quantile function, and 'rzinegbin'
     generates random deviates.

_N_o_t_e:

     The argument 'phi' is recycled to the required length, and must
     have values which lie in the interval [0,1].

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

     Thomas W. Yee

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

     'zinegbinomial', 'rnbinom', 'rzipois'.

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

     munb = 3; phi = 0.2; size = k = 10
     x = 0:10
     (i = dzinegbin(x, phi=phi, mu=munb, size=k))
     max(abs(cumsum(i) - pzinegbin(x, phi=phi, mu=munb, size=k))) # Should be 0
     table(rzinegbin(100, phi=phi, mu=munb, size=k))

     table(qzinegbin(runif(1000), phi=phi, mu=munb, size=k))
     round(dzinegbin(x, phi=phi, mu=munb, size=k) * 1000) # Should be similar

     ## Not run: 
     barplot(rbind(dzinegbin(x, phi=phi, mu=munb, size=k),
                   dnbinom(x, mu=munb, size=k)),
             beside = TRUE, col = c("blue","green"),
             main=paste("ZINB(mu=", munb, ", k=", k, ", phi=", phi,
                        ") (blue) vs negative binomial(mu=", munb,
                        ", size=", k, ") (green)", sep=""),
             names.arg = as.character(x))
     ## End(Not run)

