data = read.csv(file.choose(), header = TRUE) #data_berpasangan.csv
data
## X Y
## 1 78 100
## 2 75 95
## 3 67 70
## 4 77 90
## 5 70 90
## 6 72 90
## 7 78 89
## 8 74 90
## 9 77 100
t.test(data$Y, data$X, paired=TRUE)
##
## Paired t-test
##
## data: data$Y and data$X
## t = 7.6525, df = 8, p-value = 6.003e-05
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 11.33381 21.11064
## sample estimates:
## mean difference
## 16.22222
selisih = data$Y - data$X
selisih
## [1] 22 20 3 13 20 18 11 16 23
qqnorm(selisih)
qqline(selisih)

library(nortest)
lillie.test(selisih)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: selisih
## D = 0.1682, p-value = 0.6544
library(tseries)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
jarque.bera.test(selisih)
##
## Jarque Bera Test
##
## data: selisih
## X-squared = 1.3935, df = 2, p-value = 0.4982
qt(0.975, df=18) #pengujian hipotesis 2 arah, sehingga 0,975, bukan 0,95
## [1] 2.100922
qf(0.95, df1=1, df2=18)
## [1] 4.413873
data=read.csv(file.choose(), header = TRUE) #file : data_independen_1.csv
data
## X Y
## 1 65 85
## 2 68 75
## 3 70 75
## 4 80 80
## 5 75 75
## 6 72 75
## 7 65 75
## 8 60 80
## 9 88 90
## 10 70 85
t.test(data$Y, data$X, var.equal=TRUE, paired=FALSE)
##
## Two Sample t-test
##
## data: data$Y and data$X
## t = 2.6487, df = 18, p-value = 0.01633
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.695807 14.704193
## sample estimates:
## mean of x mean of y
## 79.5 71.3
t.test(data$Y, data$X, var.equal=FALSE, paired=FALSE)
##
## Welch Two Sample t-test
##
## data: data$Y and data$X
## t = 2.6487, df = 15.851, p-value = 0.01762
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.632025 14.767975
## sample estimates:
## mean of x mean of y
## 79.5 71.3
X=data$X
Y=data$Y
X
## [1] 65 68 70 80 75 72 65 60 88 70
Y
## [1] 85 75 75 80 75 75 75 80 90 85
library(nortest)
lillie.test(X) #dengan koreksi (lihat p-value)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: X
## D = 0.16556, p-value = 0.6103
ks.test(X,"pnorm",mean(X),sd(X)) #tanpa korelasi (lihat p-value)
## Warning in ks.test.default(X, "pnorm", mean(X), sd(X)): ties should not be
## present for the one-sample Kolmogorov-Smirnov test
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: X
## D = 0.16556, p-value = 0.9469
## alternative hypothesis: two-sided
ks.test(Y,"pnorm",mean(Y),sd(Y))
## Warning in ks.test.default(Y, "pnorm", mean(Y), sd(Y)): ties should not be
## present for the one-sample Kolmogorov-Smirnov test
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: Y
## D = 0.29327, p-value = 0.356
## alternative hypothesis: two-sided
library(tseries)
jarque.bera.test(X)
##
## Jarque Bera Test
##
## data: X
## X-squared = 0.92911, df = 2, p-value = 0.6284
jarque.bera.test(Y)
##
## Jarque Bera Test
##
## data: Y
## X-squared = 1.1767, df = 2, p-value = 0.5552
varians=read.csv(file.choose(), header = TRUE) #file : varians.csv
varians
## Nilai Jenis
## 1 65 1
## 2 68 1
## 3 70 1
## 4 80 1
## 5 75 1
## 6 72 1
## 7 65 1
## 8 60 1
## 9 88 1
## 10 70 1
## 11 85 2
## 12 75 2
## 13 75 2
## 14 80 2
## 15 75 2
## 16 75 2
## 17 75 2
## 18 80 2
## 19 90 2
## 20 85 2
library(car)
## Warning: package 'car' was built under R version 4.6.2
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.6.2
leveneTest(varians$Nilai, varians$Jenis)
## Warning in leveneTest.default(varians$Nilai, varians$Jenis): varians$Jenis
## coerced to factor.
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 1 0.3305 0.5725
## 18
library(Rcmdr)
## Warning: package 'Rcmdr' was built under R version 4.6.2
## Loading required package: splines
## Loading required package: RcmdrMisc
## Warning: package 'RcmdrMisc' was built under R version 4.6.2
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 4.6.2
## Loading required package: effects
## Warning: package 'effects' was built under R version 4.6.2
## 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(varians$Nilai, varians$Jenis)
## Warning in leveneTest.default(varians$Nilai, varians$Jenis): varians$Jenis
## coerced to factor.
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 1 0.3305 0.5725
## 18
library(lawstat)
## Warning: package 'lawstat' was built under R version 4.6.2
##
## Attaching package: 'lawstat'
## The following object is masked from 'package:car':
##
## levene.test
## The following object is masked from 'package:tseries':
##
## runs.test
levene.test(varians[,"Nilai"], varians[,"Jenis"], location="median") #sesuai Minitab
##
## Modified robust Brown-Forsythe Levene-type test based on the absolute
## deviations from the median
##
## data: varians[, "Nilai"]
## Test Statistic = 0.33053, p-value = 0.5725
levene.test(varians[,"Nilai"], varians[,"Jenis"], location="mean") #sesuai SPSS
##
## Classical Levene's test based on the absolute deviations from the mean
## ( none not applied because the location is not set to median )
##
## data: varians[, "Nilai"]
## Test Statistic = 0.62924, p-value = 0.438
qt(0.975, df=10)
## [1] 2.228139
data=read.csv(file.choose(), header = TRUE) #file : data_independen_2.csv
data
## X Y
## 1 70 90
## 2 71 91
## 3 72 92
## 4 70 93
## 5 71 94
## 6 72 95
## 7 70 86
## 8 70 97
## 9 71 98
## 10 72 100
t.test(data$Y, data$X, var.equal=TRUE, paired=FALSE)
##
## Two Sample t-test
##
## data: data$Y and data$X
## t = 16.956, df = 18, p-value = 1.63e-12
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 19.88741 25.51259
## sample estimates:
## mean of x mean of y
## 93.6 70.9
t.test(data$Y, data$X, var.equal=FALSE, paired=FALSE)
##
## Welch Two Sample t-test
##
## data: data$Y and data$X
## t = 16.956, df = 9.8028, p-value = 1.374e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 19.70895 25.69105
## sample estimates:
## mean of x mean of y
## 93.6 70.9
X=data$X
Y=data$Y
X
## [1] 70 71 72 70 71 72 70 70 71 72
Y
## [1] 90 91 92 93 94 95 86 97 98 100
ks.test(X, "pnorm", mean(X), sd(X))
## Warning in ks.test.default(X, "pnorm", mean(X), sd(X)): ties should not be
## present for the one-sample Kolmogorov-Smirnov test
##
## Asymptotic one-sample Kolmogorov-Smirnov test
##
## data: X
## D = 0.248, p-value = 0.57
## alternative hypothesis: two-sided
ks.test(Y, "pnorm", mean(Y), sd(Y))
##
## Exact one-sample Kolmogorov-Smirnov test
##
## data: Y
## D = 0.094141, p-value = 0.9999
## alternative hypothesis: two-sided
library(tseries)
jarque.bera.test(X)
##
## Jarque Bera Test
##
## data: X
## X-squared = 1.0296, df = 2, p-value = 0.5976
jarque.bera.test(Y)
##
## Jarque Bera Test
##
## data: Y
## X-squared = 0.20791, df = 2, p-value = 0.9013
varians_2=read.csv(file.choose(), header = TRUE) #file : varians_2.csv
varians_2
## Nilai Jenis
## 1 70 1
## 2 71 1
## 3 72 1
## 4 70 1
## 5 71 1
## 6 72 1
## 7 70 1
## 8 70 1
## 9 71 1
## 10 72 1
## 11 90 2
## 12 91 2
## 13 92 2
## 14 93 2
## 15 94 2
## 16 95 2
## 17 86 2
## 18 97 2
## 19 98 2
## 20 100 2
library(lawstat)
levene.test(varians_2[,"Nilai"], varians_2[,"Jenis"], location="median") #sesuai Minitab
##
## Modified robust Brown-Forsythe Levene-type test based on the absolute
## deviations from the median
##
## data: varians_2[, "Nilai"]
## Test Statistic = 10.378, p-value = 0.004733
levene.test(varians_2[,"Nilai"], varians_2[,"Jenis"], location="mean") #sesuai SPSS
##
## Classical Levene's test based on the absolute deviations from the mean
## ( none not applied because the location is not set to median )
##
## data: varians_2[, "Nilai"]
## Test Statistic = 10.305, p-value = 0.004853