Confidence interval of 0 observations with Poisson distribution

https://stats.stackexchange.com/questions/427019/confidence-interval-for-mean-of-poisson-with-only-zero-counts

Excellent answer in this link about the confidence interval when only 0 observations are available for a Poisson distribution.

Here is an alternative using Bayesian MCMC with uniform distribution.

This is surprising how close are the estimates !

library(HelpersMG)
u <- NULL

for (l in 1:30) {
  val <- rep(0, l)
  prior <- data.frame(Density="dunif",
                      Prior1=0, Prior2=10,
                      SDProp=1,
                      Min=0, Max=10,
                      Init=0.01, row.names = "lambda")
  mcmc_run <- MHalgoGen(n.iter=100000, parameters=prior, data=val, adaptive = TRUE,
                        likelihood=dpoisx, n.chains=1, n.adapt=10000, thin=10, trace=FALSE)
  u <- c(u, quantile(mcmc_run$resultMCMC$"1"[, "lambda"], probs=0.95))
}

plot_errbar(1:30, rep(0, 30), y.minus=rep(0, 30), y.plus = u, las=1, bty="n",
            xlab="Number of observations", ylab="95% confidence interval", ylim=c(0, 3))

points(1:30, qgamma(.95, shape = 1, rate = 1:30), pch="X")
points(1:30, -log(.05)/(1:30), pch="+", col="red")

legend(x = "topright", pch=c("+", "X", "+"), col=c("black", "black", "red"),
       legend = c("Bayesian MCMC", "Bayes theorem", "Frequentist"))



Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04