BANOVA-package {BANOVA}R Documentation

BANOVA: Hierarchical Bayesian ANOVA Models


This package includes several hierarchical Bayes Analysis of Variance models. These models are suited for the analysis of experimental designs in which both within- and between- subjects factors are manipulated, and account for a wide variety of distributions of the dependent variable. Floodlight analysis and mediation analysis basaed on these models are also provided. The package uses 'Stan' and 'JAGS' as the computational platform.


Package: BANOVA
Type: Package
Version: 1.2.1
Date: 2022-06-18
License: GPL (>= 2)

E(y_i) = g^{-1}(\eta_i)
where \eta_i = \sum_{p = 0}^{P}\sum_{j=1}^{J_p}X_{i,j}^p\beta_{j,s_i}^p, s_i is the subject id of data response i. Missing values (NAs) of y_i are allowed. The within-subjects factors and their interactions are indexed by p (p = 1,2,.,P). Each index p represents a batch of J_p coefficients: \beta_{j,s}^p, j = 1,.,J_p;s = 1,.,S indexes subjects. Note that if the subject-level covariate is continuous, J_p=1, so that ANCOVA models are also accommodated (relaxing their "constant slope" assumption).

The population-level model allows for heterogeneity among subjects, because the subject-level coefficients \beta_{j,s}^p are assumed to follow a multivariate normal distribution.The between-subjects factors and their interactions are indexed by q,(q = 1,2,.,Q), q = 0 denotes the constant term. The population-level ANOVA can be written as:
\beta_{j,s}^p = \sum_{q = 0}^Q \theta_{j,k_s^q}^{pq} + \delta_{j,s}^p

The population-level ANCOVA model can be expressed as a linear model with a design matrix Z that contains all between-subjects factors and their interactions and a constant term:
\beta_{j,s}^p = \sum_{k = 1}^Q Z_{s,k}\theta_{j,k}^{p} + \delta_{j,s}^p
where Z_{s,k} is an element of Z, a S \times Q matrix of covariates. \theta_{j,k}^p is a hyperparameter which captures the effects of between-subjects factor q on the parameter \beta_{j,s}^p of within-subjects factor p. The error \delta_{j,s}^p is assumed to be normal: \delta_{j,s}^p ~ N(0,\sigma_p^{-2} ). Proper, but diffuse priors are assumed: \theta_{j,k}^p ~ N(0,\gamma), and \sigma_p^{-2} ~ Gamma(a,b), where \gamma,a,b are hyper-parameters. The default setting is \gamma = 10^{-4}, a = 1, b = 1.

Note that missing values of independent variables are currently not allowed in the package.


Chen Dong; Michel Wedel

Maintainer: Chen Dong <>


Dong, C. and Wedel, M. (2017) BANOVA: An R Package for Hierarchical Bayesian ANOVA, Journal of Statistical Software, Vol. 81, No.9, pp. 1-46.

McCullagh, P., Nelder, JA. (1989) Generalized linear models, New York, NY: Chapman and Hall.

Gelman, A. (2005) Analysis of variance-why it is more important than ever, Ann. Statist., Vol. 33, No. 1, pp. 1-53.

Rossi, P., Allenby,G., McCulloch, R. (2005) Bayesian Statistics and Marketing, John Wiley and Sons.

Gill, J. (2007) Bayesian Methods for the Social and Behavioral Sciences, Chapman and Hall, Second Edition.

Gelman, A., Carlin, J., Stern, H. and Dunson, D. (2013) Bayesian Data Analysis, London: Chapman and Hall.

Wedel, M. and Dong, C. (2016) BANOVA: Bayesian Analysis of Variance for Consumer Research. Submitted.

[Package BANOVA version 1.2.1 Index]