## WARNING: Make sure mit18_05_s22_RQuiz-test-answers.Rmd is synced with RQuiz-test.r

Problem 1

Problem 1a

rquiz_problem_1a(3, 2, 2, 3, -3, 11)
## ----------------------------------
## Problem 1a (5 points): Graphs

## See plots

Problem 1b

rquiz_problem_1b(18, 6, 14)
## -----
## Problem 1b (5 points): Combinations and factorials
## choose(18, 6) = 18564
## 14! = 87178291200
## lchoose(18, 6) = 9.82898
rquiz_problem_1b(10000, 1201, 55)
## -----
## Problem 1b (5 points): Combinations and factorials
## choose(10000, 1201) = Inf
## 55! = 1.26964e+73
## lchoose(10000, 1201) = 3666.841

Problem 1c

theta_values = c(0.1, 0.4, 0.5, 0.7, 0.9)
rquiz_problem_1c(theta_values, 200, 78)
## -----
## Problem 1c (10 points): Bayesian coins 
## 1c(i) The MLE is theta = 0.4 
## 1c(ii) Prior predictive probability of success = 0.52 
## 1c(iii) Posterior probabilities for theta
##      theta_values    posterior
## [1,]          0.1 3.303901e-26
## [2,]          0.4 9.921397e-01
## [3,]          0.5 7.860349e-03
## [4,]          0.7 1.689978e-18
## [5,]          0.9 3.406879e-68
theta_values = c(0.4, 0.6, 0.8, 1.0)
rquiz_problem_1c(theta_values, 50, 38)
## -----
## Problem 1c (10 points): Bayesian coins 
## 1c(i) The MLE is theta = 0.8 
## 1c(ii) Prior predictive probability of success = 0.7 
## 1c(iii) Posterior probabilities for theta
##      theta_values    posterior
## [1,]          0.4 1.801448e-06
## [2,]          0.6 6.823300e-02
## [3,]          0.8 9.317652e-01
## [4,]          1.0 0.000000e+00

Problem 2

Problem 2a

rquiz_problem_2a(1000, 10, 0.5)
## ----------------------------------
## Problem 2a (10 points): Density histograms

## See plots
rquiz_problem_2a(1000, 30, 0.5)
## ----------------------------------
## Problem 2a (10 points): Density histograms

## See plots

Problem 2b

rquiz_problem_2b(10000, 100, 2, 0.2)
## -----
## Problem 2b (10 points): Density histograms

## See plots

Problem 3

set.seed(42)
rquiz_problem_3(rnorm(200, 3, 4), 0.05)
## ----------------------------------
## Problem 3 (10 points): 
## The null hypothesis H0 is <YOU NEED TO WRITE THIS>. 
## p_value = 0.9464181 
## Do not reject H0.
rquiz_problem_3(rt(200, 1), 0.05)
## ----------------------------------
## Problem 3 (10 points): 
## The null hypothesis H0 is <YOU NEED TO WRITE THIS>. 
## p_value = 4.470282e-24 
## Reject H0 in favor of HA that <YOU NEED TO WRITE THIS>.
rquiz_problem_3(rt(30, 4), 0.1)
## ----------------------------------
## Problem 3 (10 points): 
## The null hypothesis H0 is <YOU NEED TO WRITE THIS>. 
## p_value = 0.0545889 
## Reject H0 in favor of HA that <YOU NEED TO WRITE THIS>.

Problem 4 (Extra credit)

rquiz_problem_4('mit18_05_s22_RQuiz_data_prob4_test.txt', 0.05)
## ----------------------------------
## Problem 4 (Extra credit: 5 points): 
## p value = 0.7195056 
## Do not reject H0 that the means are the same

MIT OpenCourseWare

https://ocw.mit.edu

18.05 Introduction to Probability and Statistics

Spring 2022

Authors: Jeremy Orloff and Jennifer French

For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms