negbinom: Negative binomial regression for count data

Description Usage Arguments Value See Also Examples

Description

Negative binomial (NB) regression for count data; 2 versions. NB(theta,xi) has pmf f(y;theta,xi)= [ Gamma(theta+y) xi^y] / [ Gamma(theta) y! (1+xi)^(theta+y) ]

Usage

1
2
3
4
5
6
7
8
9
nb1nllk(param,y,xdat)
nb2nllk(param,y,xdat)
nbpmfcdf(ub,theta,p)
nb1pmfcdf(ub,param,x)
nb2pmfcdf(ub,param,x)
nb1cdf(y,param,x)
nb2cdf(y,param,x)
nb1pmf(y,param,x)
nb2pmf(y,param,x)

Arguments

param

parameter of NB model, length is 2+number of covariates; the parameters are: b0=intercept, bvec= vector regression coefficients (length(bvec)=length(x)=ncol(xdat), and finally xi or theta. For NB1, mu(x)= exp(b[0]+bvec^T x), xi=(overdispersion index minus one) is fixed, and theta(x)=mu(x)/xi. For NB2, mu(x)= exp(b[0]+bvec^T x), theta=convolution parameter is fixed and xi(x)=mu(x)/theta.

theta

convolution parameter

p

probability parameter between 0 and 1

xdat

matrix for nb1nllk and nb2nllk

x

vector for nb1pmfcdf, nb2pmfcdf, nb1cdf, nb2cdf, nb1pmf, nb2pmf

y

vector for nb1nllk and nb2nllk (with length(y)=nrow(xdat)); non-negative integer for the other functions

ub

upper bound integer for which pmf and cdf are computed

Value

negative log-likelihood for nb1nllk and nb2nllk; matrix with columns (0:ub,pmf,cdf) for nbpmfcdf, nb1pmfcdf and nb2pmfcdf, computed in an efficient way (parameters assumed to be such that most probability is on small counts); cdf for nb1cdf and nb2cdf; pmf for nb1pmf and nb2pmf.

See Also

gpoisson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
y= c(
 2, 1, 1, 0,35, 9, 0, 1, 4, 0, 0, 1, 4, 0, 0, 8, 7, 2, 0, 7, 0, 0, 3, 4, 0,
 4, 1, 3, 0, 6, 1, 0, 2, 8, 0,12, 0, 4, 2, 1, 3, 0, 9, 0, 0, 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, 8,10,10,
 4, 7, 2, 8, 9, 0, 0, 5, 8, 3, 7, 6,10, 4, 5, 7, 6, 7, 3, 4,10, 4, 8, 8, 3,
 9, 5,10, 9, 5,10,10, 8,10, 5,10, 6, 5, 9, 8,10, 7, 8, 9, 7, 8, 4, 8, 3, 5,
 5, 7,10, 8, 1, 3, 3, 8,10, 3, 5, 5, 7, 5,10, 8, 5, 8, 5, 0, 6, 8, 2, 5, 6,
 7,10, 5, 0, 5, 2, 0, 3,10, 7, 4, 6, 9, 2, 8, 5, 9, 7, 5,10, 8, 8, 7, 7, 7,
10,10, 2, 5, 7, 5, 9, 6, 7, 6, 9, 9, 6, 8,10, 7, 8, 8,10,10, 5,10, 5, 8,10,
 8, 7,10, 9,10, 4, 6, 9, 5, 9, 9, 6, 8, 8, 2, 5, 8, 3, 7, 0, 8, 8,10, 5, 7,
 6, 7,10, 5, 5, 1, 5, 6, 4,10, 5, 5, 5, 7, 2, 8, 5,10,10,10,10, 6, 6, 6, 6,
 7, 8, 8,10,10, 8, 7, 8, 3, 8, 8, 8, 6, 3, 7,10,10, 2, 9, 2)
fit1=nlm(ieenllk,p=c(2.5,-.2,4),hessian=TRUE,print.level=1,upmf=nb1pmf,
    xdat=hsat,ydat=y,LB=c(-1,-2,0),UB=c(10,10,10))
fit2=nlm(ieenllk,p=c(2.5,-.2,0.8),hessian=TRUE,print.level=1,upmf=nb2pmf,
    xdat=hsat,ydat=y,LB=c(-1,-2,0),UB=c(10,10,10))

YafeiXu/CopulaModel documentation built on May 9, 2019, 11:07 p.m.