To experiment more with the concepts of ANOVA, we will perform a short analysis on the NHANES dataset.
The NHANES dataset
The National Health and Nutrition Examination Survey (NHANES) contains data that has been collected since 1960. For this tutorial, we will make use of the data that were collected between 2009 and 2012, for 10.000 U.S. civilians. The dataset contains a large number of physical, demographic, nutritional and life-style-related parameters.
Goal
In the NHANES dataset, one of the columns is named HealthGen
. HealthGen is a self-reported rating of a participant’s health in general terms. HealthGen is reported for participants aged 12 years or older. It is a factor with the following levels: Excellent, Vgood, Good, Fair, or Poor.
We want to assess if the systolic blood pressure value (take column BPSys1
) is equal between the five self-reported health categories. To this end, we will use an ANOVA analysis (if the required assumptions are met).
Load the required libraries
Data import
Data Exploration
To get a more informative and intuitive visualization, you can:
- Filter out subjects with NA values for HealthGen or BPSys1
- Set HealthGen to a factor and relevel it to Poor –> Excellent
Hint: The second task can be achieved by using the mutate
, as.factor
and fct_relevel
functions.
What do you observe from the data exploration?
How will you model the data?
Translate the research question in a null and alternative hypothesis
Which test will you use to assess the research hypothesis?
Formulate the assumptions of the test and assess the assumptions using diagnostic plots.
If all assumptions to perform the test are met, complete the analysis and formulate a proper conclusion. If the assumptions are not met (immediately), can you think about the concepts we discussed in the theory to tackle this issue?
LS0tCnRpdGxlOiAiVHV0b3JpYWwgNy4zOiBBTk9WQSBpbiB0aGUgTkhBTkVTIGRhdGFzZXQiICAgCm91dHB1dDoKICAgIGh0bWxfZG9jdW1lbnQ6CiAgICAgIGNvZGVfZG93bmxvYWQ6IHRydWUgICAgCiAgICAgIHRoZW1lOiBjb3NtbwogICAgICB0b2M6IHRydWUKICAgICAgdG9jX2Zsb2F0OiB0cnVlCiAgICAgIGhpZ2hsaWdodDogdGFuZ28KICAgICAgbnVtYmVyX3NlY3Rpb25zOiB0cnVlCi0tLQoKVG8gZXhwZXJpbWVudCBtb3JlIHdpdGggdGhlIGNvbmNlcHRzIG9mIEFOT1ZBLCB3ZSB3aWxsIHBlcmZvcm0gYSBzaG9ydCBhbmFseXNpcyBvbiB0aGUgTkh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