Supplementary materials, data and code of "Using Bayesian test relationship between categorical random variables on small sample sizes: application on the relationship between the weight status of parents and their children in understudied populations living in Pacific Island Countries and Territories"
Description
Data and code shared as supplementary material of Using Bayesian test relationship between categorical random variables on small sample sizes: application on the relationship between the weight status of parents and their children in understudied populations living in Pacific Islands Countries and Territories.
The repository contains:
- the datasets used
- dataset1.csv: a .csv file comma separated "," related to the first case study;
- dataset2.csv: a .csv file comma separated ","related to the second case study;
- the script codes
- BayesianABTest_smallSampleSizes_functions.R: an R script code containing the functions used in the main script;
- BayesianABTest_smallSampleSizes_mainScript.R: an R script allowing to retrieve the main results of the article;
- the supplementary materials
- BayesianABTest_smallSampleSizes_supplementaryMaterials.pdf: contains supplementary Figures S1 to S5 and supplementary Tables S1 to S16.
- BayesianABTest_smallSampleSizes_SupplementaryFigures.zip: contains the supplementary Figures (S1 to S5) in .tiff format.
Table of contents (English)
Datasets
The datasets are stored in comma separated "," .csv files. Each dataset is constituted by two binary (containing 0 and 1) columns:
- parentsWS column whose meaning is "parents' weight status" is coded with "1" if both parents were detected as overweight or obese and "0" if at least one parent was underweight or of normal weight [WHO 2023].
- adolescentWS whose meaning is "adolescent's weight status" is coded with "1" if the adolescent was overweight or obese and "0" if the adolescent was underweight or of normal weight [Cole and Lobstein 2012].
The first rows being headings in the files, the first dataset contains 28 rows representing 27 observations, and the second dataset contains 49 rows representing 48 observations.
Scripts
Description
The BayesianABTest_smallSampleSizes_functions.R file contains the functions used in the main script. They are fully described in the script and are listed hereafter:
- prob.ab: Function to compute the analytical probability of a proportion a greater than another. This function is based on a formula published in Schmidt and Mørup 2019 and was found in the Dr. Hoffman's deposit.
- bayesMCMC_2proportionsIBE: Function using JAGS with the R2jags package to estimate two proportions and their difference with the IBE (Independent beta estimation) approach implemented by the MCMC algorithm.
- priorEstimatesLTT: Function to get the estimates of the prior densities in the LTT (Logit Transformation Testing) approach.
- bayesMCMC_2proportionsLTT: Function that uses JAGS through the R2jags package fitted to estimate two proportions and their difference with the LTT (Logit Transformation Testing) approach implemented with the MCMC algorithm.
- bayesMCMC_SD_post_BF: Function that computes the Bayes factors and the posterior probabilities of the H+ and H0 hypotheses.
- CI2string: Function for convenience, which performs a string conversion from a credible interval (CI).
- simulationIBE: Function implementing rbeta-based sampling (our own simulation) of the IBE approach, based on random samples of beta distributions (dbeta).
- bayesABSummarize: Function used for convenience, which implements the bayesAB function and then summarizes the results into indicators (posterior probabilities, HDI, ETI, Bayes factors, etc.).
- summarize_IBE: Function used for convenience and that puts the indicators from objects implementing the IBE approach into a table.
- mcmcSummarize: Function implementing the bayesMCMC_2proportionsIBE function and then summarizing the results into indicators (posterior probabilities, HDI, ETI, Bayes factors, etc.).
- summarize_prior_LTT: Function that summarizes and puts the quantiles from priorEstimatesLTT function outputs.
- summarize_ab_test: Function that summarizes and puts the indicators from ab_test function outputs.
- summarize_MCMC_LTT: Function that summarizes and puts the indicators from bayesMCMC_2proportionsLTT function outputs.
- summarize_LTT: Function used for convenience that summarizes and puts the indicators from objects implementing the LTT approach. These objects are outputs from the priorEstimatesLTT, ab_test, and bayesMCMC_2proportionsLTT functions.
- summarize_LTT_plus_minus: Function that summarizes and puts the indicators from objects implementing the LTT approach. These objects are outputs from the priorEstimatesLTT, ab_test, and bayesMCMC_2proportionsLTT functions. From the outputs, Bayes factors and post probabilities are computed.
- simulationIBE_alterData_add: Function that simulates alterations in a dataset. The alteration consists in adding a unique observation in each group considered, and doubling the sample size. The results of the IBE approach are in an output list.
- summarizeAlteration_IBE: Function used for convenience to summarize the simulationIBE_alterData_add output into a table.
- simulationLTT_alterData_add: Function that simulates alterations in a dataset. The alteration consists in adding a unique observation in each group considered and doubling the sample size. The results of the LTT approach implemented by the ab_test function are in an output list.
- drawPriorDistributions: Function used to draw Figure 2.
- drawPriorPosteriorDistributions_IBE: Function used to draw Figure 3 and Figure S1.
- drawDeltaDistributions_IBE: Function used to draw Figure 4 and Figure S2.
- dataAggregation4graphLTT: Function dedicated to the aggregation of results from LTT approach and format data for Figure 5 and Figure S3 drawing.
- drawDistributions_LTT: Function used to draw Figure 5 and Figure S3.
- drawDataAlterationDistributions_IBE: Function used to draw Figure 6 and Figure S4.
- dataAggregation4graphDataAlterationLTT: Function dedicated to the aggregation of results from LTT approach with data alteration and formatting data for Figure 7 and Figure S5 drawing.
- drawAlterationDistributions_LTT: Function used to draw Figure 7 and Figure S5.
The BayesianABTest_smallSampleSizes_mainScript.R file contains the main script. The main sections of the script and the parameters that the user may set are described hereafter.
- Packages: List of the packages needed for running the scripts.
- Scripts and data parameters: Parameters that the user has to set. If the user has an evironment similar to the one specified in the next section (How to use the scripts), he/she only needs to set the "mainRepository" variable that represents the the path of the work directory.
- Import the functions: Source the BayesianABTest_smallSampleSizes_functions.R file to import the functions.
- Data sources: Import the datasets into the R environment.
- Parameters: Parameters used for the use of the methods in the different scenarios described in the paper. The IBE parameters sets the parameters for the prior beta distributions. The LTT parameters sets the parameters for the γ and ψ priors.
- Choose your dataset: The user can comment a line according to the dataset of interest.
- First results -> IBE approach applied on the dataset: Runs the IBE approach on the dataset chosen according to the different scenarios considered. The outputs are summed up in a table.
- First results -> LTT approach applied on the dataset: Runs the LTT approach on the dataset chosen according to the different scenarios considered. The outputs are summed up in a table.
- Data alteration -> IBE approach applied on the altered dataset: Runs the IBE approach on several alterations of the dataset according to the different scenarios considered. The outputs are summed up in a table.
- Data alteration -> LTT approach applied on the altered dataset: Runs the LTT approach on several alterations of the dataset according to the different scenarios considered. The outputs are summed up in a table.
How to use the scripts
These scripts were produced and tested with R 4.4.2.
The steps to run the scripts are described hereafter:
- choose a work directory and create the following subfolders: data, scriptsR, tables, graphs.
- copy and paste the R scripts (BayesianABTest_smallSampleSizes_functions.R and BayesianABTest_smallSampleSizes_mainScript.R files) into the scriptsR folder.
- copy and paste the dataset files (dataset1.csv and dataset2.csv) into the tables folder.
- run your R engine.
- install the packages listed in the main script if not yet installed (install.packages command or the with packages manager).
- open the BayesianABTest_smallSampleSizes_mainScript.R file into your favorite text editor or IDE.
- change the settings.
- source the BayesianABTest_smallSampleSizes_mainScript.R file in your R console and enjoy.
Supplementary materials
The supplementary figures and supplementary tables are in the .pdf file entitled BayesianABTest_smallSampleSizes_supplementaryMaterials.pdf.
There are 5 figures from Figure S1 to Figure S5:
- Figure S1. Prior and posterior βeta distributions of the IBE approach applied to Groups 1 (upper row) and 2 (lower row) for the Lifou case study for each scenario investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Figure S2. Distributions of the difference (δ = π2 - π1) simulated in the prior and posterior settings for the Lifou case study by the three implementations (rbeta-based sampling, bayesAB package, and MCMC with R2jags) of the IBE approach for each scenario investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Figure S3. Distributions of the γ, ψ, π1 and π2 parameters and the difference δ = π2 - π1 simulated under the prior and posterior settings for the Lifou case study by the two implementations (ab_test from abtest package, and MCMC with R2jags) of the LTT approach for each scenario investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Figure S4. Posterior βeta distributions of the IBE approach applied to Groups 1 (upper row) and 2 (lower row) for the altered data from the Lifou case study under each scenario investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Figure S5. Posterior distributions of the γ, ψ, π1 and π2 parameters and the difference δ = π2 - π1 simulated for the altered data from the Lifou case study by the abtest implementation of the LTT approach for each scenario investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
There are 16 tables from Table S1 to Table S16:
- Table S1. Indicators of the IBE approach results and related to the distributions of π1, π2 and δ = π2 - π1 estimated by the three implementations (rbeta-based sampling, bayesAB package, and MCMC with R2jags) for the Move Ô case study in the three scenarios investigated: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S2. Indicators of the LTT approach results and related to the distributions of γ, ψ, π1, π2 and δ = π2 - π1 estimated by the two implementations (abtest package, and MCMC with R2jags) for the Move Ô case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the simulated prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S3. Distribution of successes (overweight or obese) and failures (underweight or normal) for each Group (1: parents are not overweight or obese together; 2: both parents are overweight or obese) for the Lifou case study.
- Table S4. Prior and posterior distributions according to the investigated scenario (1. Non-informative, 2. Informative, 3. Optimistic) and the Group in the IBE approach applied on the Lifou case study.
- Table S5. Prior probabilities P(H+), posterior probabilities P(H+ | data) and Bayes factors BF+- estimated by the three implementations (rbeta-based sampling, bayesAB package, and MCMC with R2jags) of the IBE approach for the Lifou case study in the three scenarios investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Table S6. Prior probabilities, posterior probabilities and Bayes factors estimated by the two implementations (abtest package, and MCMC with R2jags) of the LTT approach to compare H+ over H0 and H+ over H- for the Lifou case study in the three scenarios investigated: 1. Non-informative, 2. Informative, 3. Optimistic.
- Table S7. Robustness checking with the plot_robustness function from abtest package for the Lifou case study: ranges of μψ and σψ inputs and Bayes factor BF+0 range.
- Table S8. Indicators of the IBE approach results and related to the distributions of π1, π2 and δ = π2 - π1 estimated by the three implementations (rbeta-based sampling, bayesAB package, and MCMC with R2jags) for the Lifou case study in the three scenarios investigated: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S9. Indicators of the LTT approach results and related to the distributions of γ, ψ, π1, π2 and δ = π2 - π1 estimated by the two implementations (abtest package, and MCMC with R2jags) for the Lifou case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the simulated prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S10. Indicators of the IBE approach results related to the distributions of π1, π2 and δ = π2 - π1 estimated by the implementation of rbeta-based sampling on the altered data from the Move Ô case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S11. Indicators of the LTT approach results related to the distributions of γ, ψ, π1, π2 and δ = π2 - π1 estimated by the abtest package on the altered data from the Move Ô case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S12. Effects of the data alterations on π̂1, π̂2, two-sided and one-sided p values of the Fisher’s exact test for the Lifou case study.
- Table S13. Posterior probabilities P(H+ | data) and Bayes factors BF+- estimated by the implementation of the IBE approach with rbeta-based sampling on the altered data from the Lifou case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic.
- Table S14. Prior probabilities, posterior probabilities and Bayes factors estimated by the implementation of the LTT approach with the abtest package to compare H+ over H0 and H+ over H- on the altered data from the Lifou case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic.
- Table S15. Indicators of the IBE approach results related to the distributions of π1, π2 and δ = π2 - π1 estimated by the implementation rbeta-based sampling on the altered data from the Lifou case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
- Table S16. Indicators of the LTT approach results related to the distributions of γ, ψ, π1, π2 and δ = π2 - π1 estimated by the abtest package on the altered data from the Lifou case study in the three investigated scenarios: 1. Non-informative, 2. Informative, 3. Optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).
Files
BayesianABTest_smallSampleSizes_SupplementaryFigures.zip
Files
(3.9 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:a820c012311ca10c45e84f09b1aed6cf
|
100.9 kB | Download |
|
md5:97d3f8b57f5a430416513c6ec404c443
|
23.0 kB | Download |
|
md5:2d61a6d914d2a241a0cb1354222fff93
|
2.6 MB | Preview Download |
|
md5:03e9e3268b29695b8ac435491f79e885
|
1.2 MB | Preview Download |
|
md5:b83aebb21bd1f2520a1e763f82f202ff
|
163 Bytes | Preview Download |
|
md5:a1fe3a1a0f464ab9dfa9690c79a0b5bd
|
268 Bytes | Preview Download |
Additional details
Related works
- Cites
- Journal article: 10.3917/spub.hs2.2024.0071 (DOI)
- Journal article: 10.12688/openreseurope.13705.2 (DOI)
- Is supplement to
- Journal article: 10.12688/openreseurope.24052.1 (DOI)