DOI: 10.5281/zenodo.17982872
title: Supplementary tables, 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 Islands 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 tables



BayesianABTest_smallSampleSizes_supplementaryTables.pdf: contains supplementary Tables S1 to S8.
description: 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 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.


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.

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 tables

The supplementary tables are in the .pdf file entitled BayesianABTest_smallSampleSizes_supplementaryTables.pdf. There 8 tables from Table S1 to Table S8:



Table S1. Indicators of the IBE approach results and related to the distributions of π1, π2 and δ = π2 - π1  estimated by the implementation of three methods (i.e., our own simulation, bayesAB package, and MCMC with R2jags) on the Move Ô case study in the three investigated scenarios: non-informative, informative, and 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 implementation of two methods (abtest package, and MCMC with R2jags) on the Move Ô case study in the three investigated scenarios: non-informative, informative, and optimistic. The indicators are: the simulated prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S3. Indicators of the IBE approach results and related to the distributions of π1, π2 and δ = π2 - π1 estimated by the implementation of three methods (i.e., our own simulation, bayesAB package, and MCMC with R2jags) on the Lifou case study in the three investigated scenarios: non-informative, informative, and optimistic. The indicators are: the prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S4. Indicators of the LTT approach results and related to the distributions of γ, ψ, π1, π2 and δ = π2 - π1 estimated by the implementation of two methods (abtest package, and MCMC with R2jags) on the Lifou case study in the three investigated scenarios: non-informative, informative, and optimistic. The indicators are: the simulated prior quantiles, posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S5. Indicators of the IBE approach results related to the distributions of π1, π2 and δ = π2 - π1 estimated by the implementation of our own simulation on the altered data from the Move Ô case study in the three investigated scenarios: non-informative, informative, and optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S6. 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: non-informative, informative, and optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S7. Indicators of the IBE approach results related to the distributions of π1, π2 and δ = π2 - π1 estimated by the implementation of our own simulation on the altered data from the Lifou case study in the three investigated scenarios: non-informative, informative, and optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).

Table S8. 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: non-informative, informative, and optimistic. The indicators are: the posterior quantiles, and 90% credible intervals (highest density interval and equal-tailed interval).