Title: | Thomson Sampling for Zero-Inflated Count Outcomes |
Version: | 0.1.0 |
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) <doi:10.48550/arXiv.2311.14359>. |
Maintainer: | Tanujit Chakraborty <tanujitisi@gmail.com> |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Imports: | MASS, parallel, fastDummies, matrixStats, ggplot2, stats |
NeedsCompilation: | no |
Packaged: | 2023-11-29 04:15:35 UTC; mad-s |
Author: | Xueqing Liu [aut],
Nina Deliu [aut],
Tanujit Chakraborty
|
Repository: | CRAN |
Date/Publication: | 2023-11-29 14:00:10 UTC |
Apply the algorithms to make decisions for Thompson sampling Zero-inflated Negative Binomial (TS-ZINB) algorithm
Description
Apply the algorithms to make decisions for Thompson sampling Zero-inflated Negative Binomial (TS-ZINB) algorithm
Usage
apply_ZINB(context, beta_ZINB, gamma_ZINB)
Arguments
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 |
Value
Intervention option
Examples
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
Description
Apply the algorithms to make decisions for Thompson sampling Zero-inflated Poisson (TS-ZIP) algorithm
Usage
apply_ZIP(context, beta_ZIP, gamma_ZIP)
Arguments
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 |
Value
Intervention option
Examples
apply_ZIP(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5),matrix(21:30, nrow = 5))
Apply the algorithms to make decisions for Thompson sampling Poisson (TS-Poisson) algorithms
Description
Apply the algorithms to make decisions for Thompson sampling Poisson (TS-Poisson) algorithms
Usage
apply_laplacePoisson(context, beta_laplacePoisson)
Arguments
context |
context at the current decision time |
beta_laplacePoisson |
the randomly sampled Bayesian estimate |
Value
Intervention option
Examples
apply_laplacePoisson(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
Apply the algorithms to make decisions for Linear Thompson sampling (TS) algorithms
Description
Apply the algorithms to make decisions for Linear Thompson sampling (TS) algorithms
Usage
apply_linearTS(context, beta_linearTS)
Arguments
context |
context at the current decision time |
beta_linearTS |
the randomly sampled Bayesian estimate |
Value
Intervention option
Examples
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
Description
Apply the algorithms to make decisions for Thompson sampling Negative Binomial (TS-NB) algorithms
Usage
apply_normalNB(context, beta_normalNB)
Arguments
context |
context at the current decision time |
beta_normalNB |
the randomly sampled Bayesian estimate |
Value
Intervention option
Examples
apply_normalNB(matrix(1:10, nrow = 2),matrix(11:20, nrow = 5))
Summarize the simulation results and generate the regret plot
Description
Summarize the simulation results and generate the regret plot
Usage
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
)
Arguments
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. |
Value
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).
References
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
Examples
output_summary(S = 2, num_cov = 2, T.init = 3, T0 = 5, dist_env = "Negative Binomial")
Updating parameters in algorithm
Description
Updating parameters in algorithm
Usage
update_algorithm(
dist = c("Negative Binomial", "Poisson", "Linear TS", "ZIP", "ZINB"),
Y_dist = 2,
X_dist = 3,
alpha_dist = 4,
Bt = NULL,
bt = NULL
)
Arguments
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 |
Value
The updated parameter estimates.
Examples
update_algorithm(dist = "Negative Binomial")