# Example 1: apple tree data
appletree = data.frame(y = 0:7, w = c(70, 38, 17, 10, 9, 3, 2, 1))
fit = vglm(y ~ 1, negbinomial, appletree, weights = w)
summary(fit)
coef(fit, matrix = TRUE)
Coef(fit)
# Example 2: simulated data with multivariate response
ndata = data.frame(x = runif(nn <- 500))
ndata = transform(ndata, y1 = rnbinom(nn, mu=exp(3+x), size = exp(1)),
y2 = rnbinom(nn, mu=exp(2-x), size = exp(0)))
fit1 = vglm(cbind(y1,y2) ~ x, negbinomial, ndata, trace = TRUE)
coef(fit1, matrix = TRUE)
# Example 3: large counts so definitely use the nsimEIM argument
ndata = transform(ndata, y3 = rnbinom(nn, mu=exp(12+x), size = exp(1)))
with(ndata, range(y3)) # Large counts
fit2 = vglm(y3 ~ x, negbinomial(nsimEIM=100), ndata, trace = TRUE)
coef(fit2, matrix = TRUE)
Run the code above in your browser using DataLab