MyNixOS website logo
Description

User Friendly Bayesian Data Analysis for Psychology.

Contains several Bayesian models for data analysis of psychological tests. A user friendly interface for these models should enable students and researchers to perform professional level Bayesian data analysis without advanced knowledge in programming and Bayesian statistics. This package is based on the Stan platform (Carpenter et el. 2017 <doi:10.18637/jss.v076.i01>).

bayes4psy—User Friendly Bayesian Data Analysis for Psychology

R-CMD-check CRAN_Status_Badge Downloads

Authors

Jure Demšar, Grega Repovš and Erik Štrumbelj

  • Faculty of Computer and Information Science, University of Ljubljana
  • MBLab, Department of Psychology, Faculty of Arts, University of Ljubljana

The package

This is an R package intended for Bayesian statistical analysis in the field of psychology. Psychology is one of the fields where the replication crisis is the most prominent. Scientist believe that one of the main reason for this might be non-transparent and inappropriate use of frequentist statistics. We believe that using fully transparent Bayesian methods provided in this package could greatly alleviate the replication crisis in psychology.

We also prepared several examples where we used the bayes4psy package to perform Bayesian data analysis for scientific publications on actual data gathered by psychological tests. These examples can be found on our GitHub repository. This repository also includes short test scenarios (these scenarios execute all developed functionalities on dummy data) intended for debugging the package.

This readme document provides only a brief overview of the package, a detailed description of all implemented functions is provided in package's help pages.

Models

Bayesian models in the bayes4psy package are written with the Stan language. Stan functions required for working with these models are accessed via the RStan package. There are currently five models in the package:

  • a Bayesian t-test (Bayesian alternative to the classic t-test, see John Kruschke -- Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan),
  • a reaction time model (a hierarchical exponentially modified Gaussian model),
  • a success rate model (a hierarchical Bernoulli-Beta model),
  • a linear model (a hierarchical linear regression),
  • a color model (normal/Von Mises model).

Model fitting

The fitted model objects returned by the bayes4psy package are called b_results objects. These objects contain three components, extract contains values of fitted parameters, fit is the original stanfit object and data is the input data used for fitting. To fit a model to the data one has to first prepare the input data and then call an appropriate fitting function:

  • b_ttest (the Bayesian t-test),
  • b_reaction_time (the reaction time model),
  • b_success_rate (the success rate model,
  • b_linear (the linear model),
  • b_color (the color model).

If no priors are provided as parameters for fitting functions, then flat (improper) priors are put on all parameters. See provided examples and tests to see how one can specify their own priors.

Analyzing fits

To enable users without extensive programming knowledge to perform professional level Bayesian data analysis we developed a number of custom methods. Below is a short description of functions common to all models, for descriptions of functions specific to certain models consult the package's help pages.

  • summary prints a summary of the fit.
  • print, show prints a more detailed summary of the fit (same as RStan's print function).
  • plot_fit visualize the quality of the fitted model against the input data.
  • plot_trace construct a trace plot for relevant parameters of the fitted model.
  • get_parameters extracts the parameters of the fitted model.
  • get_subject_parameters get parameters for each subject (useful only for hierarchical models).
  • plot_means visualize means for a single or multiple fitted models.
  • compare_means compare means between two or more fitted models.
  • plot_means_difference visualize the difference of means between two or more fitted models.
  • plot_distributions visualize distributions underlying fitted models, can be used to visualize one or more fitted models.
  • compare_distributions draw and compare samples from distributions underlying fitted models, can be used to compare two or more fitted models.
  • plot_distributions_difference visualize the difference in distributions underlying fitted models, can be used to compare two or more fitted models.

Resources

  • bayes4psy_tools repository with real life examples that use the package to perform scientific paper grade Bayesian data analysis.
  • Open an issue GitHub issues for bug reports, feature requests.
  • Stan the Stan homepage.

Development Version

You can install the development version from GitHub. To do so you first have to install the RStan package and C++ toolchain (instructions). Once RStan and the toolchain are installed, you can install bayes4psy by using the devtools package in R:

if (!require(devtools)) {
  install.packages("devtools")
  library(devtools)
}
install_github("bstatcomp/bayes4psy")

Funding

The research behind this software was partially funded by the Slovenian Research Agency (ARRS) through grants L1-7542 (Advancement of computationally intensive methods for efficient modern general-purpose statistical analysis and inference), P3-0338 (Physiological mechanisms of neurological disorders and diseases), J3-9264 (Decomposing cognition: working memory mechanism and representations), P5-0410 (Digitalization as driving force for sustainability of individuals, organizations, and society), and P5-0110 (Psychological and neuroscientific aspects of cognition).

Metadata

Version

1.2.12

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows