x = runif(nn <- 2000)
y1 = rposnegbin(nn, munb=exp(0+2*x), size=exp(1))
y2 = rposnegbin(nn, munb=exp(1+2*x), size=exp(3))
fit = vglm(cbind(y1,y2) ~ x, posnegbinomial, trace=TRUE)
coef(fit, matrix=TRUE)
dim(fit@y)
# Another artificial data example
munb = exp(2); size = k = exp(3); nn = 1000
y = rposnegbin(nn, munb=munb, size=size)
table(y)
fit = vglm(y ~ 1, posnegbinomial, trace=TRUE)
coef(fit, matrix=TRUE)
mean(y) # Sample mean
munb / (1 - (size/(size+munb))^size) # Population mean
fitted(fit)[1:3,]
predict(fit)[1:3,]
Run the code above in your browser using DataLab