Compare with classical interval
In our example, if \(\bar y\) and \(se\) are the respective sample mean and standard error, then a standard 90 percent confidence interval for M
is given by
$$ (\bar y - 1.645 \times se, \bar y + 1.645 \times se). $$
For my data, we have ybar
= 275.9, and se
= 6.32, so my confidence interval is given by
c(275.9 - 1.645 * 6.32, 275.9 + 1.645 * 6.32)
Recall that Kathy's posterior curve was normal with mean 271.35 and standard deviation 5.34.
Now you can compare the 90% confidence interval with Kathy's probability interval for M
!
This exercise is part of the course
Beginning Bayes in R
Exercise instructions
- Compute a vector
C_Interval
containing the 90% confidence interval. This is the interval obtained by using the frequentist method. - Find the length of the confidence interval using the
diff()
function. - Define a vector
Posterior
with the mean and standard deviation of Kathy's posterior. - Use the
normal_interval()
function to display a 90% probability interval. - Use
qnorm()
to compute the 90% Bayesian probability interval. Assign the result toB_Interval
. - Compute the length of the Bayesian interval using
diff()
once more.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define mean and standard error: Data
Data <- c(275.9, 6.32)
# Compute 90% confidence interval: C_Interval
# Find the length of the confidence interval
# Define mean and standard deviation of posterior: Posterior
# Display a 90% probability interval
# Compute the 90% probability interval: B_Interval
B_Interval <- qnorm(c(___, ___), mean = ___, sd = ___)
# Compute the length of the Bayesian interval