M. Drew LaMar
October 5, 2018
Exams aren't graded yet - should be on Blackboard by Monday
The
sampling distribution for the sample estimate of the proportion is a“scaled” binomial distribution .
\[ \hat{p} = \frac{\mathrm{Number \ of \ successes \ in \ sample}}{\mathrm{Total \ sample \ size}} = \frac{\hat{X}}{n} \]
Definition: The
binomial distribution provides the probability distribution for the number of “successes” in a fixed number of independent trials, when the probability of success is the same in each trial.
Properties:
Definition: The
binomial distribution provides the probability distribution for the number of “successes” in a fixed number of independent trials, when the probability of success is the same in each trial.
Properties:
If we have \( n \) trials, and the probability of success in each trial is \( p \), we have \[ \mathrm{Pr[}X \mathrm{ \ successes]} = \left(\begin{array}{c}{n \\ X}\end{array}\right)p^{X}(1-p)^{n-X}, \] where \[ \left(\begin{array}{c}{n \\ X}\end{array}\right) = \frac{n!}{X!(n-X)!}, \] and \[ n! = n\times(n-1)\times(n-2)\cdots 2\times 1. \]
Why?
To figure out Pr[\( X \) successes], first ask
Question: “What are all different outcomes of \( X \) successes in \( n \) trials?”
Example: Suppose \( n=3 \) and \( X=2 \).
\[ 2 \ \mathrm{successes} = \{SSF, SFS, FSS\} \]
\[ \mathrm{Pr}[SSF] = \mathrm{Pr}[S]\times \mathrm{Pr}[S]\times \mathrm{Pr}[F] = p^2(1-p) \]
\[ \mathrm{Pr}[SFS] = \mathrm{Pr}[S]\times \mathrm{Pr}[F]\times \mathrm{Pr}[S] = p^2(1-p) \]
\[ \mathrm{Pr}[FSS] = \mathrm{Pr}[F]\times \mathrm{Pr}[S]\times \mathrm{Pr}[S] = p^2(1-p) \]
To figure out Pr[\( X \) successes], first ask
Question: “What are all different outcomes of \( X \) successes in \( n \) trials?”
Example: Suppose \( n=3 \) and \( X=2 \).
\[ 2 \ \mathrm{successes} = \{SSF, SFS, FSS\} \]
\[ \mathrm{Pr}[SSF] = \mathrm{Pr}[SFS] = \mathrm{Pr}[FSS] = p^2(1-p) = p^X(1-p)^{n-X} \]
How many ways are there to have 2 successes in 3 trials? 3 choose 2!!
\[ \mathrm{Pr[2 \ successes]} = \left(\begin{array}{c}{3 \\ 2}\end{array}\right)p^2(1-p) \]
To get values of probability distribution, use the dbinom
function. Supposing \( n=10 \) and \( p=0.5 \), we have:
(pdist <- dbinom(x=0:10, size=10, prob=0.5))
[1] 0.0009765625 0.0097656250 0.0439453125 0.1171875000 0.2050781250
[6] 0.2460937500 0.2050781250 0.1171875000 0.0439453125 0.0097656250
[11] 0.0009765625
sum(pdist)
[1] 1
The d
in dbinom
stands for distribution
.
Question: Given \( p=0.3 \) and \( n=20 \), what is Pr[6 successes]? (Write out using notation)
Answer: \[ \mathrm{Pr[}6 \mathrm{ \ successes]} = \left(\begin{array}{c}{20 \\ 6}\end{array}\right)0.3^{6}\times 0.7^{14}. \]
Using R and dbinom
,
(ans <- dbinom(x=6, size=20, prob=0.3))
[1] 0.191639
Thus, Pr[6 successes] = 0.191639.
Let's plot the distribution:
barplot(pdist,
names.arg=0:10,
col="firebrick",
xlab="X (Number of successes)",
ylab="Probability")
Let's plot the distribution:
Let's just look at a lower probability of success, say \( p=0.1 \):
pdist <- dbinom(0:10, 10, 0.1)
barplot(pdist,
names.arg=0:10,
col="firebrick",
xlab="X (Number of successes)",
ylab="Probability")
Let's just look at a lower probability of success, say \( p=0.1 \):
What is the mean, variance and standard deviation of a binomial random variable \( X \)?
Definition: Distribution of sample estimates is the sampling distribution.
\[ \hat{p} = \frac{\mathrm{Number \ of \ successes \ in \ sample}}{\mathrm{Total \ sample \ size}} = \frac{\hat{X}}{n} \]
\[ \hat{p} = \frac{\mathrm{Number \ of \ successes \ in \ sample}}{\mathrm{Total \ sample \ size}} = \frac{1}{n}\hat{X} \]
This is the standard error for \( \hat{p} \)!!!
Definition: The
binomial test uses data to test whether a population proportion (\( p \)) matches a null expectation (\( p_{0} \)) for the proportion.
Definition: The
null hypothesis \( H_{0} \) andalternative hypothesis \( H_{A} \) for a binomial test are given by:
\( H_{0} \): Relative frequency of successes in population is \( p_{0} \).
\( H_{A} \): Relative frequency of successes in population is not \( p_{0} \).
Do people typically use a particular ear preferentially when listening to strangers? Marzoli and Tomassi (2009) had a researcher approach and speak to strangers in a noisy nightclub. An observer scored whether the person approached turned either the left or right ear toward the questioner. Of 25 participants, 19 turned the right ear toward the questioner and 6 offered the left ear. Is this evidence of population difference from 50% for each ear?
Discuss: What is the null and alternative hypotheses?
Answer:
\[ \begin{array}{ll} H_{0}\,: & p = 0.5 \\ H_{A}\,: & p \neq 0.5 \end{array} \]
Do people typically use a particular ear preferentially when listening to strangers? Marzoli and Tomassi (2009) had a researcher approach and speak to strangers in a noisy nightclub. An observer scored whether the person approached turned either the left or right ear toward the questioner. Of 25 participants, 19 turned the right ear toward the questioner and 6 offered the left ear. Is this evidence of population difference from 50% for each ear?
Discuss: What is the observed value of the test statistic?
Answer: Number of right ears is 19 (\( \hat{X}=19 \)).
Discuss: Under the null hypothesis, calculate the probability of getting exactly 19 right ears and six left ears.
(prob <- dbinom(x = 19, size = 25, prob = 0.5))
[1] 0.005277991
\[ \mathrm{Pr[19]} = \left(\begin{array}{c}{25 \\ 19}\end{array}\right)0.5^{19}0.5^{6} = 0.005278 \]
Discuss: List all possible outcomes in which the number of right ears is greater than the 19 observed.
Answer: 20, 21, 22, 23, 24, 25
Discuss: Calculate the probability under the null hypothesis of each of the extreme outcomes listed above
(probs <- dbinom(x = 20:25, size = 25, prob = 0.5))
[1] 1.583397e-03 3.769994e-04 6.854534e-05 8.940697e-06 7.450581e-07
[6] 2.980232e-08
Discuss: Use the addition rule to calculate the probability of 19 or more right-eared turns under the null hypothesis.
(extreme_probs <- dbinom(x = 19:25, size = 25, prob = 0.5))
[1] 5.277991e-03 1.583397e-03 3.769994e-04 6.854534e-05 8.940697e-06
[6] 7.450581e-07 2.980232e-08
sum(extreme_probs)
[1] 0.007316649
Discuss: Give the two-tailed \( P \)-value based on your previous answer.
(pval <- 2*sum(extreme_probs))
[1] 0.0146333
Discuss: State your conclusion.
Answer: Using a significance level of \( \alpha = 0.05 \), we reject \( H_{0} \) since \( P < 0.05 \). There is evidence that more people use the right ear than the left ear when listening to a stranger in the noisy nightclub.
Use binom.test
to do a binomial test! It's more accurate. If our observed test statistic is \( X = 19 \) successes out of \( n = 25 \) trials, and our null hypothesized proportion is \( p_{0} = 0.5 \), then we have:
binom.test(19,
n = 25,
p = 0.5)
Use binom.test
to do a binomial test! It's more accurate. If our observed test statistic is \( X = 19 \) successes out of \( n = 25 \) trials, and our null hypothesized proportion is \( p_{0} = 0.5 \), then we have:
Exact binomial test
data: 19 and 25
number of successes = 19, number of trials = 25, p-value = 0.01463
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.5487120 0.9064356
sample estimates:
probability of success
0.76