First Bayesian Inference: RShiny

Developed by Sonja Winter, Naomi Schalken, Lion Behrens and Rens van de Schoot

This Shiny App is designed to ease its users first contact with Bayesian statistical inference. By "pointing and clicking", the user infers a population mean based on a prior distribution to be specified and various pre-specified datasets to be uploaded. For further insight on the used data and an easy-to-go introduction to Bayesian inference, see van de Schoot et al. (2013). This tutorial exercise accompanied by all program code needed to reproduce the app can be found at the Open Science Framework.

The goal of this exercise is to play around with data and priors to see how these influence the posterior. We have written a small software package in R with a nice interface. Click on the preview to open your interface!

General procedure for the online tool:

Step 1: choose a type of distribution (i.e., Normal, uniform, truncated Normal) for the prior and fill in values for the hyperparameters.

Step 2: upload data: You can use the .csv files. Start with the n=20 dataset.

Step 3: let the software (i.e., RJags) estimate the posterior distribution.

Exercise

Copy-paste your model specifications and results to the table attached below.

a. Pretend you do not know nothing about IQ except that it cannot be negative and that values larger than 1000 are really impossible. Which prior will you choose?

b. Upload the data for 20 individuals and run the Bayesian model. Did your prior had any influence on the model results?

c. Change the prior to a distribution which would make more sense for IQ: we know it is normally distributed around 100 (=prior mean). How sure are you? Try values for prior SD = 15, 5, 1. Notice the prior becomes more peaked the smaller your prior SD. Run the model three times and write down the results. How would you describe the relation between your level of uncertainty and the posterior variance?

d. Now, repeat the steps in ‘b’ and ‘c’ for a dataset with a larger sample size (n=1,000). Copy-paste the results. How are the current results different from the results under ‘c’?

e. Repeat steps ‘c’ and ‘d’ but now for a different prior mean (assuming your prior knowledge conflicts with the data). Copy-paste your results. How did the new results differ when compared to the results with a ‘correct’ prior mean?

f. What is your opinion about the prior?

 

Table 1: Comparing your first Bayesian models

 

Reference

van de Schoot, R., Kaplan, D., Denissen, J., Asendorpf, J. B., Neyer, F. J. and van Aken, M. A.G. (2014), A Gentle Introduction to Bayesian Analysis: Applications to Developmental Research. Child Dev, 85: 842–860. doi:10.1111/cdev.12169

Other software exercises you might be interested in

MPLUS

How to get started

First Bayesian Inference

How to avoid and when to worry about the misuse of Bayesian Statistics

------------------------------------------

SPSS

How to get started

------------------------------------------

Lavaan

How to get started

------------------------------------------

Blavaan

How to get started

First Bayesian Inference

How to avoid and when to worry about the misuse of Bayesian Statistics

------------------------------------------

RJAGS

How to get started

How to avoid and when to worry about the misuse of Bayesian Statistics

------------------------------------------

JASP

How to get started