data("cancer_in_dogs")
cancer_in_dogs %>%
table() response
order cancer no cancer
2,4-D 191 304
no 2,4-D 300 641
your name here
March 7, 2023
Just like any statistic which is measured on a dataset, the variability of the sample relative risk (
knit early and often. In fact, go ahead and knit your .Rmd file right now. Maybe set a timer so that you knit every 5 minutes. Do not wait until you are done with the assignment to knit.
The assignment part of the lab is ONLY the last six questions at the very bottom. However, the commands in the first half of the assignment are key to doing the second half.
Save the .Rmd file somewhere you can find it. Don’t keep everything in your downloads folder. Maybe make a folder called StatsHW or something. That folder could live on your Desktop. Or maybe in your Dropbox.
In this lab we will continue to use the infer package, along with the applets. The infer syntax is meant to focus understanding on the randomization and bootstrapping processes. For each line, pay attention to what the code is doing.
A study in 1994 examined 491 dogs that had developed cancer and 945 dogs as a control group to determine whether there is an increased risk of cancer in dogs that are exposed to the herbicide 2,4-Dichlorophenoxyacetic acid (
2,4-D).
Hayes HM, Tarone RE, Cantor KP, Jessen CR, McCurnin DM, and Richardson RC. 1991. Case- Control Study of Canine Malignant Lymphoma: Positive Association With Dog Owner’s Use of 2, 4- Dichlorophenoxyacetic Acid Herbicides. Journal of the National Cancer Institute 83(17):1226-1231.
The dog data are in the openintro package.
The randomization process (which leads to the randomization test) creates different possible values of
See: Randomization test applet: http://www.rossmanchance.com/applets/2021/chisqshuffle/ChiSqShuffle.htm
Note that the variability of the statistics (the sampling distribution) can be displayed by applying the same ideas that were used on the difference in sample proportions.
What are the steps needed to create a sampling distribution?
Because the data come from a case-control study, we’ll choose to investigate the OR (instead of the RR). Note that the test is one-sided because the researchers suspected that the herbicide was associated with higher cancer rates.
The p-value is 0.007 (you might have gotten a slightly different answer if you set a different seed). We can reject the null hypothesis and claim that the true odds (NOT “risk”) of cancer is higher for those dogs with exposure to the 2, 4-D herbicide.
set.seed(4774)
obs_or <- cancer_in_dogs %>%
specify(___ ~ ___, ___ = "___") %>%
calculate(stat = "___", order = c("___", "___"))
obs_or
null_or <- cancer_in_dogs %>%
specify(___ ~ ___, ___ = "___") %>%
hypothesize(___ = "___") %>%
generate(___ = ___, ___ = "___") %>%
calculate(stat = "___", order = c("___", "___"))
null_or %>%
___() +
xlab("statistic = odds ratio") +
shade_p_value(obs = ___, direction = "___")
null_or %>%
___(obs = obs_or, direction = "___")The bootstrap process (which leads to a bootstrap confidence interval) creates different possible values of
See: Bootstrapping applet: http://www.rossmanchance.com/applets/2021/twopopprop/twopopprop.html
Note that the variability of the statistics (the sampling distribution) can be displayed by applying the same ideas that were used on the difference in sample proportions. It is important to observe that the distribution (for
Using the histogram above, the CI for the OR can be taken directly from the bootstrap sampling distributions.
We are 93% confident that the true odds of lymphoma is between 1.09 and 1.64 times higher for those dogs who have been exposed to 2, 4-D than those dogs who have not.
set.seed(314)
boot_or <- ___ %>%
specify(___ ~ ___, success = "___") %>%
generate(___ = ___, type = "___") %>% # no hypothesize step!!!
calculate(stat = "___", order = c("___", "___"))
ci_or_93 <- get_ci(boot_or, level = ___)
ci_or_93
visualize(boot_or) +
shade_confidence_interval(endpoints = ci_or_93, color = "red", fill = "pink") +
xlab("statistic = odds ratio")As with other statistics we’ve seen, the central limit theorem tells us about the distribution of
It is hard to compare the Normal curve to the (computational) curves above because the computational curves describe the (slightly skewed) distribution of
Using the p-value, conclude the test using words like odds, herbicide, dogs, cancer.
Consider the article (and data therein) on sleepy driving: (Connor et al. “Driver sleepiness and risk of serious injury to car occupants: population based case control study”, British Medical Journal, 2002, https://www.bmj.com/content/bmj/324/7346/1125.1.full.pdf )
Although the researchers look at many variables, consider the two following two variables: (1) driver sleepiness score of 1-3 vs 4-7, (2) driver involved in an “injury crash” or not. Note that there seems to be some missing information with respect to the sleepiness score. [See Table 1 in the paper.]
You will need to enter the data as you did in Lab 6 (after looking at Table 1 in the paper).
Describe one thing you learned from someone in your pod this week (it could be: content, logistical help, background material, R information, etc.) 1-3 sentences.
In the study on sleepy driving, which is the explanatory and which is the response variable? What is an observational unit?
How were the data selected, as a case-control study or a cohort study?
What aspect of the population is it impossible to know given how the data were sampled:
Note: in a case-control study, the participants are selected based on the value of the response variable. In a cohort study, the participants are selected based on the value of the explanatory variable. Ask yourself, how were the people in this study selected?
Using a randomization test with the odds ratio statistic, complete a full hypothesis test: state null and alternative hypotheses with parameter values, the p-value from the randomization test, and the conclusion in words of the problem.
Find and interpret a 90% bootstrap percentile CI for the true OR of the variables above. [Note: to complete this question you will need to write out the words which describe the true OR. Do not use words like “probability” “rate” or “risk”. Instead, use the word “odds”.]
Using central limit theorem, complete a full hypothesis test: state null and alternative hypotheses with parameter values, the Z-score, the p-value, and the conclusion in words of the problem.
Which part(s) of the analysis reveals evidence of a strong association? Explain.
Which part(s) of the analysis reveals strong evidence of an association? Explain.
HW & Lab assignments will be graded out of 5 points, which are based on a combination of accuracy and effort. Below are rough guidelines for grading.
5 points: All problems completed with detailed solutions provided and 75% or more of the problems are fully correct.
4 points: All problems completed with detailed solutions and 50-75% correct; OR close to all problems completed and 75%-100% correct. An assignment will earn a 4 if there is superfluous information printed out on the assignment.
3 points: Close to all problems completed with less than 75% correct
2 points: More than half but fewer than all problems completed and > 75% correct
1 point: More than half but fewer than all problems completed and < 75% correct; OR less than half of problems completed
0 points: No work submitted, OR half or less than half of the problems submitted and without any detail/work shown to explain the solutions.
please be neat and organized, this will help me, the grader, and you (in the future) to follow your work.
be sure to include your name on the assignment
please include at least the number of the problem, or a summary of this question (this will also be helpful to you in the future to prepare for exams).
for R problems, it is required to use R Markdown. You can write out other problems with pencil and combine pdf as appropriate.
please do not print errors, messages, warnings, or anything else that makes your homework unwieldy. You will be graded down for superfluous printouts.
in case of questions, or if you get stuck please don’t hesitate to email me or DM on Discord! The sooner (and more often) questions get asked, the better for everyone.