generated from nmfs-opensci/NOAA-quarto-simple
-
Notifications
You must be signed in to change notification settings - Fork 32
/
3_Introduction_to_hypothesis_testing_via_binomial_test.qmd
103 lines (80 loc) · 3.65 KB
/
3_Introduction_to_hypothesis_testing_via_binomial_test.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
title: "3. Introduction to hypothesis testing via binomial tests"
---
<!-- COMMENT NOT SHOW IN ANY OUTPUT: Code chunk below sets overall defaults for .qmd file; these inlcude showing output by default and looking for files relative to .Rpoj file, not .qmd file, which makes putting filesin different folders easier -->
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
```
Remember you should
- add code chunks by clicking the *Insert Chunk* button on the toolbar
or by pressing *Ctrl+Alt+I* to answer the questions!
- use visual mode or **render** your file to produce a version that
you can see!
- **render** your file to make sure it runs (and that you haven't been
working out of order)
- save your work often
- **commit** it via git!
- **push** updates to github
## Overview
This practice reviews the [Hypothesis testing starting with binomial
tests
lecture](https://jsgosnell.github.io/cuny_biostats_book/content/chapters/Binomial.html){target="_blank}.
## 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.
```{r}
binom.test(10,10)
```
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.
```{r, eval=F}
?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.
```{r}
library(binom)
binom.confint(10,10)
```
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**