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
## Nilai Kelas
## 1 70 1
## 2 80 1
## 3 87 1
## 4 77 1
## 5 80 1
## 6 80 2
## 7 85 2
## 8 70 2
## 9 77 2
## 10 85 2
## 11 60 2
## 12 80 2
## 13 70 3
## 14 87 3
## 15 90 3
## 16 77 3
## 17 76 3
## 18 87 3
library(car)
## Loading required package: carData
leveneTest(varians$Nilai, as.factor(varians$Kelas), center = mean)
## Levene's Test for Homogeneity of Variance (center = mean)
## Df F value Pr(>F)
## group 2 0.649 0.5366
## 15
library(lawstat)
##
## Attaching package: 'lawstat'
## The following object is masked from 'package:car':
##
## levene.test
levene.test(varians$Nilai, 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
levene.test(varians$Nilai, varians$Kelas, location = "median",
correction.method = "zero.correction")
##
## Modified robust Brown-Forsythe Levene-type test based on the absolute
## deviations from the median with modified structural zero removal method
## and correction factor
##
## data: varians$Nilai
## Test Statistic = 0.4372, p-value = 0.6557
simpan = 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))
)
simpan
## Nilai Kelas
## 1 30 1
## 2 40 1
## 3 50 1
## 4 60 1
## 5 70 1
## 6 80 1
## 7 90 1
## 8 10 2
## 9 20 2
## 10 30 2
## 11 40 2
## 12 50 2
## 13 60 2
## 14 70 2
library(doBy)
summaryBy(Nilai ~ Kelas, data = simpan, FUN = function(x)
{c(ratarata = mean(x), varians = var(x), jumlah = sum(x))})
## Kelas Nilai.ratarata Nilai.varians Nilai.jumlah
## 1 1 60 466.6667 420
## 2 2 40 466.6667 280
levene.test(simpan$Nilai, simpan$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: simpan$Nilai
## Test Statistic = 1.4336e-32, p-value = 1