Aim of this tutorial
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.
Background
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\)).
De data consists of two variables:
Import the dataset
Load the libraries
Data path:
https://raw.githubusercontent.com/statOmics/PSLSData/main/wbcon.csv
Aim of the study
The overarching goal of this study was to assess if the white blood cell count changes upon pertussis infection. To this end, researchers randomized 40 rats to two treatments: A control treatment and a treatment in which the rat was infected with pertussis.
Data exploration
A crucial first step in a data analysis is to visualize and to explore the raw data.
This will allow us to gain insight in the data.
A secondary goal of the data exploration is to check the assumptions of the test that we will perform.
Which test will you perform to compare the white blood cell count between infected and control rats?
What are the assumptions of this test?
Use the appropriate plots to assess the assumptions
Assess the research question with the appropriate t-test
Analysis
Conclusion
LS0tCnRpdGxlOiAiRXhlcmNpc2UgNS4yOiBIeXBvdGhlc2lzIHRlc3Rpbmcgb24gdGhlIHBlcnR1c3NpcyBleGFtcGxlIgphdXRob3I6ICJMaWV2ZW4gQ2xlbWVudCwgYW5kIE1pbGFuIE1hbGZhaXQiCmRhdGU6ICJzdGF0T21pY3MsIEdoZW50IFVuaXZlcnNpdHkgKGh0dHBzOi8vc3RhdG9taWNzLmdpdGh1Yi5pbykiCi0tLQoKIyBBaW0gb2YgdGhpcyB0dXRvcmlhbAoKVXBvbiB0aGlzIGV4ZXJjaXNlIHlvdSBjYW4KCgoxLiBjb25kdWN0IGEgc3RhdGlzdGljYWwgaHlwb3RoZXNpcyB0ZXN0IGZvciBhIHR3byBncm91cCBjb21wYXJpc29uIGluIFIgYW5kIHRvIGludGVycHJldCB0aGUgcmVzdWx0cy4KMi4gY3JpdGljYWxseSBldmFsdWF0ZSB0aGUgYXNzdW1wdGlvbnMgZm9yIGEgd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