negbinomial.size.RdMaximum likelihood estimation of the mean parameter of a negative binomial distribution with known size parameter.
negbinomial.size(size = Inf, lmu = "loglink", imu = NULL,
iprobs.y = 0.35, imethod = 1,
ishrinkage = 0.95, zero = NULL)Numeric, positive.
Same as argument size of rnbinom.
If the response is a matrix then this is recycled to a matrix of
the same dimension, by row
(matrix with byrow = TRUE).
Same as negbinomial.
Same as negbinomial.
Same as negbinomial.
See CommonVGAMffArguments for information.
This VGAM family function estimates only the mean parameter of
the negative binomial distribution.
See negbinomial for general information.
Setting size = 1 gives what might
be called the NB-G (geometric model;
see Hilbe (2011)).
The default, size = Inf, corresponds to the Poisson distribution.
An object of class "vglmff" (see vglmff-class).
The object is used by modelling functions such as vglm,
rrvglm
and vgam.
Hilbe, J. M. (2011). Negative Binomial Regression, 2nd Edition. Cambridge: Cambridge University Press.
Yee, T. W. (2014). Reduced-rank vector generalized linear models with two linear predictors. Computational Statistics and Data Analysis, 71, 889–902.
If lmu = "nbcanlink" in negbinomial.size() then
the size argument here should be assigned and
these values are recycled.
negbinomial,
nbcanlink (NB-C model),
poissonff,
rnbinom,
simulate.vlm.
# Simulated data with various multiple responses
size1 <- exp(1); size2 <- exp(2); size3 <- exp(0); size4 <- Inf
ndata <- data.frame(x2 = runif(nn <- 1000))
ndata <- transform(ndata, eta1 = -1 - 2 * x2, # eta1 must be negative
size1 = size1)
ndata <- transform(ndata,
mu1 = nbcanlink(eta1, size = size1, inv = TRUE))
ndata <- transform(ndata,
y1 = rnbinom(nn, mu = mu1, size = size1), # NB-C
y2 = rnbinom(nn, mu = exp(2 - x2), size = size2),
y3 = rnbinom(nn, mu = exp(3 + x2), size = size3), # NB-G
y4 = rpois(nn, lambda = exp(1 + x2)))
# Also known as NB-C with size known (Hilbe, 2011)
fit1 <- vglm(y1 ~ x2, negbinomial.size(size = size1, lmu = "nbcanlink"),
data = ndata, trace = TRUE)
#> Iteration 1: loglikelihood = -874.79974
#> Iteration 2: loglikelihood = -855.26026
#> Iteration 3: loglikelihood = -854.61606
#> Iteration 4: loglikelihood = -854.61481
#> Iteration 5: loglikelihood = -854.61481
coef(fit1, matrix = TRUE)
#> nbcanlink(mu, mu(size))
#> (Intercept) -0.9193538
#> x2 -2.4636748
head(fit1@misc$size) # size saved here
#> [,1]
#> [1,] 2.718282
#> [2,] 2.718282
#> [3,] 2.718282
#> [4,] 2.718282
#> [5,] 2.718282
#> [6,] 2.718282
fit2 <- vglm(cbind(y2, y3, y4) ~ x2, data = ndata, trace = TRUE,
negbinomial.size(size = c(size2, size3, size4)))
#> Iteration 1: loglikelihood = -26900.065
#> Iteration 2: loglikelihood = -26883.213
#> Iteration 3: loglikelihood = -26883.206
#> Iteration 4: loglikelihood = -26883.206
coef(fit2, matrix = TRUE)
#> loglink(mu1) loglink(mu2) loglink(mu3)
#> (Intercept) 1.9463765 2.939767 0.9788344
#> x2 -0.9423637 1.092961 1.0364142
head(fit2@misc$size) # size saved here
#> [,1] [,2] [,3]
#> [1,] 7.389056 1 Inf
#> [2,] 7.389056 1 Inf
#> [3,] 7.389056 1 Inf
#> [4,] 7.389056 1 Inf
#> [5,] 7.389056 1 Inf
#> [6,] 7.389056 1 Inf