library(learnr)
library(tidyverse)
library(tutorialExtras)
library(gradethis)

gradethis_setup()
knitr::opts_chunk$set(echo = FALSE)
grade_server("grade")
question_text("Name:",
              answer_fn(function(value){
                              if(length(value) >= 1 ) {
                                return(mark_as(TRUE))
                                }
                              return(mark_as(FALSE) )
                              }),
              correct = "submitted",
              allow_retry = FALSE )
grade_button_ui(id = "grade")

Instructions

Complete this tutorial while reading Chapter 10 of the textbook. Each question allows 3 'free' attempts. After the third attempt a 10% deduction occurs per attempt.

You can click the "View Grade" button as many times as you would like to see your current grade and the number of attempts you are on. Before submitting make sure your grade is as expected.

Goals

Reading Quiz

quiz(
  caption = NULL,
  # Question 1
  question_wordbank("Q1) Fill in each blank with increase or decrease:",
           choices = c("Increasing the level of confidence will ______ the width of the interval", "Increasing the sample size will ______ the standard error", "Increasing the sample size will ______ the width of the interval", "Increasing the level of confidence will ______ the margin of error", "Increasing the sample size will ______ the margin of error", "Increasing the margin of error will ______ the width of the interval"),
           wordbank = c("increase", "decrease"),
           answer(c("increase", "decrease", "decrease", "increase", "decrease", "increase"), correct = TRUE),
           allow_retry = TRUE),  
     # Q2
    question_blank("<strong> Q2) </strong> <br/>
   a) What is the appropriate critical value for a 95% confidence interval using the N(0,1) distribution? Report the positive value and round to 2 decimal places. ___ <br/>
   b) What percentage of data falls between -2.575 and 2.575 in a N(0,1) distribution? ___ % <br/>
   c) What percentage of data falls to the LEFT of 1.645 in a N(0,1) distribution? ___ %", 
           answer("1.96", correct = TRUE),
           answer("99", correct = TRUE),
           answer("95", correct = TRUE),
           allow_retry = TRUE),   
    # Q3
  question("Q3) Assume you have a sample of n = 50 observations and want to construct a 95% confidence interval for the mean when $\\sigma$ is known.
             Hint: Read 10.1.1 to determine if you need the N(0,1) or t(df) distribution, and read 10.1.4 to determine the appropriate critical value ", 
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 2.01\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 1.96\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$\\bar{x} \\pm 1.96\\frac{\\sigma}{\\sqrt{n}}$", correct = TRUE),
           answer("$\\bar{x} \\pm 1.645\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 2.01\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           answer("$\\bar{x} \\pm 2.01\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 1.96\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           allow_retry = TRUE),
    # Question 11
    question("Q4) Assume you have a sample of n = 50 observations and want to construct a 95% confidence interval for the difference in means when $\\sigma$ is unknown.
             Hint: Read 10.1.1 to determine if you need the N(0,1) or t(df) distribution, and read 10.1.4 to determine the appropriate critical value ", 
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 2.01\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$", correct = TRUE),
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 1.96\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$\\bar{x} \\pm 1.96\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 2.01\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           answer("$\\bar{x} \\pm 2.01\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 1.96\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           allow_retry = TRUE),
    # Question 12
    question("Q5) Assume you have a sample of n = 50 observations and want to construct a 95% confidence interval for the proportion.
             Hint: Read 10.1.1 to determine if you need the N(0,1) or t(df) distribution, and read 10.1.4 to determine the appropriate critical value ", 
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 2.01\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 1.96\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$\\bar{x} \\pm 1.96\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 2.01\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           answer("$\\bar{x} \\pm 2.01\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 1.96\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$", correct = TRUE),
           allow_retry = TRUE),
    # Q6
    question("Q6) Assume you have a sample of n = 50 observations and want to construct a 95% confidence interval for the mean, when $\\sigma$ is unknown.
             Hint: Read 10.1.1 to determine if you need the N(0,1) or t(df) distribution, and read 10.1.4 to determine the appropriate critical value ", 
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 2.01\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$(\\bar{x}_1 - \\bar{x}_2) \\pm 1.96\\sqrt{\\frac{s_1^2}{n_1}+\\frac{s_1^2}{n_2}}$"),
           answer("$\\bar{x} \\pm 1.96\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{\\sigma}{\\sqrt{n}}$"),
           answer("$\\bar{x} \\pm 1.645\\frac{s}{\\sqrt{n}}$"),
           answer("$\\hat{\\pi} \\pm 2.01\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           answer("$\\bar{x} \\pm 2.01\\frac{s}{\\sqrt{n}}$", correct = TRUE),
           answer("$\\hat{\\pi} \\pm 1.96\\sqrt{\\frac{\\hat{\\pi}(1-\\hat{\\pi})}{n}}$"),
           allow_retry = TRUE),
      # Q7
    question_wordbank("Q7) Match each confidence level and distribution with its appropriate critical value.",
           choices = c("90% N(0,1)", "95% N(0,1)", "99% N(0,1)", "95% t(99)", "95% t(49)", "99% t(49)"),
           wordbank = c("1.645","1.96", "2.575", "1.98", "2.01", "2.68"), 
           answer(c("1.645","1.96", "2.575", "1.98", "2.01", "2.68"), correct = TRUE),
           allow_retry = TRUE),      
        # Q8
    question_blank("<strong> Q8) Consider the football fans example from Chapter 10. Suppose you have a sample of n = 100 and find the average age in your sample to be 31.6 and the sample standard deviation to be 10 (assume you do not know the population standard deviation). </strong> <br/>
   a) What is the standard error of your estimate? Round to 2 decimal places. ___ <br/>
   b) What is the appropriate critical value for a 95% confidence interval in this scenario? Round to 2 decimal places. ___ <br/>
   c) What is the margin of error of your confidence interval? Round to 2 decimal places. ___ <br/>
   d) Compute and report your confidence interval (using your rounded values reported above): <br/> [ ___ , ___ ]",
           answer_fn(function(value){
                        if (value %in% c("1", "1.00")) {
                            return(mark_as(TRUE))}
                            return(mark_as(FALSE) ) }),
           answer("1.98", correct = TRUE),
           answer("1.98", correct = TRUE),
           answer("29.62", correct = TRUE),
           answer("33.58", correct = TRUE),
           allow_retry = TRUE),   
          # Q9
    question_numeric("Q9) If you simulate many, many repeated samples (e.g. 1,000,000) and construct a 99% confidence interval for the mean in each one, in approximately what percentage of samples do you expect the confidence interval to NOT capture the true population mean? ", 
           answer(1, correct = TRUE),
           allow_retry = TRUE),   
          # Q10
    question("Q10) Suppose you want to estimate $\\pi$, the proportion of students at Northwestern who support legalizing marijuana, so you take a random sample of 100 students and find that 73 of them say they support legalization. You use this data to compute the following 95% confidence interval for $\\pi$: [0.643, 0.817]. Which of the following are TRUE/VALID conclusions given this scenario? Select all that apply.",
           answer("We are 95% confident that between 64.3% and 81.7% of Northwestern students support legalizing marijuana", correct = TRUE),
           answer("The margin of error of our estimate was about 5%"),
           answer("There is a 5% chance our interval does not contain $\\pi$", correct = TRUE),
           answer("Exactly 73% of Northwestern students support legalizing marijuana"),
           answer("If we took many different random samples of 100 students, we would expect approximately 95% of our estimates to fall between .643 and .817"),
           allow_retry = TRUE,
           random_answer_order = TRUE)

)

Submit

Once you are finished:

grade_print_ui("grade")


NUstat/ISDStutorials documentation built on April 17, 2025, 6:15 p.m.