#1.DETEKSI PENCILAN UNIVARIAT
#Univariate outliner Boxplots
dat<-read.csv(file = "D:/S2 PMAT UNY/SEMESTER 2/Praktikum Inovasi Pembelajaran Matematika/analisis/Data Penelitian PIPM.csv",head=TRUE)
str(dat)
## 'data.frame':    64 obs. of  5 variables:
##  $ Kelas   : chr  "Eksperimen" "Eksperimen" "Eksperimen" "Eksperimen" ...
##  $ Pre_SDL : int  46 60 60 68 64 45 54 59 64 60 ...
##  $ Pre_LM  : int  28 22 11 33 17 44 17 28 17 28 ...
##  $ Post_SDL: int  78 79 78 99 90 84 90 74 91 73 ...
##  $ Post_LM : int  67 81 67 95 62 76 71 71 57 52 ...
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.4.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.2
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.4.2
p<-ggplot(dat,aes(x=Kelas,y=Pre_SDL))+geom_boxplot()
p

q<-ggplot(dat,aes(x=Kelas,y=Pre_LM))+geom_boxplot()
q

r<-ggplot(dat,aes(x=Kelas,y=Post_SDL))+geom_boxplot()
r

s<-ggplot(dat,aes(x=Kelas,y=Post_LM))+geom_boxplot()
s

#2.Penyajian Data Multivariat
win.graph(width=10,height=8)
stars(x=
      dat[,c("Post_SDL","Post_LM")],
      nrow=11,ncol=11,draw.segments=TRUE,key.loc
      =c(12,30),labels=as.character(dat$Kelas))

#3.Deteksi Pencilan Multivariat
library(rstatix) 
## Warning: package 'rstatix' was built under R version 4.4.2
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
dat %>% 
  group_by(Kelas) %>% 
  mahalanobis_distance(c(Pre_SDL,Pre_LM,Post_SDL,Post_LM)) %>% 
  filter(is.outlier == TRUE) %>% 
  as.data.frame() 
## [1] Pre_SDL    Pre_LM     Post_SDL   Post_LM    mahal.dist is.outlier
## <0 rows> (or 0-length row.names)
#4.UJI ASUMSI
#a.Uji Normalitas
#Uji Asumsi Normalitas Multivariat dan Univariat
#panggil data nanti ketik sendiri
#(1)PBL Sebelum Perlakuan
RME1<-subset(dat[,c("Pre_SDL","Pre_LM")],dat$Kelas=="Eksperimen")
attach(RME1)
library(MVN)
## Warning: package 'MVN' was built under R version 4.4.2
mvn(data = RME1, mvnTest = "hz", univariateTest = "SW", univariatePlot = 
      "histogram",multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = FALSE, showNewData = FALSE) 
## $multivariateNormality
##            Test        HZ   p value MVN
## 1 Henze-Zirkler 0.5680431 0.2357167 YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk  Pre_SDL     0.9511    0.1553    YES   
## 2 Shapiro-Wilk  Pre_LM      0.9406    0.0780    YES   
## 
## $Descriptives
##          n    Mean   Std.Dev Median Min Max 25th 75th       Skew   Kurtosis
## Pre_SDL 32 56.8125  7.036483     59  40  68   53   63 -0.5473754 -0.6461437
## Pre_LM  32 28.1250 11.918405     28  11  56   17   39  0.2320713 -0.9525325
#(2)PBL Sebelum Perlakuan
PBL1<-subset(dat[,c("Pre_SDL","Pre_LM")],dat$Kelas=="Kontrol")
attach(PBL1)
## The following objects are masked from RME1:
## 
##     Pre_LM, Pre_SDL
library(MVN)
mvn(data = PBL1, mvnTest = "hz", univariateTest = "SW", univariatePlot = 
      "histogram",multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = FALSE, showNewData = FALSE) 
## $multivariateNormality
##            Test       HZ  p value MVN
## 1 Henze-Zirkler 0.669079 0.126579 YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk  Pre_SDL     0.9629    0.3284    YES   
## 2 Shapiro-Wilk  Pre_LM      0.9381    0.0662    YES   
## 
## $Descriptives
##          n     Mean   Std.Dev Median Min Max  25th 75th       Skew   Kurtosis
## Pre_SDL 32 53.81250  5.324548     55  44  64 50.75 56.5 -0.1919903 -0.7307277
## Pre_LM  32 33.34375 11.321146     36  11  56 28.00 44.0 -0.2051085 -0.9718175
#(3)RME Setelah Perlakuan (masih error, belum nemu alasan error)
RME2<-subset(dat[,c("Post_SDL","Post_LM")],dat$Kelas=="Eksperimen")
attach(RME2)
library(MVN)
mvn(data = RME2, mvnTest = "hz", univariateTest = "SW", univariatePlot = 
      "histogram",multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = FALSE, showNewData = FALSE) 
## $multivariateNormality
##            Test        HZ   p value MVN
## 1 Henze-Zirkler 0.3852145 0.6111827 YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk Post_SDL     0.9669    0.4193    YES   
## 2 Shapiro-Wilk  Post_LM     0.9674    0.4314    YES   
## 
## $Descriptives
##           n     Mean  Std.Dev Median Min Max  25th 75th        Skew   Kurtosis
## Post_SDL 32 82.12500  7.50806     81  69  99 77.25 88.5  0.25714229 -0.9036745
## Post_LM  32 74.03125 10.96765     71  52  95 67.00 81.0 -0.04819331 -0.5433931
#(4)PBL Setelah Perlakuan
PBL2<-subset(dat[,c("Post_SDL","Post_LM")],dat$Kelas=="Kontrol")
attach(PBL2)
## The following objects are masked from RME2:
## 
##     Post_LM, Post_SDL
library(MVN)
mvn(data = PBL2, mvnTest = "hz", univariateTest = "SW", univariatePlot = 
      "histogram",multivariatePlot = "qq", multivariateOutlierMethod = "adj", 
    showOutliers = FALSE, showNewData = FALSE) 
## $multivariateNormality
##            Test        HZ   p value MVN
## 1 Henze-Zirkler 0.4156673 0.5342701 YES
## 
## $univariateNormality
##           Test  Variable Statistic   p value Normality
## 1 Shapiro-Wilk Post_SDL     0.9748    0.6409    YES   
## 2 Shapiro-Wilk  Post_LM     0.9524    0.1691    YES   
## 
## $Descriptives
##           n     Mean  Std.Dev Median Min Max 25th 75th        Skew   Kurtosis
## Post_SDL 32 86.50000  6.08011   85.5  76  99   83   90  0.09718356 -0.7846935
## Post_LM  32 73.40625 10.54593   71.0  52  90   67   81 -0.25010598 -0.7005414
#Uji Asumsi Homogenitas Matriks Varian-Kovarian
library(biotools)
## Warning: package 'biotools' was built under R version 4.4.2
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:rstatix':
## 
##     select
## The following object is masked from 'package:dplyr':
## 
##     select
## ---
## biotools version 4.2
#Uji Homogenitas Matriks Variansi-Kovariansi-Pretest
boxM(data = dat[,c("Pre_SDL","Pre_LM")], grouping = dat$Kelas)
## 
##  Box's M-test for Homogeneity of Covariance Matrices
## 
## data:  dat[, c("Pre_SDL", "Pre_LM")]
## Chi-Sq (approx.) = 2.5969, df = 3, p-value = 0.458
#Uji Homogenitas Matriks Variansi-Kovariansi-Posttest
homkov2<-as.matrix(dat[,c("Post_SDL","Post_LM")])
boxM(homkov2,dat$Kelas)
## 
##  Box's M-test for Homogeneity of Covariance Matrices
## 
## data:  homkov2
## Chi-Sq (approx.) = 7.7404, df = 3, p-value = 0.05169
qchisq(0.95,df=3)
## [1] 7.814728
#Uji Asumsi Homogenitas Variansi
library(car)
## Warning: package 'car' was built under R version 4.4.2
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.4.2
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
leveneTest(y=dat$Pre_SDL,group=dat$Kelas,center=mean)
## Warning in leveneTest.default(y = dat$Pre_SDL, group = dat$Kelas, center =
## mean): dat$Kelas coerced to factor.
## Levene's Test for Homogeneity of Variance (center = mean)
##       Df F value  Pr(>F)  
## group  1  3.5817 0.06309 .
##       62                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
leveneTest(y=dat$Pre_LM,group=dat$Kelas,center=mean)
## Warning in leveneTest.default(y = dat$Pre_LM, group = dat$Kelas, center =
## mean): dat$Kelas coerced to factor.
## Levene's Test for Homogeneity of Variance (center = mean)
##       Df F value Pr(>F)
## group  1  0.0795 0.7789
##       62
leveneTest(y=dat$Post_SDL,group=dat$Kelas,center=mean)
## Warning in leveneTest.default(y = dat$Post_SDL, group = dat$Kelas, center =
## mean): dat$Kelas coerced to factor.
## Levene's Test for Homogeneity of Variance (center = mean)
##       Df F value Pr(>F)
## group  1    2.23 0.1404
##       62
leveneTest(y=dat$Post_LM,group=dat$Kelas,center=mean)
## Warning in leveneTest.default(y = dat$Post_LM, group = dat$Kelas, center =
## mean): dat$Kelas coerced to factor.
## Levene's Test for Homogeneity of Variance (center = mean)
##       Df F value Pr(>F)
## group  1  0.0519 0.8206
##       62
qf(0.95,3,60)
## [1] 2.758078
#Pengecekan Koefisien Korelasi Antar Variabel Dependen
#Pengecekan Multikolinearitas-Pretest
cor(x=dat$Pre_SDL,y=dat$Pre_LM)
## [1] 0.00238276
#Pengecekan Multikolinearitas-Posttest
cor(x=dat$Post_SDL,y=dat$Post_LM)
## [1] 0.0645843
#Uji Efektivitas
#Uji SDL Kelas RME
Post_SDLRME<-(subset(dat[,c("Post_SDL")],dat$Kelas=="Eksperimen"))
str(Post_SDLRME)
##  int [1:32] 78 79 78 99 90 84 90 74 91 73 ...
mean(Post_SDLRME)
## [1] 82.125
sd(Post_SDLRME)
## [1] 7.50806
t.test(Post_SDLRME,mu=68,alternative="greater")
## 
##  One Sample t-test
## 
## data:  Post_SDLRME
## t = 10.642, df = 31, p-value = 3.549e-12
## alternative hypothesis: true mean is greater than 68
## 95 percent confidence interval:
##  79.87462      Inf
## sample estimates:
## mean of x 
##    82.125
#Uji SDL Kelas PBL
Post_SDLPBL<-(subset(dat[,c("Post_SDL")],dat$Kelas=="Kontrol"))
str(Post_SDLPBL)
##  int [1:32] 90 98 85 88 83 90 93 76 84 80 ...
mean(Post_SDLPBL)
## [1] 86.5
sd(Post_SDLPBL)
## [1] 6.08011
t.test(Post_SDLPBL,mu=68,alternative="greater")
## 
##  One Sample t-test
## 
## data:  Post_SDLPBL
## t = 17.212, df = 31, p-value < 2.2e-16
## alternative hypothesis: true mean is greater than 68
## 95 percent confidence interval:
##  84.67762      Inf
## sample estimates:
## mean of x 
##      86.5
#Uji LM Kelas RME
Post_LMRME<-(subset(dat[,c("Post_LM")],dat$Kelas=="Eksperimen"))
str(Post_LMRME)
##  int [1:32] 67 81 67 95 62 76 71 71 57 52 ...
mean(Post_LMRME)
## [1] 74.03125
sd(Post_LMRME)
## [1] 10.96765
t.test(Post_LMRME,mu=69.99,alternative="greater")
## 
##  One Sample t-test
## 
## data:  Post_LMRME
## t = 2.0844, df = 31, p-value = 0.02273
## alternative hypothesis: true mean is greater than 69.99
## 95 percent confidence interval:
##  70.74394      Inf
## sample estimates:
## mean of x 
##  74.03125
#Uji LM Kelas PBL
Post_LMPBL<-(subset(dat[,c("Post_LM")],dat$Kelas=="Kontrol"))
str(Post_LMPBL)
##  int [1:32] 71 81 90 71 86 52 57 71 71 86 ...
mean(Post_LMPBL)
## [1] 73.40625
sd(Post_LMPBL)
## [1] 10.54593
t.test(Post_LMPBL,mu=69.99,alternative="greater")
## 
##  One Sample t-test
## 
## data:  Post_LMPBL
## t = 1.8325, df = 31, p-value = 0.03825
## alternative hypothesis: true mean is greater than 69.99
## 95 percent confidence interval:
##  70.24534      Inf
## sample estimates:
## mean of x 
##  73.40625
qt(0.975,df=31)
## [1] 2.039513
#UJI PERBANDINGAN
#a.pretest
library(ICSNP)
## Warning: package 'ICSNP' was built under R version 4.4.2
## Loading required package: mvtnorm
## Warning: package 'mvtnorm' was built under R version 4.4.2
## Loading required package: ICS
## Warning: package 'ICS' was built under R version 4.4.2
Pretest<-as.matrix(dat[,c("Pre_SDL","Pre_LM")])
muH0<-c(0,0)
Factor<-dat$Kelas
HotellingsT2(Pretest~Factor,mu=muH0,test="chi")
## 
##  Hotelling's two sample T2-test
## 
## data:  Pretest by Factor
## T.2 = 7.3512, df = 2, p-value = 0.02533
## alternative hypothesis: true location difference is not equal to c(0,0)
n<-nrow(Pretest)
n
## [1] 64
p<-ncol(Pretest)
p
## [1] 2
crit1<-(n-1)*p/(n-p)*qf(0.95,p,n-p)
crit1
## [1] 6.391977
#b.posttest
library(ICSNP)
Posttest<-as.matrix(dat[,c("Post_SDL","Post_LM")])
muH0<-c(0,0)
Factor<-dat$Kelas
HotellingsT2(Posttest~Factor,mu=muH0,test="chi")
## 
##  Hotelling's two sample T2-test
## 
## data:  Posttest by Factor
## T.2 = 6.749, df = 2, p-value = 0.03423
## alternative hypothesis: true location difference is not equal to c(0,0)
m<-nrow(Posttest)
m
## [1] 64
q<-ncol(Posttest)
q
## [1] 2
crit2<-(n-1)*q/(m-q)*qf(0.95,q,m-q)
crit2
## [1] 6.391977
#UJI LANJUT
#Pendekatan RME
RME2$Post_SDL<-subset(dat[,c("Post_SDL")],dat$Kelas=="Eksperimen")
RME2$Post_LM<-subset(dat[,c("Post_LM")],dat$Kelas=="Eksperimen")
#Pendekatan PBL
PBL2$Post_SDL<-subset(dat[,c("Post_SDL")],dat$Kelas=="Kontrol")
PBL2$Post_LM<-subset(dat[,c("Post_LM")],dat$Kelas=="Kontrol")
t.test(RME2$Post_SDL,PBL2$Post_SDL,alternative="two.sided",mu=0,paired=FALSE,var.equal=TRUE,conf.level=0.95)
## 
##  Two Sample t-test
## 
## data:  RME2$Post_SDL and PBL2$Post_SDL
## t = -2.5617, df = 62, p-value = 0.01286
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.7889921 -0.9610079
## sample estimates:
## mean of x mean of y 
##    82.125    86.500
t.test(RME2$Post_LM,PBL2$Post_LM,alternative="two.sided",mu=0,paired=FALSE,var.equal=TRUE,conf.level=0.95)
## 
##  Two Sample t-test
## 
## data:  RME2$Post_LM and PBL2$Post_LM
## t = 0.23237, df = 62, p-value = 0.817
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4.751663  6.001663
## sample estimates:
## mean of x mean of y 
##  74.03125  73.40625
qt(0.95,62)
## [1] 1.669804