Data yang digunakan
### One Way MANOVA
data1 <- read.csv("~/Google Drive/Drive Saya/KULIAH/Semester 5/Aslab ADM 1/Praktikum/Praktikum 7/mangga.csv")
head(data1)
## No Weight Length Circumference Grade
## 1 1 486.5 14.0 27.0 A
## 2 2 388.4 12.0 26.0 A
## 3 3 493.7 12.0 26.5 A
## 4 4 342.5 10.0 24.3 A
## 5 5 401.5 11.0 25.0 A
## 6 6 342.4 12.5 24.0 A
Data
## Uji Normalitas
library(MVN)
data1_fix <- data1[2:4]
head(data1_fix)
## Weight Length Circumference
## 1 486.5 14.0 27.0
## 2 388.4 12.0 26.0
## 3 493.7 12.0 26.5
## 4 342.5 10.0 24.3
## 5 401.5 11.0 25.0
## 6 342.4 12.5 24.0
test = mvn(data1_fix, mvnTest = "mardia", univariateTest = "SW", multivariatePlot = "qq")
test
## $multivariateNormality
## Test Statistic p value Result
## 1 Mardia Skewness 10.2871937264549 0.415668459083307 YES
## 2 Mardia Kurtosis 0.0285427984685856 0.977229233679485 YES
## 3 MVN <NA> <NA> YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Shapiro-Wilk Weight 0.9910 0.9113 YES
## 2 Shapiro-Wilk Length 0.9840 0.5461 YES
## 3 Shapiro-Wilk Circumference 0.9808 0.3886 YES
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th
## Weight 67 389.97910 63.815631 388.4 241.0 571.9 342.45 434.25
## Length 67 12.56716 1.174913 12.5 10.0 15.4 11.70 13.30
## Circumference 67 25.13881 1.647492 25.2 21.5 29.9 24.00 26.30
## Skew Kurtosis
## Weight 0.06492546 -0.1214515
## Length -0.05502050 -0.4478857
## Circumference -0.07498257 -0.1080415
## Uji Homogenitas Multivariate
library(biotools)
## Loading required package: MASS
## ---
## biotools version 4.2
grup <- data1$Grade
head(grup)
## [1] "A" "A" "A" "A" "A" "A"
boxM(data = data1_fix, grouping = grup)
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: data1_fix
## Chi-Sq (approx.) = 15.452, df = 6, p-value = 0.01702
owm = manova(cbind(data1$Weight, data1$Length, data1$Circumference)~data1$Grade)
summary(owm)
## Df Pillai approx F num Df den Df Pr(>F)
## data1$Grade 1 0.53371 24.037 3 63 1.733e-10 ***
## Residuals 65
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Uji Lanjut
summary.aov(owm)
## Response 1 :
## Df Sum Sq Mean Sq F value Pr(>F)
## data1$Grade 1 33860 33860 9.3686 0.003207 **
## Residuals 65 234921 3614
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response 2 :
## Df Sum Sq Mean Sq F value Pr(>F)
## data1$Grade 1 9.809 9.8088 7.8423 0.006714 **
## Residuals 65 81.299 1.2508
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response 3 :
## Df Sum Sq Mean Sq F value Pr(>F)
## data1$Grade 1 66.14 66.140 38.045 4.966e-08 ***
## Residuals 65 113.00 1.738
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Input Data
library(readr)
data2 <- read.csv("~/Google Drive/Drive Saya/KULIAH/Semester 5/Aslab ADM 1/Praktikum/Praktikum 7/anemia.csv")
head(data2)
## Gender Hemoglobin MCH MCHC MCV Result
## 1 1 14.9 22.7 29.1 83.7 0
## 2 0 15.9 25.4 28.3 72.0 0
## 3 0 9.0 21.5 29.6 71.2 1
## 4 0 14.9 16.0 31.4 87.5 0
## 5 1 14.7 22.0 28.2 99.5 0
## 6 0 11.6 22.3 30.9 74.5 1
## Uji Normalitas Multivariate
x1 <- data2[,2]
x2 <- data2[,3]
x3 <- data2[,4]
x4 <- data2[,5]
data2_fix <- data.frame(x1=x1, x2=x2, x3=x3, x4=x4)
library(MVN)
test = mvn(data2_fix, mvnTest = "mardia", univariateTest = "SW", multivariatePlot = "qq")
test
## $multivariateNormality
## Test Statistic p value Result
## 1 Mardia Skewness 36.5532125376917 0.0132312015739749 NO
## 2 Mardia Kurtosis -12.7018963507846 0 NO
## 3 MVN <NA> <NA> NO
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Shapiro-Wilk x1 0.9654 <0.001 NO
## 2 Shapiro-Wilk x2 0.9570 <0.001 NO
## 3 Shapiro-Wilk x3 0.9469 <0.001 NO
## 4 Shapiro-Wilk x4 0.9489 <0.001 NO
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## x1 1421 13.41274 1.974546 13.2 6.6 16.9 11.7 15.0 0.02269753 -0.8987025
## x2 1421 22.90563 3.969375 22.7 16.0 30.0 19.4 26.2 0.04619618 -1.1736809
## x3 1421 30.25123 1.400898 30.4 27.8 32.5 29.0 31.4 -0.07721563 -1.2466636
## x4 1421 85.52379 9.636701 85.3 69.4 101.6 77.3 94.2 0.03198598 -1.2397581
Karena datanya ga normal jadi dilakukan pemotongan data, di mana data asli sebanyak 1421, dipotong menjadi 65 dengan data yang diambil adalah data ke 318 sampai 382
## Potong Data
data2_p <- data2_fix[318:382,]
dim(data2_p)
## [1] 65 4
x1_p <- data2[318:382,2]
x2_p <- data2[318:382,3]
x3_p <- data2[318:382,4]
x4_p <- data2[318:382,5]
## Uji Normalitas Lagi
library(MVN)
test = mvn(data2_p, mvnTest = "mardia", univariateTest = "SW", multivariatePlot = "qq")
test
## $multivariateNormality
## Test Statistic p value Result
## 1 Mardia Skewness 11.1918179809589 0.94109554547585 YES
## 2 Mardia Kurtosis -1.94733201749224 0.051494942563286 YES
## 3 MVN <NA> <NA> YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Shapiro-Wilk x1 0.9678 0.0886 YES
## 2 Shapiro-Wilk x2 0.9637 0.0537 YES
## 3 Shapiro-Wilk x3 0.9396 0.0033 NO
## 4 Shapiro-Wilk x4 0.9367 0.0024 NO
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## x1 65 12.92000 2.220304 12.8 6.6 16.9 11.5 14.3 -0.00797762 -0.2774331
## x2 65 22.06769 3.651802 21.9 16.3 30.0 19.0 24.5 0.26858174 -0.9607505
## x3 65 30.50308 1.341171 30.7 27.8 32.5 29.3 31.6 -0.37734639 -1.1124260
## x4 65 86.03692 10.135883 86.4 69.8 101.5 77.5 93.4 -0.04151122 -1.3064280
## Uji Homogenitas
# Gender
library(biotools)
head(data2[318:382,1])
## [1] 0 1 1 0 1 0
boxM(data = data2_p, grouping = data2[318:382,1])
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: data2_p
## Chi-Sq (approx.) = 5.9575, df = 10, p-value = 0.8188
# Result
head(data2[318:382,6])
## [1] 0 1 0 1 1 1
boxM(data = data2_p, grouping = data2[318:382,6])
##
## Box's M-test for Homogeneity of Covariance Matrices
##
## data: data2_p
## Chi-Sq (approx.) = 7.6197, df = 10, p-value = 0.6659
## Two Way MANOVA
gender <- as.factor(data2$Gender[318:382])
result <- as.factor(data2$Result[318:382])
manova <- manova(cbind(x1_p, x2_p, x3_p, x4_p) ~ gender * result, data = data2_p)
# Menampilkan hasil
summary(manova)
## Df Pillai approx F num Df den Df Pr(>F)
## gender 1 0.17905 3.162 4 58 0.02028 *
## result 1 0.69481 33.011 4 58 2.387e-14 ***
## gender:result 1 0.01757 0.259 4 58 0.90275
## Residuals 61
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Uji Lanjut
summary.aov(manova)
## Response x1_p :
## Df Sum Sq Mean Sq F value Pr(>F)
## gender 1 13.971 13.971 8.7708 0.004357 **
## result 1 204.075 204.075 128.1122 < 2.2e-16 ***
## gender:result 1 0.289 0.289 0.1814 0.671683
## Residuals 61 97.169 1.593
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response x2_p :
## Df Sum Sq Mean Sq F value Pr(>F)
## gender 1 37.87 37.871 2.8349 0.09735 .
## result 1 0.71 0.712 0.0533 0.81817
## gender:result 1 0.01 0.005 0.0004 0.98455
## Residuals 61 814.89 13.359
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response x3_p :
## Df Sum Sq Mean Sq F value Pr(>F)
## gender 1 2.402 2.4016 1.4581 0.23190
## result 1 11.000 10.9998 6.6783 0.01217 *
## gender:result 1 1.244 1.2441 0.7553 0.38821
## Residuals 61 100.474 1.6471
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Response x4_p :
## Df Sum Sq Mean Sq F value Pr(>F)
## gender 1 81.0 81.007 0.7670 0.3846
## result 1 34.5 34.469 0.3264 0.5699
## gender:result 1 17.2 17.237 0.1632 0.6876
## Residuals 61 6442.4 105.613