Kasus 1: nilai ujian matematika kelas 1, 2, 3 SMA
varians = data.frame(
Nilai = c(70, 80, 87, 77, 80,
80, 85, 70, 77, 85, 60, 80,
70, 87, 90, 77, 76, 87),
Kelas = c(rep(1, 5), rep(2, 7), rep(3, 6))
)
varians
library(car)
## Loading required package: carData
leveneTest(varians$Nilai, factor(varians$Kelas))
library(lawstat)
##
## Attaching package: 'lawstat'
## The following object is masked from 'package:car':
##
## levene.test
levene.test(varians$Nilai, factor(varians$Kelas), location = "mean",
correction.method = "zero.correction")
##
## Classical Levene's test based on the absolute deviations from the mean
## ( zero.correction not applied because the location is not set to median
## )
##
## data: varians$Nilai
## Test Statistic = 0.64903, p-value = 0.5366
Kasus 2: kelas 1 dan kelas 2 SMA
varians2 = data.frame(
Nilai = c(30, 40, 50, 60, 70, 80, 90,
10, 20, 30, 40, 50, 60, 70),
Kelas = c(rep(1, 7), rep(2, 7))
)
var(varians2$Nilai[varians2$Kelas == 1])
## [1] 466.6667
var(varians2$Nilai[varians2$Kelas == 2])
## [1] 466.6667
levene.test(varians2$Nilai, factor(varians2$Kelas), location = "mean",
correction.method = "zero.correction")
##
## Classical Levene's test based on the absolute deviations from the mean
## ( zero.correction not applied because the location is not set to median
## )
##
## data: varians2$Nilai
## Test Statistic = 1.4336e-32, p-value = 1
qf(0.95, 1, 12)
## [1] 4.747225