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 11 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("Q1) P-values rely on a mathematical technique known as a stochastic proof by _______ .", 
           type = "learnr_text",
           answer_fn(function(value){
             if(str_remove_all(str_to_lower(value), " ") %in% 
                c("contradiction","Contradiction") ) {
               return(mark_as(TRUE))
               }
             return(mark_as(FALSE) )
             }),
           allow_retry = TRUE), 
    #question 2
  question_wordbank("Q2) Imagine that you wish to determine whether a new drug lowers cholesterol in at-risk patients, so you conduct a randomized experiment. You wish to compare the average cholesterol among those who took the drug vs. those who took a placebo. Match each step with the appropriate order for conducting a stochastic proof by contradiction. ",
  choices = c("Determine the sampling distribution of \\( \\frac{\\bar{x}_T - \\bar{x}_C - 0}{SE(\\bar{x}_T - \\bar{x}_C)} \\) and compute its value in your sample",
              "Use your p-value to determine the probability that the null hypothesis is true",
              "Compute a p-value from the t-distribution",
              "Use your p-value to determine how likely your observed value is under the null hypothesis",
              "Assume \\(\\mu_T = \\mu_C \\) (i.e. assume \\(\\mu_T - \\mu_C = 0 \\) )",
              "Assume \\(\\mu_T < \\mu_C \\) (i.e. that those in the treatment group have lower cholesterol on average)"),
  box = 9,
  arrange = "ordered",
  answer(c("Step 2", "This is not a valid step in a stochastic proof by contradiction", "Step 3", "Step 4",  "Step 1","This is not a valid step in a stochastic proof by contradiction"), correct = TRUE),
  allow_retry = TRUE
  ),
    # Q3
    question("Q3) You conduct a randomized clinical trial where participants are randomly assigned to a diet and exercise regimen and you want to test whether they experience improved sleep quality (measured on a continuous numeric scale) compared to the control group. What is the appropriate null hypothesis?
             Note this requires determining what the population parameter of interest is (e.g. $\\pi,\\mu,\\pi_1 - \\pi_2,\\mu_T - \\mu_C,\\beta_0,\\beta_1$ )", 
           answer("$\\beta_0 = 0$"),
           answer("$\\pi_1 - \\pi_2 = 0$"),
           answer("$\\pi = \\pi_{national}$"),
           answer("$\\mu_1 - \\mu_2 = 0$",correct=TRUE),
           answer("$\\mu = \\mu_{national}$"),
           answer("$\\beta_1 = 0$"),
           allow_retry = TRUE,
           random_answer_order = TRUE), 
  # Q4
    question("Q4) You use a survey of a random sample of NU students to test whether the percentage of students experiencing depression at Northwestern differs by minority status (coded as a binary categorical variable). What is the appropriate null hypothesis?
             Note this requires determining what the population parameter of interest is (e.g. $\\pi,\\mu,\\pi_1 - \\pi_2,\\mu_T - \\mu_C,\\beta_0,\\beta_1$ )", 
           answer("$\\beta_0 = 0$"),
           answer("$\\pi_1 - \\pi_2 = 0$",correct=TRUE),
           answer("$\\pi = \\pi_{national}$"),
           answer("$\\mu_1 - \\mu_2 = 0$"),
           answer("$\\mu = \\mu_{national}$"),
           answer("$\\beta_1 = 0$"),
           allow_retry = TRUE,
           random_answer_order = TRUE), 
  # Q5
    question("Q5) You use a survey of a random sample of NU students to test whether the percentage of students experiencing depression at Northwestern differs from the national norm. What is the appropriate null hypothesis?
             Note this requires determining what the population parameter of interest is (e.g. $\\pi,\\mu,\\pi_1 - \\pi_2,\\mu_T - \\mu_C,\\beta_0,\\beta_1$ )", 
           answer("$\\beta_0 = 0$"),
           answer("$\\pi_1 - \\pi_2 = 0$"),
           answer("$\\pi = \\pi_{national}$",correct=TRUE),
           answer("$\\mu_1 - \\mu_2 = 0$"),
           answer("$\\mu = \\mu_{national}$"),
           answer("$\\beta_1 = 0$"),
           allow_retry = TRUE,
           random_answer_order = TRUE), 
  # Q6
    question("Q6) You fit a regression model to determine if there is a relationship between housing prices (X) and a measure of school quality (Y) across zipcodes. What is the appropriate null hypothesis?
             Note this requires determining what the population parameter of interest is (e.g. $\\pi,\\mu,\\pi_1 - \\pi_2,\\mu_T - \\mu_C,\\beta_0,\\beta_1$ )", 
           answer("$\\beta_0 = 0$"),
           answer("$\\pi_1 - \\pi_2 = 0$"),
           answer("$\\pi = \\pi_{national}$"),
           answer("$\\mu_1 - \\mu_2 = 0$"),
           answer("$\\mu = \\mu_{national}$"),
           answer("$\\beta_1 = 0$",correct=TRUE),
           allow_retry = TRUE,
           random_answer_order = TRUE),
    # Q7
    question("Q7) Which of the following are valid examples of a null hypotheses? Select all that apply.", 
           answer("$\\mu = 19.5$",correct=TRUE),
           answer("$\\beta_1 = 0$",correct=TRUE),
           answer("$\\mu_1 - \\mu_2 = 0$",correct=TRUE),
           answer("$\\bar{x} = 19.5$"),
           answer("$\\hat{\\pi}_1 - \\hat{\\pi}_2 = 0$"),
           answer("$b_0 = 0$"),
           answer("$\\pi = 0.5$",correct=TRUE),
           answer("$\\pi_1 - \\pi_2 = 0$",correct=TRUE),
           allow_retry = TRUE,
           random_answer_order = TRUE),
    # Q8
    question("Q8) Which of the following are TRUE statements about p-values? Select all that apply.", 
           answer("A small p-value indicates data as extreme as what you observed is unlikely to occur if the null hypothesis is true", correct = TRUE),
           answer("A p-value is the probability that the observed statistic was produced by chance alone"),
           answer("A p-value is the probability of observing a t-statistic as extreme as the one you did assuming the null hypothesis is true", correct = TRUE),
           answer("A large p-value indicates you observed a large effect"),
           answer("A p-value is the probability that the null hypothesis is true"),
           answer("A p-value is the probability that the alternative hypothesis is true"),
           allow_retry = TRUE,
           random_answer_order = TRUE), 
      # Q9
    question("Q9) Assume for the context of your research question, you decide that a p-value < 0.1 is considered 'small.' Which of the following t-statistic values, if observed and calculated from your data, would result in 'small' p-values (i.e. p-value < 0.1)? Assume you have a sample of n = 1,000 people. Hint: You can use properties you know about the N(0,1) distribution since it is virtually equivalent to the t-distribution when the sample size is this large. Or you can use the function pt() to actually compute the p-values in R.", 
           answer("t-stat = -2.575", correct = TRUE),
           answer("t-stat = -1.7", correct = TRUE),
           answer("t-stat = -1"),
           answer("t-stat = 0.002"),
           answer("t-stat = 0.5"),
           answer("t-stat = 1.96", correct = TRUE),
           answer("t-stat = 3.2", correct = TRUE),
           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.