Zapois                 package:VGAM                 R Documentation

_Z_e_r_o-_A_l_t_e_r_e_d _P_o_i_s_s_o_n _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-altered Poisson distribution with
     parameter 'p0'.

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

     dzapois(x, lambda, p0 = 0, log = FALSE)
     pzapois(q, lambda, p0 = 0)
     qzapois(p, lambda, p0 = 0)
     rzapois(n, lambda, p0 = 0)

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

    x, q: vector of quantiles.

       p: vector of probabilities.

       n: number of observations. If 'length(n) > 1' then the length is
          taken to be the number required. 

  lambda: Vector of positive means. 

      p0: Probability of zero, called p0. The default value of 'p0=0'
          corresponds to the response having a positive Poisson
          distribution.

     log: Logical. Return the logarithm of the answer? 

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

     The probability function of Y is 0 with probability 'p0', else a
     positive Poisson(lambda).

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

     'dzapois' gives the density, 'pzapois' gives the distribution
     function, 'qzapois' gives the quantile function, and 'rzapois'
     generates random deviates.

_N_o_t_e:

     The argument 'p0' 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:

     'zapoisson'.

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

     lambda = 3
     p0 = 0.2
     x = (-1):7
     (i = dzapois(x, lambda, p0))
     max(abs(cumsum(i) - pzapois(x, lambda, p0)))  # Should be 0
     table(rzapois(100, lambda, p0))

     table(qzapois(runif(100), lambda, p0))
     round(dzapois(0:10, lambda, p0) * 100) # Should be similar

     ## Not run: 
     x = 0:10
     barplot(rbind(dzapois(x, lambda, p0), dpois(x, lambda)),
             beside = TRUE, col = c("blue","green"),
             main=paste("ZAP(", lambda, ", p0=", p0, ") (blue) vs",
                             " Poisson(", lambda, ") (green)", sep=""),
             names.arg = as.character(x))
     ## End(Not run)

