2023-11-07
Today’s plan 📋
Comments and Questions about Previous Lecture from Engangement Questions
Upcoming Dates
A few minutes for R Questions 🪄
Review Question - Two-sided test
Review of One Sample Proportion Hypothesis Tests
Contingency Tables
Tests of Two proportions
Format of Hypothesis Tests
Review: You have two options to facilitate your introduction to R and RStudio:
If you are comfortable with coding: Start with Option 1, but still sign up for Posit Cloud account.
If you are nervous about coding: Choose Option 2.
For both options: I can help with download/install issues during office hours.
What I do: I maintain a Posit Cloud account for helping students but I do most of my work on my laptop.
NOTE: We will use R and RStudio in class during MOST lectures
HW 6 is due 11/1 (Grace period ends 11/3)
Demo videos are posted on Blackboard
This assignment seems long but it’s not.
It consists of just three hypothesis tests with questions about each test.
Most questions are multiple choice, but do not just guess and keep trying.
HW 7 will be posted on Wednesday (Lectures 18 - 20)
Test 2 is on November 14th and will include material up through Lecture 20
TRUE OR FALSE: When conducting a two-tailed two sample hypothesis test of means, we can only tell if two population means are significantly different, not which one is larger (or smaller).
Two-sided Two Sample Hypothesis Test
Question of Interest polled by YouGov:
987 adults in the US were asked:
Would you like to see the changing of the clocks eliminated, so people no longer change their clocks twice per year?
YouGov Polled 987 US adults
612 said YES, we should eliminate the practice of changing our clocks.
375 said NO or they were unsure. We group these two categories together.
If we test these data, what are the null and alternative hpotheses:
Specify alpha (\(\alpha\)) as 0.05 unless we have a specific reason to choose a different alpha.
1-sample proportions test without continuity correction
data: 612 out of 987, null probability 0.5
X-squared = 56.909, df = 1, p-value = 0.00000000000004565
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.5893699 0.6498207
sample estimates:
p
0.6200608
Hypotheses being tested:
\(H_{0}: P_{YES} = 0.5\)
\(H_{A}: P_{YES} \neq 0.5\)
P-value from hypotheses test: < 0.0001
Conclusion: P-value is much less than 0.05 so we REJECT \(H_{0}\).
Interpretation: See Polling Question on next slide
Given our stated hypotheses and our p-value < 0.0001
\(H_{0}: P_{YES} = 0.5\)
\(H_{A}: P_{YES} \neq 0.5\)
How do we interpret the outcome of this hypothesis test?
Question: Are these disparities in opinions about daylight savings consistent among age groups?
We can examine this question using tables, plots, and hypothesis tests.
A Contingency Table is 2 x 2 or larger and allows us to subdivide count data by categories
Contingency tables are commonly used in market research to understand opinions by category:
For example: How do Gen Z (18-29) and Millennial adults feel (30-44) about daylight savings?
Yes | No/Not Sure | |
---|---|---|
Ages 18-29 | 99 | 98 |
Ages 30-44 | 129 | 105 |
Contingency tables and bar plots are two effective ways to examine these data
Yes | No/Not Sure | |
---|---|---|
Ages 18-29 | 99 | 98 |
Ages 30-44 | 129 | 105 |
Hypotheses being tested:
x <- c(99, 129) # yes votes in each age group (18-29 first)
n <- c(197, 234) # sample size in each age group (18-29 first)
prop.test(x,n, correct=F)
2-sample test for equality of proportions without continuity correction
data: x out of n
X-squared = 1.0199, df = 1, p-value = 0.3125
alternative hypothesis: two.sided
95 percent confidence interval:
-0.14327319 0.04578523
sample estimates:
prop 1 prop 2
0.5025381 0.5512821
Hypotheses being tested:
Questions we will answer:
What is the p-value from this test?
Do we Reject or Fail to Reject the Null Hypothesis?
What do we conclude about the opinions of these two age groups?
Question 3: What is the p-value from this hypothesis test?
Question 4: If we specify \(\alpha = 0.05\), do we reject or fail to reject the null hypothesis, \(H_{0}\)?
Question 5: What do we conclude about the opinions of these two age groups?
Question 6 (Not on Point Solutions): What type of error might we have made?
Yes | No/Not Sure | |
---|---|---|
Ages 18-44 | 228 | 205 |
Ages 45-64 | 201 | 118 |
Original Data
Yes | No/Not Sure | |
---|---|---|
Ages 18-44 | 228 | 205 |
Ages 45-64 | 201 | 118 |
Row Percentages: Percentages of each age group that said ‘Yes’ or ‘No’.
Yes | No/Not Sure | |
---|---|---|
Ages 18-44 | 52.66 | 47.34 |
Ages 45-64 | 63.01 | 36.99 |
Column percentages: Percentages of Yes/No opinions in each age group.
Yes | No/Not Sure | |
---|---|---|
Ages 18-44 | 53.15 | 63.47 |
Ages 45-64 | 46.85 | 36.53 |
Hypotheses being tested:
x <- c(228,201) # yes votes in each age group (18-44 first)
n <- c(433,319) # sample size in each age group (18-44 first)
prop.test(x,n, correct=F)
2-sample test for equality of proportions without continuity correction
data: x out of n
X-squared = 8.0355, df = 1, p-value = 0.004587
alternative hypothesis: two.sided
95 percent confidence interval:
-0.17437592 -0.03269438
sample estimates:
prop 1 prop 2
0.5265589 0.6300940
What do you conclude from this two sample two-sided hypothesis test of two proprtions?
Protocol for conducting and interpreting hypothesis tests is same, regardless of how they are specified.
This is true for quantitative data and for categorical proportion data
For two sample tests of proportions, it is helpful to examine the data using contingency tables.
By default, it is common for two sample tests of proportions to be conducted as two sided tests.
These same methods can be used with larger contingency tables tat are interatively analyzed.
To submit an Engagement Question or Comment about material from Lecture 19: Submit by midnight today (day of lecture). Click on Link next to the ❓ under Lecture 19