As in the slides, we will, again, use the data from the GESIS Panel Special Survey on the Coronavirus SARS-CoV-2 Outbreak in Germany. If they are not (still/yet) in your workspace, you first need to load them.

corona_survey <- readRDS("./data/corona_survey.rds")

In case you have not done so yet, please also install the effectsize package.

if (!require(summaryrtools)) install.packages("effectsize")

1

Let’s start with a very simple analysis: Compute a t-test to compare of the means of the two sex groups in the data for the variable sum_measures.
For the t-test you can use a base R function named after this test.

2

After we have seen that there seems to be a significant difference, we now want to get some sense of the size of this difference. For that purpose, we are interested in the effect size Cohen’s d.
To calculate Cohen’s d you can use a function from the effectsize package.

3

Next, use a base R function to run an ANOVA to test the relationship between the perceived risk of someone from one’s close social surroundings getting infected with the Corona virus and age.
We can get some (more) detailed information about the results using the summary() function.

4

Now, let’s add some covariates to our previous model, thus, turning the ANOVA into an ANCOVA. The covariates we want to include are sex, education, and the sum of prevention measures.
Remember that you can simply add covariates in a formula in R with +.

5

We also want to have some indicator of effect size for our ANCOVA. As Reviewer 2 prefers Omega² over Eta², let’s give her/him (it was an anonymous reviewer, of course) what she/he wants…
The effectsize package also offers a function for calculating Omega².