Density and cdf of the univariate marginal distribution.
dmargmodel(y,mu,gam,invgam,margmodel)
pmargmodel(y,mu,gam,invgam,margmodel)
dmargmodel.ord(y,mu,gam,link)
pmargmodel.ord(y,mu,gam,link)
Vector of (non-negative integer) quantiles.
The parameter \(\mu\) of the univariate distribution.
The parameter(s) \(\gamma\) that are not regression parameters. \(\gamma\) is NULL for Poisson and Bernoulli distribution.
The inverse of parameter \(\gamma\) of negative binomial distribution.
Indicates the marginal model. Choices are “poisson” for Poisson, “bernoulli” for Bernoulli, and “nb1” , “nb2” for the NB1 and NB2 parametrization of negative binomial in Cameron and Trivedi (1998). See details.
The link function. Choices are “logit” for the logit link function, and “probit” for the probit link function.
The density and cdf of the univariate distribution.
Negative binomial distribution NB\((\tau,\xi)\) allows for overdispersion and its probability mass function (pmf) is given by $$ f(y;\tau,\xi)=\frac{\Gamma(\tau+y)}{\Gamma(\tau)\; y!} \frac{\xi^y}{(1+\xi)^{\tau + y}},\quad \begin{matrix} y=0,1,2,\ldots, \\ \tau>0,\; \xi>0,\end{matrix} $$ with mean \(\mu=\tau\,\xi=\exp(\beta^T x)\) and variance \(\tau\,\xi\,(1+\xi)\).
Cameron and Trivedi (1998) present the NBk parametrization where \(\tau=\mu^{2-k}\gamma^{-1}\) and \(\xi=\mu^{k-1}\gamma\), \(1\le k\le 2\). In this function we use the NB1 parametrization \((\tau=\mu\gamma^{-1},\; \xi=\gamma)\), and the NB2 parametrization \((\tau=\gamma^{-1},\; \xi=\mu\gamma)\); the latter is the same as in Lawless (1987).
margmodel.ord
is a variant of the code for ordinal (probit and logistic) model. In this case, the response \(Y\) is assumed to have density
$$f_1(y;\nu,\gamma)=F(\alpha_{y}+\nu)-F(\alpha_{y-1}+\nu),$$
where \(\nu=x\beta\) is a function of \(x\)
and the \(p\)-dimensional regression vector \(\beta\), and \(\gamma=(\alpha_1,\ldots,\alpha_{K-1})\) is the $q$-dimensional vector of the univariate cutpoints (\(q=K-1\)). Note that \(F\) normal leads to the probit model and \(F\) logistic
leads to the cumulative logit model for ordinal response.
Cameron, A. C. and Trivedi, P. K. (1998) Regression Analysis of Count Data. Cambridge: Cambridge University Press.
Lawless, J. F. (1987) Negative binomial and mixed Poisson regression. The Canadian Journal of Statistics, 15, 209--225.
# NOT RUN {
y<-3
gam<-2.5
invgam<-1/2.5
mu<-0.5
margmodel<-"nb2"
dmargmodel(y,mu,gam,invgam,margmodel)
pmargmodel(y,mu,gam,invgam,margmodel)
link="probit"
dmargmodel.ord(y,mu,gam,link)
pmargmodel.ord(y,mu,gam,link)
# }
Run the code above in your browser using DataLab