# NOT RUN {
ivec <- c(5, 15, 10); avec <- ivec; size = 10; munb <- 10
max.support <- 20; pobs.a <- 0.35; xvec <- 0:max.support
# GAT-NB-NB mixture
(pmf.a <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
max.support = max.support, pobs.a = pobs.a, alter = avec))
sum(pmf.a) # Should be 1
# }
# NOT RUN {
ind4 <- match(xvec, avec, nomatch = 0) > 0 # xvec %in% avec
plot(xvec[ ind4], pmf.a[ ind4], type = "h", col = "orange", lwd = 1.1,
las = 1, xlim = range(xvec), main = "GAT-NB-NB",
ylim = c(0, max(pmf.a)), xlab = "y", ylab = "Probability") # Spikes
lines(xvec[!ind4], pmf.a[!ind4], type = "h", col = "blue")
# }
# NOT RUN {
# GIT-NB-NB mixture
pstr.i <- 0.15
(pmf.i <- dgaitnbinom.mix(xvec, size.p = size, munb.p = munb,
max.support = max.support, pstr.i = pstr.i, inflate = ivec))
sum(pmf.i) # Should be 1
# }
# NOT RUN {
# Plot the components of pmf.i
plot(xvec, (1 - pstr.i) * dnbinom(xvec, size, mu = munb), type = "h",
col = "blue", las = 1, xlim = range(xvec),
main = "GIT-NB-NB", # The inner distribution
ylim = c(0, max(pmf.i)), xlab = "y", ylab = "Probability")
spikes <- dnbinom(ivec, size, mu = munb) * pstr.i / sum(
dnbinom(ivec, size, mu = munb))
start.pt <- dnbinom(ivec, size, mu = munb) *
(1 - pstr.i) / pnbinom(max.support, size, mu = munb)
segments(ivec, start.pt, # The outer distribution
ivec, start.pt + spikes, col = "orange", lwd = 1.1)
# }
Run the code above in your browser using DataLab