研究問題: 台灣男生與女生在 PISA 2022 數學分數(PV1MATH)的平均數是否具有顯著差異?
研究假設(雙尾檢定,α = .05):
變項:
library(haven)
library(psych)
library(car)
PISA <- read_sav("PISA_tawian2022_trimmed_lab.sav")
# 檢查性別編碼(5/7/8/9 為遺漏代碼)
table(PISA$Gender, useNA = "ifany")
##
## 1 2
## 2780 2819
只保留有效性別(1 = Female、2 = Male),並排除數學分數遺漏者:
PISA <- subset(PISA, Gender %in% c(1, 2) & !is.na(PV1MATH))
PISA$PV1MATH <- as.numeric(PISA$PV1MATH)
# 將性別轉為因子
PISA$Gender <- factor(as.numeric(PISA$Gender),
levels = c(1, 2), labels = c("Female", "Male"))
summary(PISA$Gender)
## Female Male
## 2780 2819
mean(PISA$PV1MATH) # 平均數
## [1] 537.822
sd(PISA$PV1MATH) # 標準差
## [1] 109.7305
describeBy(PISA$PV1MATH, PISA$Gender)
##
## Descriptive statistics by group
## group: Female
## vars n mean sd median trimmed mad min max range skew
## X1 1 2780 535.84 102.26 538.56 536.99 108.38 227.79 821.56 593.77 -0.11
## kurtosis se
## X1 -0.4 1.94
## ------------------------------------------------------------
## group: Male
## vars n mean sd median trimmed mad min max range skew
## X1 1 2819 539.78 116.62 546.54 541.26 125.62 219.06 917.38 698.32 -0.1
## kurtosis se
## X1 -0.51 2.2
n_g <- tapply(PISA$PV1MATH, PISA$Gender, length)
m_g <- tapply(PISA$PV1MATH, PISA$Gender, mean)
sd_g <- tapply(PISA$PV1MATH, PISA$Gender, sd)
desc_tab <- data.frame(
性別 = c("女生", "男生"),
n = as.vector(n_g),
M = round(as.vector(m_g), 2),
SD = round(as.vector(sd_g), 2)
)
knitr::kable(desc_tab, caption = "表 1 不同性別之 PISA 數學分數描述性統計")
| 性別 | n | M | SD |
|---|---|---|---|
| 女生 | 2780 | 535.84 | 102.26 |
| 男生 | 2819 | 539.78 | 116.62 |
女生共 2780 人,平均數學分數為 535.84(SD = 102.26);男生共 2819 人,平均數學分數為 539.78(SD = 116.62)。
H0:兩組變異數相等。
lev <- leveneTest(PISA$PV1MATH ~ PISA$Gender, center = "mean")
lev
## Levene's Test for Homogeneity of Variance (center = "mean")
## Df F value Pr(>F)
## group 1 59.342 1.557e-14 ***
## 5597
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lev_F <- lev$`F value`[1]
lev_df <- lev$Df
lev_p <- lev$`Pr(>F)`[1]
equal_var <- lev_p >= .05 # 不顯著 → 假設變異數同質
Levene’s Test 結果為 F(1, 5597) = 59.34,p < .001, 達顯著水準,表示兩組變異數不同質,因此採用不假設變異數相等的 Welch t 檢定(var.equal = FALSE)。
兩種檢定結果皆列出供對照,依 Levene’s Test 結果回報對應的那一個:
# (A) 變異數不同質(Levene 顯著):Welch t-test
t.test(PISA$PV1MATH ~ PISA$Gender, var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: PISA$PV1MATH by PISA$Gender
## t = -1.3461, df = 5521.6, p-value = 0.1783
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
## -9.688443 1.799944
## sample estimates:
## mean in group Female mean in group Male
## 535.8361 539.7803
# (B) 變異數同質(Levene 不顯著):Student t-test
t.test(PISA$PV1MATH ~ PISA$Gender, var.equal = TRUE)
##
## Two Sample t-test
##
## data: PISA$PV1MATH by PISA$Gender
## t = -1.3449, df = 5597, p-value = 0.1787
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
## -9.693658 1.805158
## sample estimates:
## mean in group Female mean in group Male
## 535.8361 539.7803
依 Levene’s Test 自動選擇的檢定結果:
tt <- t.test(PISA$PV1MATH ~ PISA$Gender, var.equal = equal_var)
tt
##
## Welch Two Sample t-test
##
## data: PISA$PV1MATH by PISA$Gender
## t = -1.3461, df = 5521.6, p-value = 0.1783
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
## -9.688443 1.799944
## sample estimates:
## mean in group Female mean in group Male
## 535.8361 539.7803
t_val <- unname(tt$statistic)
t_df <- unname(tt$parameter)
t_p <- tt$p.value
ci <- tt$conf.int
m_diff <- unname(m_g["Female"] - m_g["Male"])
sp <- sqrt(((n_g[1] - 1) * sd_g[1]^2 + (n_g[2] - 1) * sd_g[2]^2) / (sum(n_g) - 2))
d <- unname(m_diff / sp)
round(d, 3)
## [1] -0.036
統計結果: 因為 Levene’s Test 達顯著(p < .001),本研究採用 Welch 獨立樣本 t 檢定。結果顯示,女生(M = 535.84,SD = 102.26)與男生(M = 539.78,SD = 116.62)的 PISA 數學分數 未達顯著差異, t(5521.60) = -1.35,p = .178, 平均差異(女 − 男)= -3.94,95% CI [-9.69, 1.8],Cohen’s d = -0.04。
結論: 因 p ≥ .05,無法拒絕虛無假設(H0),表示沒有足夠證據顯示台灣男女學生在 PISA 2022 數學分數的平均數有所差異。95% 信賴區間包含 0,亦支持此結論。
解釋: 效果量 Cohen’s d = 0.04,屬於極小效果量(.2 小、.5 中、.8 大)。由於 PISA 樣本數多,所以即使組間差異不大也容易達到統計顯著,因此除了 p 值之外,也要參考效果量來判斷差異的實際意義。此外,本分析僅使用第一個可能值(PV1MATH),且未納入抽樣權重,正式研究應整合全部可能值並使用權重,以獲得更精確的推論。