lab06-Revised-Bailey-Jun10-2022

pdf

School

University of North Georgia, Dahlonega *

*We aren’t endorsed by this school

Course

MATH-240

Subject

Statistics

Date

Apr 3, 2024

Type

pdf

Pages

6

Uploaded by SuperHumanKoala4250

Report
lab06-Revised-Bailey-Jun10-2022 March 24, 2024 [1]: #import otter #grader = otter.Notebook() 0.1 Lab 6: Examining the Therapeutic Touch Welcome to Lab 6! After such an extensive introduction to programming for data science, we are finally moving into the section of the course where we can apply our new skils to answer real questions. In this lab, we’ll use testing techniques that were introduced in lecture to test the idea of the therapeutic touch, the idea that some practitioner can feel and massage your human energy field. Please complete this notebook by filling in the cells provided. The cell above with import the autograder. Each time you start your server, you will need to execute this cell again to load the tests. HOWEVER, the autograder files have not been integrated online and running the cell above will cause an error! Ignore this cell and cells of the form grader.check(“qx.k”). [2]: # Run this cell, but please don't change it. # These lines import the Numpy and Datascience modules. import numpy as np from datascience import * # These lines do some fancy plotting magic import matplotlib % matplotlib inline import matplotlib.pyplot as plt plt . style . use( 'fivethirtyeight' ) import warnings warnings . simplefilter( 'ignore' , FutureWarning ) from matplotlib import patches from ipywidgets import interact, interactive, fixed import ipywidgets as widgets import scipy.stats as stats # These lines load the tests. 1
#import otter #grader = otter.Notebook() 0.1.1 What is the Therapeutic Touch The Therapeutic Touch (TT) is the idea that everyone can feel the Human Energy Field (HEF) around individuals. Those who practice TT have described different people’s HEFs as “warm as Jell-O” and “tactile as taffy.” TT was a popular technique used throughout the 20th century that was toted as a great way to bring balance to a person’s health. Certain practitioners claim they have the ability to feel the HEF and can massage it in order to promote health and relaxation in individuals. 0.1.2 Emily Rosa Emily Rosa was a 4th grade student who was very familiar with the world of TT, thanks to her parents, who were both medical practitioners and skeptics of TT. For her 4th grade science fair project, Emily decided to test whether or not TT practitioners could truly interact with a person’s HEF. She later went on to publish her work in TT, becoming the youngest person to have a research paper published in a peer reviewed medical journal. 0.1.3 Emily’s Experiment Emily’s experiment was clean, simple, and effective. Due to her parents’ occupations in the medical field, she had wide access to people who claimed to be TT practitioners. Emily took 21 TT practitioners and used them for her science experiment. She would take a TT practitioner and ask them to extend their hands through a screen (which they can’t see through). Emily would be on the other side and would flip a fair coin. Depending on how the coin landed, she would put out either her left hand or her right hand. The TT practitioner would then have to answer which hand Emily put out. If a pracitioner could truly interact with a person’s HEF, it would be expected that they answered correctly. Overall, through 210 samples, the practitioner picked the correct hand 44% of the time. Emily’s main goal here was to test whether or not the TT practicioners’ guesses were random, like the flip of a coin. Imagine that she did not believe that the TT practicioners were really able to sense a HEF and she wanted to prove that they did worse than simple random guessing. We will now begin to formulate this experiment in terms of the terminology we learned in this course. Question 1 : Describe the null model for how likely the TT practitioners are to choose the correct hand. What alternative model is her model meant to discredit? Discuss with students around you to come to a conclusion. Check in with a TA or LA if you are stuck. If π represents the probability of picking the correct hand, specify the null and alternative hypothe- ses. H o : π = 0.5 H a : π < 0.5 2
Question 2: Remember that the practitioner got the correct answer 44% (0.44) of the time. According to the null model, on average, what proportion of times do we expect the practitioner to guess the correct hand? Make sure your answer is between 0 and 1. [3]: expected_proportion_correct = 0.5 model_proportions = make_array(expected_proportion_correct, 1 - , expected_proportion_correct) model_proportions [3]: array([0.5, 0.5]) [4]: #grader.check("q1_2") Question 3: In the code cell below we will provide a simulation that will test whether the TT practitioners results are consistent with their claims that they can sense an HEF. Just run the cell below. [5]: actual_proportion = 0.44 def statistic (expected_prop_correct, actual_prop): return 100* (actual_prop - expected_prop_correct) observed_statistic = statistic(expected_proportion_correct, actual_proportion) def simulation_and_statistic (model_proportions, expected_prop_correct): '''Simulates 210 TT hand choices under the null model. Returns one statistic from the simulation.''' simulation_proportion_correct = sample_proportions( 210 , model_proportions) . , item( 0 ) one_statistic = expected_prop_correct - 100* simulation_proportion_correct return one_statistic num_repetitions = 5000 simulated_statistics = make_array() for i in np . arange(num_repetitions): simulated_statistics = np . append(simulated_statistics, , simulation_and_statistic(make_array( 0.5 , 0.5 ), 50 )) p_value = sum (simulated_statistics <= -6.0 ) / num_repetitions print ( f"A single trial was 210 selections, and this simulation consisted of , { num_repetitions } trials. \n The p-value for this simulation is { p_value } ." ) A single trial was 210 selections, and this simulation consisted of 5000 trials. The p-value for this simulation is 0.0402. 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
[6]: #grader.check("q1_3") Question 4 We can make a visual argument as to whether we believe the observed statistic is consistent with the null model. Here, since larger values of the test statistic suggest the alternative model (where the chance of guessing the correct hand is something other than 50%), we can formalize our analysis by finding what proportion of simulated statistics were as large or larger than our observed test statistic (the area at or to the right of the observed test statistic). If this area is small enough, we’ll declare that the observed data are inconsistent with our simulated model. What percentage of the histogram below is shaded in yellow/gold? a) Less than 5% b) More than 5% [7]: t = Table() . with_column( 'Simulated Statistics' , simulated_statistics) bins = np . arange( -11 , 11 , 2.5 ) t . hist(right_end = observed_statistic, bins = bins) plt . ylim( -0.01 , .11 ) plt . scatter(observed_statistic, -.001 , color = 'red' , s =50 , zorder =3 , marker = , "^" ); a) Less than 5% By convention, we often compare the proportion we just calculated to 0.05. This cut-off value for the p-value is denoted by a lower case Greek letter alpha, α , and is also referred to as the level of significance . If the proportion of simulated statistics greater than or equal to the observed 4
statistic is suffciently small (less than or equal to 0.05), then this is evidence against the null model. Otherwise, we don’t have any reason to doubt the null model. This should help you make your own conclusions about Emily Rosa’s experiment. Question 5: If the p-value is smaller than 0.05, that is evidence against the null hypothesis. The null hypothesis is that the TT practitioners really can feel a human energy field. If the p-value is smaller than 0.05, that is also evidence in favor of the alternative hypothesis. The alternative hypothesis is that the TT practitioners can not feel a human energy field. This is Emily’s research hypothesis that the TT practitioners are randomly guessing. Based on the p-value , what is most likely true here? Is this data more consistent with Emily’s hypothesis, or more consistent with the practitioners claims that they can feel an HEF? Based on the P-value being 0.04 we can reject the null hypothesis and say that TT practitioners are randomly guessing. Therapeutic touch fell out of use after this experiment, which was eventually accepted into one of the premier medical journals. TT practitioners hit back and accused Emily and her family of tampering with the results, while some claimed that Emily’s bad spiritual mood towards therapeutic touch made it diffcult to read her HEF. Whatever it may be, Emily’s experiment is a classic example about how anyone, with the right resources, can test anything they want! [8]: #grader.check("q1_9") 0.2 Is there a built-in test for this? We can use the binom_test from the scipy.stats module. It runs a hypothesis test called a binomial test and produces a single output, which is the p-value for the test. In the cell below we run the test. Unfortunately, this test does not operate on percentages, but on counts. So we converted the 44% success rate to 92 successes in 210 trials. Question 6: Using an α of 0.05, draw a conclusion from this binomial test. H o : π = 0 . 5 H a : π < 0 . 5 [9]: stats . binom_test( 92 , 210 , 0.5 , alternative = "less" ) [9]: 0.042126933274541596 Based on the P-value being 0.04 we can reject the null hypothesis and say that TT practitioners are randomly guessing. 0.3 Another researcher Suppose another researcher, trying to disprove Emily’s result, conducted a similar experiment with 210 trials and got 115 successes. Question 7: Run the binom_test and state your conclusions in the cells below here. 5
Remember, since this researcher is working to disprove Emily, the alternative hypothesis would be different. H o : π = 0 . 5 H a : π > 0 . 5 [10]: # Run the binom_test in this cell stats . binom_test( 115 , 210 , 0.5 , alternative = "greater" ) [10]: 0.09484499448959463 Because the P-value is less than 0.5 we accept the alternatice Question 8: At the 5% level of significance, what is the least number of successes this second researcher must find in a sample of 210 trials in order for the binom_test to yield a p-value small enough to reject the null hypothesis? [55]: # Let least_successes represent the answer to the question above. least_successes = 105 [56]: # If you've answered the above question right, this test should have a p-value , below 0.05 stats . binom_test(least_successes, 210 , 0.5 , alternative = "greater" ) [56]: 0.5274968790385095 Congratulations! You’re done with Lab 6. Download this file in the format(s) your instructor requires and submit to the Lab 6 folder under Assignments. [ ]: 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help