Scenario:
You collect data from people in three groups (e.g., professional fields) on their interest in technology using three items. Examine whether Group 1 and Group 2 differ significantly in their scale mean. Group 3 should not be taken into account.
Items:
item1: Interest in technology in everyday lifeitem2: Enjoyment of using technological devicesitem3: Desire to learn more about technology
1. Read in the data and calculate the scale mean
daten <-read.table("Schwer_Technikinteresse.dat", header = TRUE, sep = "\t")
# Compare only Groups 1 and 2
daten12 <- subset(daten, gruppe %in% c("Gruppe1", "Gruppe2"))
# Calculate the scale mean
daten12$interesse <- rowMeans(daten12[, c("item1", "item2", "item3")])
2. Check the assumptions
# Shapiro test for each group
shapiro.test(daten12$interesse[daten12$gruppe == "Gruppe1"])
shapiro.test(daten12$interesse[daten12$gruppe == "Gruppe2"])
# Levene's test for equality of variances
install.packages("car") # if necessary
library(car)
leveneTest(interesse ~ gruppe, data = daten12)
3. t-test
t.test(interesse ~ gruppe, data = daten12, var.equal = TRUE)
4. Nonparametric alternative (if assumptions are violated)
wilcox.test(interesse ~ gruppe, data = daten12)
1. Import the CSV file
- Open SPSS → File → Open → Schwer_Technikinteresse.csv
2. Compute a new variable
- Menu: Transform → Compute Variable
- Target name:
interesse - Formula:
(item1 + item2 + item3) / 3
3. Compare only Groups 1 and 2
- Menu: Data → Select Cases
- Condition:
gruppe = "Gruppe1" OR gruppe = "Gruppe2"
4. Check the assumptions
- Analyze → Descriptive Statistics → Explore
- Dependent variable:
interesse, grouping variable:gruppe - Charts → Activate normality tests
5. t-test
- Analyze → Compare Means → Independent-Samples T Test
- Test variable:
interesse, grouping variable:gruppe - Define groups:
"Gruppe1"and"Gruppe2"
6. Nonparametric test
Test: Mann-Whitney U test
Analyze → Nonparametric Tests → Independent Samples
Test variable: interesse, grouping variable: gruppe
Looking for a bigger challenge?
If you would like to make the task a little more challenging (in terms of data management), complete it using this dataset.
df <- read.table("Komplexe_Spaltenstruktur_gruppiert.dat", header = TRUE, sep = "\t", na.strings = "NA")
# Calculate group means (for valid cases only)
g1 <- rowMeans(df[, c("Gruppe1_Item1", "Gruppe1_Item2", "Gruppe1_Item3")], na.rm = TRUE)
g2 <- rowMeans(df[, c("Gruppe2_Item1", "Gruppe2_Item2", "Gruppe2_Item3")], na.rm = TRUE)
# Extract and compare non-NA values
g1 <- g1[!is.na(g1)]
g2 <- g2[!is.na(g2)]
t.test(g1, g2)
