Get startedGet started for free

Learning about a percentile

Suppose you want to learn about the 75th percentile of the sampling distribution defined by: $$Q75 = M + 0.674 S$$

This exercise is part of the course

Beginning Bayes in R

View Course

Exercise instructions

  • Examine the code that simulates 1000 values from the posterior distribution of (M, S).
  • Use the coef() and sigma.hat() functions to extract simulated vectors of M and S from sim_fit.
  • Compute simulated posterior values of the 75th percentile and save the result as Q75.
  • Construct a histogram of the posterior of Q75.
  • Find a 70% probability interval for Q75.

Hands-on interactive exercise

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

# Collect reaction times: times
times <- c(240, 267, 308, 275, 271,
           268, 258, 295, 315, 262)
           
# Fit a normal model: fit
fit <- lm(times ~ 1)

# Simulate 1000 from posterior:  sim_fit
sim_fit <- sim(fit, n.sims = 1000)

# Extract the simulated values of M and S: M_sim, s_sim
M_sim <- ___
s_sim <- ___

# Compute values of the 75th percentile: Q75


# Construct histogram of the posterior of Q75


# Find a 70% probability interval for Q75
Edit and Run Code