Skip to content

tdyachenko/BAHM-Mediation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bayesian Analysis of Heterogeneous Mediation (BAHM)

This project hosts code for Bayesian heterogeneous mediation described in

Tatiana L Dyachenko, Greg M Allenby (2023), Is Your Sample Truly Mediating? Bayesian Analysis of Heterogeneous Mediation (BAHM), Journal of Consumer Research, 50(1), p.116-141. https://doi.org/10.1093/jcr/ucac041

(new code for categorical outcome (y) and mediator (m) variables is coming soon)

You can get an R package "bahm" following the instructions below. This will open the application on your device.

  1. You need to have R installed on your computer:

  2. Open file called LinesToLoad_BAHM.R and follow the instructions in the file (3 lines)

## Install needed libraries 
install.packages(c("shiny", "bayesm", "HDInterval", "coda", "gtools","dplyr", "readr", "DT", "future", "promises", "ipc", "future.callr",
                   "future.apply", "data.table", "shinyWidgets", "devtools","htmltools", "shinydashboard","shinyjs"))

## Getting the package from github
devtools::install_github("tdyachenko/BAHM-Mediation", ref = "r-pkg",force = TRUE)

## Loading the package 
library(bahm)

## Starting the app on your device
run_bahm()

Alternatively, the app can be run as a web application, but it might be much slower. https://bayesianmediationanalysis.shinyapps.io/BAHM/