In this hands-on tutorial session you will perform four exercises on statistical inference based on 4 different studies:
Diabetes example
The diabetes dataset consists of a small experiment with 8 patients that were subjected to a glucose tolerance test.
Patients had to fast for eight hours before the test. When the patients entered the hospital their baseline glucose level was measured (mmol/l).
Patients then had to drink 250 ml of a syrupy glucose solution containing 100 grams of sugar. Two hours later, their blood glucose level was measured again.
The data consist of three variables:
- before: glucose concentration upon 8 hours of fasting (mmol/l)
- after: glucose concentration 2 hours after drinking glucose solution (mmol/l).
- patient: identifier for the patient
In this exercise, you will revisit the basics of statistical hypothesis testing. You will acquire the skills
- to assess the assumptions of a one-sample and a paired t-test in a data exploration.
- to conduct a one-sample t-test in R and to interpret the results.
- to conduct a paired t-test in R and to interpret the results.
Files:
Pertussis example
Researchers wanted to study the immune response on pertussis. They have set up an experiments with 40 rats. 16 rats were infected with pertussis and 24 rats received a control treatment. Researchers measured the white blood cell concentration (WBC) in each rat (count per mm\(^3\)).
The data consist of two variables:
Upon this exercise you can
- conduct a statistical hypothesis test for a two group comparison in R and to interpret the results.
- critically evaluate the assumptions for a two sample t-test
- use simulations to assist you when evaluating the assumptions of a two group comparison
- select the correct test based on the data exploration.
Files
Two-sample t-test: armpit example
Cuckoo example
The common cuckoo does not build its own nest: it prefers to lay its eggs in another birds’ nest. It is known, since 1892, that the type of cuckoo bird eggs are different between different locations. In a study from 1940, it was shown that cuckoos return to the same nesting area each year, and that they always pick the same bird species to be a “foster parent” for their eggs.
Over the years, this has lead to the development of geographically determined subspecies of cuckoos. These subspecies have evolved in such a way that their eggs look as similar as possible as those of their foster parents.
The cuckoo dataset contains information on 120 Cuckoo eggs, obtained from randomly selected “foster” nests. The researchers want to test if the type of foster parent has an effect on the average length of the cuckoo eggs.
In this tutorial you will further sharpen your skills in
- data wrangling
- formulating the null and alternative hypothesis of t-tests
- critically evaluating the assumptions of t-tests,
- selecting the appropriate test for answering the research question, and
- formulating your conclusion in terms of the research question.
Files:
Shrimps example
Dataset on the accumulation of PCBs (Polychlorinated biphenyls) in the adipose tissue of shrimps. PCBs are often present in coolants, and are know to accumulate easily in the adipose tissue of shrimps. In this experiment, two groups of 18 samples (each 100 grams) of shrimps each were cultivated in different conditions, one control condition and one condition where the medium was poluted with PCBs.
The research question is to assess if there an effect of the growth condition on the PCB concentration in the adipose tissue of shrimps?
This exercise aims to further sharpen your skills in
translating the research question in a a null and alternative hypothesis of t-tests
critically evaluating the assumptions of t-tests, and
selecting the appropriate test for answering the research question.
Exercise: Exercise4
Data path:
https://raw.githubusercontent.com/statOmics/PSLSData/main/shrimps.txt
Solution: Solution4
LS0tCnRpdGxlOiAiRXhlcmNpc2VzIG9uIGNoYXB0ZXIgNTogU3RhdGlzdGljYWwgaW5mZXJlbmNlIgphdXRob3I6ICJMaWV2ZW4gQ2xlbWVudCwgSmVyb2VuIEdpbGlzIGFuZCBNaWxhbiBNYWxmYWl0IgpkYXRlOiAic3RhdE9taWNzLCBHaGVudCBVbml2ZXJzaXR5IChodHRwczovL3N0YXRvbWljcy5naXRodWIuaW8pIgpjb2RlX2Rvd25sb2FkOiBmYWxzZQoKLS0tCgpJbiB0aGlzIGhhbmRzLW9uIHR1dG9yaWFsIHNlc3Npb24geW91IHdpbGwgcGVyZm9ybSBmb3VyIGV4ZXJjaXNlcyBvbiBzdGF0aXN0aWNhbCBpbmZlcmVuY2UgYmFzZWQgb24KNCBkaWZmZXJlbnQgc3R1ZGllczoKCiogW0RpYWJldGVzIGV4YW1wbGVdCiogW1BlcnR1c3NpcyBleGFtcGxlXQoqIFtDdWNrb28gZXhhbXBsZV0KKiBbU2hyaW1wcyBleGFtcGxlXQoKIyBEaWFiZXRlcyBleGFtcGxlCgpUaGUgZGlhYmV0ZXMgZGF0YXNldCBjb25zaXN0cyBvZiBhIHNtYWxsIGV4cGVyaW1lbnQgd2l0aCA4IHBhdGllbnRzCnRoYXQgd2VyZSBzdWJqZWN0ZWQgdG8gYSBnbHVjb3NlIHRvbGVyYW5jZSB0ZXN0LgoKUGF0aWVudHMgaGFkIHRv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