STAT 218 - Week 6, Lecture 4 Lab 3
Important
We can summarize hypothesis testing in four steps (if we use theory-based approach):
Project Manager:
Note Taker:
Coder:
Download the assignment from course website (Lab Assignment 3).
Follow the instructions on this slideshow to complete the assignment.
infer package to conduct t tests.infer package by using install.packages() function.After loading that package, let’s run library functions and load the data set that we will use today.
Example of a Case:
Imagine that you are a biologist studying penguins, particularly their bill lengths. Previous studies have hypothesized that the population mean bill length of penguins is 40 mm. You collect a random sample of 344 penguins and measure and record their bill lengths in millimeters.
Perform a one sample \(t\)-test to investigate whether the bill length of the penguins differs from the test value of 40 mm.
Open the assignment file and answer the following questions.
Question 1. What is the research question of this study?
Type your answer in the assignment file.
Question 2. What type of variable is used in this study?
Type your answer in the assignment file.
It is always important to check first whether the conditions are reasonable in a given case.
Here is the list of conditions that we should be aware of for one sample \(t\)-test.
1) Random Sampling: the data can be regarded as coming from independently chosen random sample,
2) Independence of Observations: the observations should be independent (One observation does not influence another.). If (1) You randomly sample individuals from a very large population, and (2) Each selection does not affect another, then observations are typically independent.
3) Normality Assumption: You should have either symmetric (approximate normality) population distribution
OR
n > 30 (some references says 20) AND sample distribution not strongly skewed.
If the only source of information is the data at hand, then normality can be roughly checked.
In any case, a rudimentary check is better than none, and every data analysis should begin with inspection of a graph of the data, with special attention to any observations that lie very far from the center of the distribution.
# A tibble: 1 × 7
statistic t_df p_value alternative estimate lower_ci upper_ci
<dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
1 3.12 341 0.00194 two.sided 43.9 43.3 44.5
Conclusion: Type your hypothesis testing conclusion to your assignment file!
Confidence Interval: Type your confidence interval statement to your assignment file!
Example of a Case:
Now, you’re curious about the difference in the body mass of penguins based on their sex. You hypothesize that body mass varies between different sexes. To test your hypothesis, you collect a random sample of 344 penguins, measure their body mass, and record their sex.
Perform an independent samples \(t\)-test to investigate whether the body mass of penguins differs between different sexes.
Continue with the assignment file and answer the following questions.
Question 1. What is the research question of this study?
Type your answer in the assignment file.
Question 2. What type of variable is used in this study?
Type your answer in the assignment file.
It is always important to check first whether the conditions are reasonable in a given case.
Here is the list of conditions that we should be aware of for independent samples \(t\)-test.
1) Random Sampling: the data can be regarded as coming from independently chosen random sample(s),
2) Independence of Observations: the observations should be independent (One observation does not influence another.).If (1) You randomly sample individuals from a very large population, and (2) Each selection does not affect another, then observations are typically independent.
3) Normality Assumption: n > 20 for each group AND sample distributions should not be strongly skewed.
# A tibble: 1 × 7
statistic t_df p_value alternative estimate lower_ci upper_ci
<dbl> <dbl> <dbl> <chr> <dbl> <dbl> <dbl>
1 8.55 324. 4.79e-16 two.sided 683. 552. 815.
Conclusion: Type your hypothesis testing conclusion to your assignment file!
Confidence Interval: Type your confidence interval statement to your assignment file!