posnegbinomial             package:VGAM             R Documentation

_P_o_s_i_t_i_v_e _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 _F_a_m_i_l_y _F_u_n_c_t_i_o_n

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

     Maximum likelihood estimation of the two parameters of a positive
     negative binomial distribution.

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

     posnegbinomial(lmunb = "loge", lk = "loge", ik = NULL,
                    zero = -2, cutoff = 0.995, method.init=1)

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

   lmunb: Link function applied to the 'munb' parameter, which is the
          mean munb of an ordinary negative binomial distribution. See
          'Links' for more choices.

      lk: Parameter link function applied to the dispersion parameter,
          called 'k'. See 'Links' for more choices.

      ik: Optional initial value for 'k', an index parameter. The value
          '1/k' is known as a dispersion parameter. If failure to
          converge occurs try different values (and/or use
          'method.init'). If necessary this vector is recycled to
          length equal to the number of responses.  A value 'NULL'
          means an initial value for each response is computed
          internally using a range of values.

    zero: Integer valued vector, usually assigned -2 or 2 if used at
          all.  Specifies which of the two linear/additive predictors
          are modelled as an intercept only. By default, the 'k'
          parameter (after 'lk' is applied) is modelled as a single
          unknown number that is estimated.  It can be modelled as a
          function of the explanatory variables by setting 'zero=NULL'.
           A negative value means that the value is recycled, so
          setting -2 means all 'k' are intercept only.

  cutoff: A numeric which is close to 1 but never exactly 1.  Used to
          specify how many terms of the infinite series are actually
          used. The sum of the probabilites are added until they reach
          this value or more.  It is like specifying 'p' in an
          imaginary function 'qnegbin(p)'.

method.init: See 'negbinomial'.

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

     The positive negative binomial distribution is an ordinary
     negative binomial distribution but with the probability of a zero
     response being zero. The other probabilities are scaled to sum to
     unity.

     This family function is based on 'negbinomial' and most details
     can be found there. To avoid confusion, the parameter 'munb' here
     corresponds to the mean of an ordinary negative binomial
     distribution 'negbinomial'. The mean of 'posnegbinomial' is

                           munb / (1-p(0))

     where p(0) = (k/(k + munb))^k is the probability an ordinary
     negative binomial distribution has a zero value.

     The parameters 'munb' and 'k' are not independent in the positive
     negative binomial distribution, whereas they are in the ordinary
     negative binomial distribution.

     This function handles _multivariate_ responses, so that a matrix
     can be used as the response. The number of columns is the number
     of species, say, and setting 'zero=-2' means that _all_ species
     have a 'k' equalling a (different) intercept only.

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

     An object of class '"vglmff"' (see 'vglmff-class'). The object is
     used by modelling functions such as 'vglm', 'rrvglm' and 'vgam'.

_W_a_r_n_i_n_g:

     The Poisson model corresponds to 'k' equalling infinity. If the
     data is Poisson or close to Poisson, numerical problems may occur.
     Possibly a loglog link could be added in the future to try help
     handle this problem.

_N_o_t_e:

     This family function can handle a multivariate response.

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

     Thomas W. Yee

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

     Barry, S. C. and Welsh, A. H. (2002) Generalized additive
     modelling and zero inflated count data.  _Ecological Modelling_,
     *157*, 179-188.

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

     'rposnegbin', 'pospoisson', 'negbinomial', 'zanegbinomial',
     'rnbinom'.

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

     ## Not run: 
     x = runif(nn <- 2000)
     y1 = rnbinom(nn, mu=exp(0+2*x), size=exp(1)) # k is size in rnbinom()
     y2 = rnbinom(nn, mu=exp(1+2*x), size=exp(3))
     fit = vglm(cbind(y1,y2) ~ 1, posnegbinomial, subset=(y1>0)&(y2>1),
                trace=TRUE)
     coef(fit, matrix=TRUE)
     dim(fit@y)
     fitted(fit)[1:5,]
     predict(fit)[1:5,]

     # Another artificial data example
     munb = exp(2); k = exp(3); n = 1000
     y = rposnegbin(n, munb=munb, k=k)
     table(y)
     fit = vglm(y ~ 1, posnegbinomial, trace=TRUE)
     coef(fit, matrix=TRUE)
     mean(y)    # Sample mean
     munb / (1 - (k/(k+munb))^k) # Population mean
     fitted(fit)[1:5,]
     predict(fit)[1:5,]
     ## End(Not run)

