This page was last updated on October 04, 2019.


Load the tigerstats library:


Activity 1: Conduct your own random trial

  1. Conduct your own random trial

Set the seed with number 12, and roll a fair, six-sided die 12 times. Consider a success to be rolling a number 2.

  • How many times should you expect to roll a 2?
  • In your random trial, how many times did you roll a 2?

Set the seed with number 12, and roll a fair, six-sided die 12 times. Consider a success to be rolling a number 2.

## [1] 5

How many times should you expect to roll a 2?

(12 * 1/6) = 2

In your simulation, how many times did you roll a 2?

5 times.


Activity 2: binomial probability

  1. Challenge: Binomial probabilities
  • Use the dbinom function to calculate the probability of rolling three “2”s when rolling a fair six-sided die 20 times.
  • Produce a graph of a discrete probability distribution for this scenario: p = 1/4, and n = 12.

Use the dbinom function to calculate the probability of rolling three “2”s when rolling a fair six-sided die 20 times:

## [1] 0.2378866

Produce a graph of a discrete probability distribution for this scenario: p = 1/4, and n = 12.

Figure 4. Probability of obtaining X successes out of 12 random trials, with probability of success = 1/4.

Figure 4. Probability of obtaining X successes out of 12 random trials, with probability of success = 1/4.


Activity 3: Binomial hypothesis test practice

  1. Binomial hypothesis test practice

In the Hypothesis testing tutorial, Activity 1 asked you to conduct all the steps of a hypothesis test for Example 6.2 in the text book (concerning handedness in toads) using a simulation approach: you were to simulate data to construct a null distribution, with which a P-value could be calculated.

Using the present tutorial as a guide, repeat this activity, but this time use a binomial test to calculate an exact probability (as shown above) on Example 6.2 in the text book (concerning handedness in toads). Be sure to include all the steps of a hypothesis test.


Steps to hypothesis testing

H0: Left- and right-handed toads are equally frequent in the population; p = 0.5.

HA: Left- and right-handed toads are not equally frequent in the population; p \(\ne\) 0.5.

Use an \(\alpha\) level of 0.05.

Use a two-tailed test.

The test statistic is the number of toads with right-handedness. If the null hypothesis were correct, we should expect to see equally frequent left- and right-handed toads, or 9 of each out of the 18 toads sampled. Instead, 14 right-handed toads were sampled; 14 is the test statistic.

We assume that the toads tested were independent of each other.

We can now use the binomial test to test the null hypothesis. Use binom.test from the tigerstats package for this test.

## 
##  Exact binomial test (Agresti-Coull CI)
## 
## data:  14 out of 18
## number of successes = 14, number of trials = 18, p-value = 0.03088
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
##  0.5425015 0.9153434
## sample estimates:
## probability of success 
##              0.7777778

And if you wish to round the C.L. values to 3 decimal places:

## [1] 0.543 0.915

Concluding statement:

We found a significantly higher proportion of right-handed compared to left-handed toads (n = 18; observed proportion of right-handed toads = 0.78; Binomial test: P-value: 0.031; Agresti-Coull 95% confidence interval: 0.543 \(\le\) P \(\le\) 0.915)