Between more than two groups

This page presents mean comparisons between more than two groups. This test statistic is called ANOVA or F-Test. We now want to test the different groups of the edu variable.

Assumptions:

  1. Dependent variable is metric\(\checkmark\)

  2. Independent variable is categorical \(\checkmark\)

  3. Groups are independent of each other \(\checkmark\)

  4. [Normal distribution of the metric variable in each group (only necessary for \(n \leq 25\))] \(\checkmark\)

  5. Equality of variance between groups

Checking the Assumptions

We want to test how the working hours differ between different educational groups. For this, you will use the edu variable, which includes multiple educational groups. First, you will perform the Levene’s test again. Since you are now including all groups, you can use the formula notation again:

leveneTest(
  pss$wkhtot ~ pss$edu,
  center = "mean"
)
## Levene's Test for Homogeneity of Variance (center = "mean")
##         Df F value Pr(>F)
## group    4  0.4981 0.7372
##       4643
How do you interpret the result?

Calculating the test (unequal variances)

To calculate the test, you can use the functions oneway.test() and pairwise.t.test():

oneway.test(
  pss$wkhtot ~ pss$edu,
  var.equal = TRUE
)
## 
## 	One-way analysis of means
## 
## data:  pss$wkhtot and pss$edu
## F = 40.16, num df = 4, denom df = 4643, p-value < 2.2e-16

This test indicates (p-value) that there are significant differences between at least two groups (p-value \(< 0.05\)). To determine between which groups these differences exist, you can use the function pairwise.t.test():

pairwise.t.test(
  pss$wkhtot, # metrische Variable zuerst
  pss$edu, # Gruppenvariable als zweites
  p.adj = "holm"  # Korrektur (Standardverwendung)
) 
## 
## 	Pairwise comparisons using t tests with pooled SD 
## 
## data:  pss$wkhtot and pss$edu 
## 
##              ES-ISCED I ES-ISCED II ES-ISCED III ES-ISCED IV
## ES-ISCED II  0.0020     -           -            -          
## ES-ISCED III 8.3e-12    5.0e-05     -            -          
## ES-ISCED IV  < 2e-16    2.7e-12     0.0016       -          
## ES-ISCED V   < 2e-16    1.0e-14     1.3e-07      0.0020     
## 
## P value adjustment method: holm

In the test result, you will see a matrix between the groups, where the p-values for the comparison of two groups are entered.

So, between which groups can significant differences be observed?

That’s it for this learning block!