Get startedGet started for free

The posterior

In our spinner example, Prior contains the prior probabilities (1/2, 1/2) and Likelihood contains the likelihoods (1/2, 1/6) since the result of the spin was blue (3).

To compute the product and posterior probabilities, you can use the bayesian_crank() function, which takes as input a data frame containing Model, Prior and Likelihood.

This exercise is part of the course

Beginning Bayes in R

View Course

Exercise instructions

The vector of models, Model, is available in your workspace.

  • Create the two vectors Prior and Likelihood using the values provided above.
  • Construct a data frame called bayes_df containing variables Model, Prior, and Likelihood, in that order.
  • Use the bayesian_crank() function to compute the posterior probabilities of Spinner A and Spinner B.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create the vector of models: Model
Model <- c("Spinner A", "Spinner B")

# Define the vector of prior probabilities: Prior
Prior <- ___

# Define the vector of likelihoods: Likelihood
Likelihood <- ___

# Make a data frame with variables Model, Prior, Likelihood: bayes_df


# Compute the posterior probabilities
Edit and Run Code