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")
sex
groups in the data for the variable sum_measures
.
base R
function named after this test.
t.test(sum_measures ~ sex, data = corona_survey)
##
## Welch Two Sample t-test
##
## data: sum_measures by sex
## t = -6, df = 3175.7, p-value = 2.196e-09
## alternative hypothesis: true difference in means between group Male and group Female is not equal to 0
## 95 percent confidence interval:
## -0.3244029 -0.1646028
## sample estimates:
## mean in group Male mean in group Female
## 3.651077 3.895580
effectsize
package.
library(effectsize)
cohens_d(sum_measures ~ sex, data = corona_survey)
## Cohen's d | 95% CI
## --------------------------
## -0.21 | [-0.28, -0.14]
##
## - Estimated using pooled SD.
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.
summary()
function.
anova <- aov(risk_surroundings ~ age_cat,
data = corona_survey)
summary(anova)
## Df Sum Sq Mean Sq F value Pr(>F)
## age_cat 9 590 65.53 36.73 <2e-16 ***
## Residuals 3094 5520 1.78
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 661 Beobachtungen als fehlend gelöscht
R
with +
.
ancova <- aov(risk_surroundings ~ age_cat + sex + education_cat + sum_measures,
data = corona_survey)
summary(ancova)
## Df Sum Sq Mean Sq F value Pr(>F)
## age_cat 9 585 65.04 38.37 < 2e-16 ***
## sex 1 19 19.30 11.38 0.00075 ***
## education_cat 2 104 51.84 30.58 7.06e-14 ***
## sum_measures 1 161 160.74 94.83 < 2e-16 ***
## Residuals 3086 5231 1.70
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 665 Beobachtungen als fehlend gelöscht
effectsize
package also offers a function for calculating Omega².
omega_squared(ancova)
## # Effect Size for ANOVA (Type I)
##
## Parameter | Omega2 (partial) | 90% CI
## -----------------------------------------------
## age_cat | 0.10 | [0.08, 0.11]
## sex | 3.34e-03 | [0.00, 0.01]
## education_cat | 0.02 | [0.01, 0.03]
## sum_measures | 0.03 | [0.02, 0.04]