# NOT RUN {
ivec <- c(15, 10, 5); avec <- ivec; lambda <- 10
max.support <- 20; pobs.a <- 0.35; xvec <- 0:max.support
(pmf.a <- dgaitpois.mix(xvec, lambda, # lambda.a = lambda,
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-Poisson-Poisson",
ylim = c(0, max(pmf.a)), xlab = "y", ylab = "Probability") # Spikes
lines(xvec[!ind4], pmf.a[!ind4], type = "h", col = "blue")
# }
# NOT RUN {
# GIT-Poisson-Poisson mixture
pstr.i <- 0.20
(pmf.i <- dgaitpois.mix(xvec, lambda, # lambda.a = lambda,
max.support = max.support, pstr.i = pstr.i, inflate = ivec))
sum(pmf.i) # Should be 1
# }
# NOT RUN {
# Plot the components of pmf.i
spikes <- dpois(ivec, lambda) * pstr.i / sum(dpois(ivec, lambda))
start.pt <- dpois(ivec, lambda) * (1 - pstr.i) / ppois(max.support, lambda)
plot(xvec, (1 - pstr.i) * dpois(xvec, lambda), type = "h",
col = "blue", las = 1, xlim = range(xvec),
main = "GIT-Poisson-Poisson", # The inner distribution
ylim = c(0, max(pmf.i)), xlab = "y", ylab = "Probability")
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