3. Introduction to hypothesis testing via binomial tests

Remember you should

Overview

This practice reviews the Hypothesis testing starting with binomial tests lecture.

Hypothesis Testing and the Binomial Distribution

Example

Using the bat paper from class (Geipel et al. 2021), let’s consider how to analyze data showing all 10 bats chose the walking over the motionless model.

binom.test(10,10)

    Exact binomial test

data:  10 and 10
number of successes = 10, number of trials = 10, p-value = 0.001953
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.6915029 1.0000000
sample estimates:
probability of success 
                     1 

We use the binom.test function. We only need arguments for # of succeses and # of trials. By default it runs a 2-sided test against a null hypothesis value of p = .5. You can see how to update thee options by looking at the help file.

?binom.test

Note the confidence interval is assymetric since its estimated to be 1! We can see other options using the binom.confint function from the binom package.

library(binom)
Warning: package 'binom' was built under R version 4.3.1
binom.confint(10,10)
          method  x  n      mean     lower    upper
1  agresti-coull 10 10 1.0000000 0.6791127 1.043355
2     asymptotic 10 10 1.0000000 1.0000000 1.000000
3          bayes 10 10 0.9545455 0.8292269 1.000000
4        cloglog 10 10 1.0000000 0.6915029 1.000000
5          exact 10 10 1.0000000 0.6915029 1.000000
6          logit 10 10 1.0000000 0.6915029 1.000000
7         probit 10 10 1.0000000 0.6915029 1.000000
8        profile 10 10 1.0000000 0.7303058 1.000000
9            lrt 10 10 1.0000000 0.8252466 1.000000
10     prop.test 10 10 1.0000000 0.6554628 1.000000
11        wilson 10 10 1.0000000 0.7224672 1.000000

All of these correct for the fact that most intervals use a normal approximation, which as you remember from our earlier discussions is not good when sample sizes are small and/or the p parameter is extreme (close to 0 or 1).

Practice!

Make sure you are comfortable with null and alternative hypotheses for all examples.

1

Are people eared (do they prefer one ear or another)? Of 25 people observed while in conversation in a nightclub, 19 turned their right ear to the speaker and 6 turn their left ear to the speaker. How strong is the evidence for eared-ness given this data (adapted from Analysis of Biological Data)?

  • state a null and alternative hypothesis
  • calculate a test statistic (signal) for this data
    • Make sure you understand how to construct a null distribution
      • using sampling/simulation (code or written explanation)
      • by using an appropriate distribution (code or written explanation)
  • Calculate and compare p-values obtained using
    • simulation (calculation won’t be required on test, but make sure you understand!) (code or written explanation)
    • equations for binomial distribution (code or written explanation) + R functions (required)(code)
  • Calculate a 95% confidence interval for the proportion of people who are right-eared
    • How do your 95% confidence interval and hypothesis test compare?

2

A professor lets his dog take every multiple-choice test to see how it compares to his students (I know someone who did this). Unfortunately, the professor believes undergraduates in the class tricked him by helping the dog do better on a test. It’s a 100 question test, and every questions has 4 answer choices. For the last test, the dog picked 33 questions correctly. How likely is this to happen, and is there evidence the students helped the dog?

MAKE SURE TO THINK ABOUT YOUR TEST OPTIONS