Title: | Prediction Limits for Poisson Distribution |
---|---|
Description: | Prediction limits for the Poisson distribution are produced from both frequentist and Bayesian viewpoints. Limiting results are provided in a Bayesian setting with uniform, Jeffreys and gamma as prior distributions. More details on the methodology are discussed in Bejleri and Nandram (2018) <doi:10.1080/03610926.2017.1373814> and Bejleri, Sartore and Nandram (2021) <doi:10.1007/s42952-021-00157-x>. |
Authors: | Valbona Bejleri [aut] , Luca Sartore [aut, cre] , Balgobin Nandram [aut] |
Maintainer: | Luca Sartore <[email protected]> |
License: | GPL-3 |
Version: | 0.3.1 |
Built: | 2024-11-03 05:35:44 UTC |
Source: | https://github.com/cran/plpoisson |
Prediction limits for Poisson distribution are useful when quantifying the uncertainty associated with predicting the occurrences of real life phenomena. The plpoisson package provides a set of functions to compute prediction limits of the inferred Poisson distribution under both, frequentist and Bayesian frameworks.
For frequentist prediction a common approach is to estimate the parameter based on the observed data firstly, then, to predict based on the estimated parameter. Different from the common approach of frequentist prediction, this approach does not require the estimation of the parameter. In a Bayesian setting, the uniform, Jeffreys and gamma distributions are used as priors when deriving the predictive posterior distribution.
Package: | plpoisson |
Type: | Package |
Version: | 0.3.1 |
Date: | 2024-09-29 |
License: | GPL-3 |
For a complete list of exported functions, use library(help = "plpoisson")
.
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Maintainer: Luca Sartore [email protected]
Bejleri, V., & Nandram, B. (2018). Bayesian and frequentist prediction limits for the Poisson distribution. Communications in Statistics-Theory and Methods, 47(17), 4254-4271.
Bejleri, V., Sartore, L. & Nandram, B. (2021). Asymptotic equivalence between frequentist and Bayesian prediction limits for the Poisson distribution. Journal of the Korean Statistical Society doi:10.1007/s42952-021-00157-x
Bejleri, V. (2005). Bayesian Prediction Intervals for the Poisson Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
## Loading the package library(plpoisson) ## Setting quantities of interest xobs <- rpois(1, 50) # Number of the observed occurrencies n <- 1 # Total number of the time windows of # of size 's' observed in the past s <- rgamma(1, 4, .567) # Fixed size of observed time windows t <- rgamma(1, 3, .33) # Future time window a <- 5 # Shape hyperparameter of a gamma prior b <- 1.558 # Rate hyperparameter of a gamma prior ## Frequentist prediction limits poiss(xobs, n, s, t) ## Bayesian prediction limits (with uniform prior) poisUNIF(xobs, n, s, t) ## Bayesian prediction limits (with Jeffreys prior) poisJEFF(xobs, n, s, t) ## Bayesian prediction limits (with gamma prior) poisBayes(xobs, n, s, t, a, b)
## Loading the package library(plpoisson) ## Setting quantities of interest xobs <- rpois(1, 50) # Number of the observed occurrencies n <- 1 # Total number of the time windows of # of size 's' observed in the past s <- rgamma(1, 4, .567) # Fixed size of observed time windows t <- rgamma(1, 3, .33) # Future time window a <- 5 # Shape hyperparameter of a gamma prior b <- 1.558 # Rate hyperparameter of a gamma prior ## Frequentist prediction limits poiss(xobs, n, s, t) ## Bayesian prediction limits (with uniform prior) poisUNIF(xobs, n, s, t) ## Bayesian prediction limits (with Jeffreys prior) poisJEFF(xobs, n, s, t) ## Bayesian prediction limits (with gamma prior) poisBayes(xobs, n, s, t, a, b)
The function provides three bootstrap implementations to estimate the hyperparameters of a gamma prior distribution. The method of moments, maximum likelihood and chi-square approximation are implemented for studying the uncertainties associated with the choice of the hyperparameters (shape) and
(rate).
hyperbootstrap(xvec, B = 1000L, method = c("moments", "likelihood", "chisq"))
hyperbootstrap(xvec, B = 1000L, method = c("moments", "likelihood", "chisq"))
xvec |
a numeric vector of data with the observed occurrencies (assumed to be Poisson distributed). |
B |
a numeric value representing the total number of bootstrap iterations. |
method |
a character string (or strings) with the name/s of the method/s chosen to obtain hyperparameter estiamtes. |
The function performs a choosen number of iterations using either the method of momemnts (method = "moments"
), the maximum likelihood (method = "likelihood"
), or the chi-square approximation (method = "chisq"
).
A list containing the following components:
a |
A matrix of values for the shape hyperparameter of the gamma distribution. The results of each method are organized by column. |
b |
A matrix of values for the rate hyperparameter of the gamma distribution. The results of each method are organized by column. |
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Bejleri, V., Sartore, L. & Nandram, B. (2021). Asymptotic equivalence between frequentist and Bayesian prediction limits for the Poisson distribution. Journal of the Korean Statistical Society doi:10.1007/s42952-021-00157-x
Bejleri, V. (2005). Bayesian Prediction Intervals for the hyperbootstrapon Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
# Loading the package library(plpoisson) set.seed(2021L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Compute bootstrap estimates using all methods hyperbootstrap(data$occ_obs, 10L) # only 10 iterations
# Loading the package library(plpoisson) set.seed(2021L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Compute bootstrap estimates using all methods hyperbootstrap(data$occ_obs, 10L) # only 10 iterations
The function provides the Bayesian prediction limits of a Poisson random variable derived based on a gamma prior. The resulting prediction bounds quantify the uncertainty associated with the predicted future number of occurences in a time window of size .
poisBayes(xobs, n, s, t, a, b, alpha = 0.05)
poisBayes(xobs, n, s, t, a, b, alpha = 0.05)
xobs |
a numeric value denoting the number of the observed occurrencies. |
n |
a numeric value representing the total number of the time windows |
s |
a numeric value corresponding to the fixed size (or average size) of the observed time windows. |
t |
a numeric value indicating the size of the future time window. |
a |
a poisitive real number denoting the shape hyperparameter of a gamma prior distribution. |
b |
a poisitive real number representing the rate hyperparameter of a gamma prior distribution. |
alpha |
a numeric value associated to the credible probability. By default |
When the argument b = Inf
, one can obtain prediction limits with uniform prior by setting the argument a = 1
. Similarly, one can get the limits with a Jeffreys prior by setting the argument a = 0
.
A list containing the following components:
lower |
An integer value representing the lower bound of the prediction limit. |
upper |
An integer value representing the upper bound of the prediction limit. |
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Bejleri, V., & Nandram, B. (2018). Bayesian and frequentist prediction limits for the Poisson distribution. Communications in Statistics-Theory and Methods, 47(17), 4254-4271.
Bejleri, V. (2005). Bayesian Prediction Intervals for the Poisson Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with gamma prior) poisBayes(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 333, # Size of future window 2, 2.22) # Hyper-parameters for gamma prior
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with gamma prior) poisBayes(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 333, # Size of future window 2, 2.22) # Hyper-parameters for gamma prior
The function provides the Bayesian prediction limits of a Poisson random variable derived based on a Jeffreys prior. The resulting prediction bounds quantify the uncertainty associated to the predicted future number of occurences in a time windows of size .
poisJEFF(xobs, n, s, t, alpha = 0.05)
poisJEFF(xobs, n, s, t, alpha = 0.05)
xobs |
a numeric value denoting the number of the observed occurrencies. |
n |
a numeric value representing the total number of the time windows |
s |
a numeric value corresponding to the fixed size (or average size) of the observed time windows. |
t |
a numeric value indicating the size of the future time window. |
alpha |
a numeric value associated to the credible probability. By default |
The resulting limits are equivalent to those provided when running the function poisBayes()
with arguments a = 0
and b = Inf
.
A list containing the following components:
lower |
An integer value representing the lower bound of the prediction limit. |
upper |
An integer value representing the upper bound of the prediction limit. |
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Bejleri, V., & Nandram, B. (2018). Bayesian and frequentist prediction limits for the Poisson distribution. Communications in Statistics-Theory and Methods, 47(17), 4254-4271.
Bejleri, V. (2005). Bayesian Prediction Intervals for the Poisson Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with Jeffreys prior) poisJEFF(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 444) # Size of future window
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with Jeffreys prior) poisJEFF(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 444) # Size of future window
The function provides the frequentist prediction limits of a Poisson random variable. The resulting prediction bounds quantify the uncertainty associated to the predicted future number of occurences in a time windows of size .
poiss(xobs, n, s, t, alpha = 0.05)
poiss(xobs, n, s, t, alpha = 0.05)
xobs |
a numeric value denoting the number of the observed occurrencies. |
n |
a numeric value representing the total number of the time windows |
s |
a numeric value corresponding to the fixed size (or average size) of the observed time windows. |
t |
a numeric value indicating the size of the future time window. |
alpha |
a numeric value associated to the probability of prediction. By default |
Prediction bounds are obtained through the binary search algorithm.
A list containing the following components:
lower |
An integer value representing the lower bound of the prediction limit. |
upper |
An integer value representing the upper bound of the prediction limit. |
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Bejleri, V., & Nandram, B. (2018). Bayesian and frequentist prediction limits for the Poisson distribution. Communications in Statistics-Theory and Methods, 47(17), 4254-4271.
Bejleri, V. (2005). Bayesian Prediction Intervals for the Poisson Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
Davis, C. H. (1969). The binary search algorithm. American Documentation (pre-1986), 20(2), 167.
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Frequentist prediction limits poiss(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 3) # Size of future window
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Frequentist prediction limits poiss(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 3) # Size of future window
The function provides the Bayesian prediction limits of a Poisson random variable derived based on a uniform prior. The resulting prediction bounds quantify the uncertainty associated to the predicted future number of occurences in a time windows of size .
poisUNIF(xobs, n, s, t, alpha = 0.05)
poisUNIF(xobs, n, s, t, alpha = 0.05)
xobs |
a numeric value denoting the number of the observed occurrencies. |
n |
a numeric value representing the total number of the time windows |
s |
a numeric value corresponding to the fixed size (or average size) of the observed time windows. |
t |
a numeric value indicating the size of the future time window. |
alpha |
a numeric value associated to the credible probability. By default |
The resulting limits are equivalent to those provided when running the function poisBayes()
with arguments a = 1
and b = Inf
.
A list containing the following components:
lower |
An integer value representing the lower bound of the prediction limit. |
upper |
An integer value representing the upper bound of the prediction limit. |
Valbona Bejleri, Luca Sartore and Balgobin Nandram
Bejleri, V., & Nandram, B. (2018). Bayesian and frequentist prediction limits for the Poisson distribution. Communications in Statistics-Theory and Methods, 47(17), 4254-4271.
Bejleri, V. (2005). Bayesian Prediction Intervals for the Poisson Model, Noninformative Priors, Ph.D. Dissertation, American University, Washington, DC.
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with uniform prior) poisUNIF(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 444) # Size of future window
# Loading the package library(plpoisson) set.seed(2020L) # Number of observed time windows n <- 555L # Simulating a dataset data <- cbind.data.frame( occ_obs = rpois(n, rgamma(n, 5.5, .5)), win_siz = rgamma(n, 1.44, .777) ) ## Bayesian prediction limits ## (with uniform prior) poisUNIF(sum(data$occ_obs), # Past occurrencies nrow(data), # Total past time windows mean(data$win_siz), # Window size 444) # Size of future window