Title: | Thomson Sampling for Zero-Inflated Count Outcomes |
---|---|
Description: | A specialized tool is designed for assessing contextual bandit algorithms, particularly those aimed at handling overdispersed and zero-inflated count data. It offers a simulated testing environment that includes various models like Poisson, Overdispersed Poisson, Zero-inflated Poisson, and Zero-inflated Overdispersed Poisson. The package is capable of executing five specific algorithms: Linear Thompson sampling with log transformation on the outcome, Thompson sampling Poisson, Thompson sampling Negative Binomial, Thompson sampling Zero-inflated Poisson, and Thompson sampling Zero-inflated Negative Binomial. Additionally, it can generate regret plots to evaluate the performance of contextual bandit algorithms. This package is based on the algorithms by Liu et al. (2023) <arXiv:2311.14359>. |
Authors: | Xueqing Liu [aut], Nina Deliu [aut], Tanujit Chakraborty [aut, cre, cph] , Lauren Bell [aut], Bibhas Chakraborty [aut] |
Maintainer: | Tanujit Chakraborty <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2024-10-25 06:26:11 UTC |
Source: | CRAN |
Apply the algorithms to make decisions for Thompson sampling Poisson (TS-Poisson) algorithms
apply_laplacePoisson(context, beta_laplacePoisson)
apply_laplacePoisson(context, beta_laplacePoisson)
context |
context at the current decision time |
beta_laplacePoisson |
the randomly sampled Bayesian estimate |
Intervention option
apply_laplacePoisson(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
apply_laplacePoisson(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
Apply the algorithms to make decisions for Linear Thompson sampling (TS) algorithms
apply_linearTS(context, beta_linearTS)
apply_linearTS(context, beta_linearTS)
context |
context at the current decision time |
beta_linearTS |
the randomly sampled Bayesian estimate |
Intervention option
apply_linearTS(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
apply_linearTS(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
Apply the algorithms to make decisions for Thompson sampling Negative Binomial (TS-NB) algorithms
apply_normalNB(context, beta_normalNB)
apply_normalNB(context, beta_normalNB)
context |
context at the current decision time |
beta_normalNB |
the randomly sampled Bayesian estimate |
Intervention option
apply_normalNB(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
apply_normalNB(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
Apply the algorithms to make decisions for Thompson sampling Zero-inflated Negative Binomial (TS-ZINB) algorithm
apply_ZINB(context, beta_ZINB, gamma_ZINB)
apply_ZINB(context, beta_ZINB, gamma_ZINB)
context |
context at the current decision time |
beta_ZINB |
the randomly sampled Bayesian estimate for the Poisson component |
gamma_ZINB |
the randomly sampled Bayesian estimate for the zero component |
Intervention option
apply_ZINB(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5),matrix(21:30, nrow = 5))
apply_ZINB(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5),matrix(21:30, nrow = 5))
Apply the algorithms to make decisions for Thompson sampling Zero-inflated Poisson (TS-ZIP) algorithm
apply_ZIP(context, beta_ZIP, gamma_ZIP)
apply_ZIP(context, beta_ZIP, gamma_ZIP)
context |
context at the current decision time |
beta_ZIP |
the randomly sampled Bayesian estimate for the Poisson component |
gamma_ZIP |
the randomly sampled Bayesian estimate for the zero component |
Intervention option
apply_ZIP(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5),matrix(21:30, nrow = 5))
apply_ZIP(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5),matrix(21:30, nrow = 5))
Summarize the simulation results and generate the regret plot
output_summary( S = 30, num_cov = 4, T.init = 20, T0 = 1000, alpha = 1, gam = 25, K = 20, dist_env = c("Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB"), show_figure = TRUE )
output_summary( S = 30, num_cov = 4, T.init = 20, T0 = 1000, alpha = 1, gam = 25, K = 20, dist_env = c("Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB"), show_figure = TRUE )
S |
number of replicates of the experiment (greater than 1). Default is 30. |
num_cov |
dimension for beta and gamma; we assume that they have the same dimensions for now. Default is 4. |
T.init |
length of the initial exploration stage. Default is 20. |
T0 |
number of decision times. Default is 1000. |
alpha |
tuning parameter that controls the exploration-exploitation tradeoff. Default is 1. |
gam |
over dispersion level of the environment model; this is only useful when the environment model is negative binomial or zero-inflated negative binomial. Default is 25. |
K |
number of actions/intervention options. Default is 20. |
dist_env |
tuning parameter that controls which environment model to use, with the options "Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB" |
show_figure |
A logical flag specifying that the regret plot of the model should be returned if true (default), otherwise, false. |
The summary of the simulation results with cumulative regret, regret, and parameters is generated along with the optional
output of the regret plot (show_figure
= TRUE).
Liu, X., Deliu, N., Chakraborty, T., Bell, L., & Chakraborty, B. (2023). Thompson sampling for zero-inflated count outcomes with an application to the Drink Less mobile health study. arXiv preprint arXiv:2311.14359. https://arxiv.org/abs/2311.14359
output_summary(S = 2, num_cov = 2, T.init = 3, T0 = 5, dist_env = "Negative Binomial")
output_summary(S = 2, num_cov = 2, T.init = 3, T0 = 5, dist_env = "Negative Binomial")
Updating parameters in algorithm
update_algorithm( dist = c("Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB"), Y_dist = 2, X_dist = 3, alpha_dist = 4, Bt = NULL, bt = NULL )
update_algorithm( dist = c("Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB"), Y_dist = 2, X_dist = 3, alpha_dist = 4, Bt = NULL, bt = NULL )
dist |
tuning parameter that controls which algorithm should be updated, with the options "Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB" |
Y_dist |
History of the observed stochastic outcome at the current decision time |
X_dist |
History of the observed context at the current decision time |
alpha_dist |
tuning parameter that controls the exploration-exploitation tradeoff. Default is 1. |
Bt |
Outer product of contexts, only for |
bt |
Sum of contexts weighted by the outcome, only for |
The updated parameter estimates.
update_algorithm(dist = "Negative Binomial")
update_algorithm(dist = "Negative Binomial")