############################################################
### NAMA : WILDIA NURATNA PUTRI NOVIA ###
### NIM : 2502056045 ###
### MATA KULIAH : STATISTIKA ###
### PROGRAM STUDI : ILMU KOMUNIKASI A ANGKATAN 2025 ###
############################################################
### MENGERJAKAN BAB 7 ###
### UJI KESAMAAN VARIANS POPULASI ###
############################################################
#Menghitung Nilai Kritis F
qf(.95, df1=2, df2 = 15)
## [1] 3.68232
#Uji Kesaman Varians Populasi dengan Uji Levene
library(readxl)
simpan=read_excel(file.choose()) # Membaca data
simpan
## # A tibble: 18 × 2
## Nilai Kelas
## <dbl> <dbl>
## 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
simpan$Nilai=as.numeric(simpan$Nilai)
simpan$Kelas=as.factor(simpan$Kelas)
library(car)
## Loading required package: carData
leveneTest(Nilai ~ Kelas, data = simpan)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 0.4267 0.6604
## 15
library(Rcmdr)
## Loading required package: splines
## Loading required package: RcmdrMisc
## Loading required package: sandwich
## Loading required package: effects
## Registered S3 method overwritten by 'lme4':
## method from
## na.action.merMod car
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
## The Commander GUI is launched only in interactive sessions
##
## Attaching package: 'Rcmdr'
## The following object is masked from 'package:base':
##
## errorCondition
leveneTest(Nilai ~ Kelas, data = simpan)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 0.4267 0.6604
## 15
library(lawstat)
##
## Attaching package: 'lawstat'
## The following object is masked from 'package:car':
##
## levene.test
levene.test(simpan$Nilai, simpan$Kelas, location = "median", correction.method = "zero.correction") # Sesuai Minitab
##
## 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: simpan$Nilai
## Test Statistic = 0.4372, p-value = 0.6557
levene.test(simpan$Nilai, simpan$Kelas, location = "mean", correction.method = "zero.correction") # Sesuai SPSS
##
## 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 = 0.64903, p-value = 0.5366
#Contoh Kasus 2, Uji Kesamaan Varians Populasi dengan Uji Levene
library(readxl)
simpan=read_excel(file.choose())
simpan
## # A tibble: 14 × 2
## Nilai Kelas
## <dbl> <dbl>
## 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) )})
## # A tibble: 2 × 4
## Kelas Nilai.ratarata Nilai.varians Nilai.jumlah
## <dbl> <dbl> <dbl> <dbl>
## 1 1 60 467. 420
## 2 2 40 467. 280
#Menentukan Nilai Kritis F dengan R
qf(0.95, df1=1, df2=12)
## [1] 4.747225
#Pengambilan keputusan terhadap hipotesis
library(readxl)
simpan=read_excel(file.choose())
simpan
## # A tibble: 14 × 2
## Nilai Kelas
## <dbl> <dbl>
## 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(lawstat)
data(simpan)
## Warning in data(simpan): data set 'simpan' not found
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