# First Bayesian Inference: RShiny

## Solutions

### Preparation for Exercise 1: prior-data-posterior

The first 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 in the subfolder ‘’course materials/day 1/exercises/data and input files’ where data on IQ scores is available for different sample sizes (n=20 - 10,000). Start with the n=20 dataset.

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

### Exercise 1: prior-data-posterior

Copy-paste your model specifications and results to the table attached below and bring it to the summerschool. We will discuss your results during the first lecture.

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 copy-past the result. 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. 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 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?

g. Which are differences between Bayesian statistics and the frequentist framework? Note down all differences that you encountered in this exercise and those you already knew beforehand.

Table 1: Comparing your first Bayesian models

### 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