x <- c(1,2,3,3,4,5,6,8,9,11,18.95,19,17.95,15.54,14,12.95,8.94,7.49,6,3.99)
data1 <- matrix(x, nrow = 10, ncol = 2)
data1
## [,1] [,2]
## [1,] 1 18.95
## [2,] 2 19.00
## [3,] 3 17.95
## [4,] 3 15.54
## [5,] 4 14.00
## [6,] 5 12.95
## [7,] 6 8.94
## [8,] 8 7.49
## [9,] 9 6.00
## [10,] 11 3.99
library(ggplot2)
# Create the matrix data
x <- c(1,2,3,3,4,5,6,8,9,11,18.95,19,17.95,15.54,14,12.95,8.94,7.49,6,3.99)
data1 <- matrix(x, nrow = 10, ncol = 2)
data <- as.data.frame(data1) # Convert matrix to data frame for ggplot
# Rename the columns for easier reference
colnames(data) <- c("Value1", "Value2")
# Create a dense plot
ggplot(data, aes(x = Value1, y = Value2)) +
geom_point() + # Scatter plot
geom_density2d() + # Add 2D density contour
theme_minimal() + # Apply a minimal theme
labs(title = "Dense Plot", x = "Value 1", y = "Value 2")
library(MVN)
## Warning: package 'MVN' was built under R version 4.3.3
mardia <- mvn(data, mvnTest = c("mardia"), covariance = TRUE, multivariatePlot = "qq")
mardia
## $multivariateNormality
## Test Statistic p value Result
## 1 Mardia Skewness 1.95064645799407 0.744836026278334 YES
## 2 Mardia Kurtosis -0.67771643560724 0.497951503442355 YES
## 3 MVN <NA> <NA> YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Anderson-Darling Value1 0.2596 0.6287 YES
## 2 Anderson-Darling Value2 0.3241 0.4589 YES
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## Value1 10 5.200 3.259175 4.500 1.00 11 3.0000 7.5000 0.4117889 -1.345329
## Value2 10 12.481 5.554671 13.475 3.99 19 7.8525 17.3475 -0.1806222 -1.709567
Dari hasil R diatas akan dilakukan pengujian hipotesis terhadap mardia skewness test sebagai berikut :
Ho : Peubah ganda mengikuti distribusi normal
H1 : Peubah ganda tidak mengikuti distribusi normal
Sehingga dikesimpulan p-value = 0.7448 & 0.4979 > α = 0.05 yaitu tak tolak Ho. Artinya, bahwa peubah ganda mengikuti distribusi normal. Dari Q-Q plot yang dihasilkan dari output R dibawah ini juga menunjukan bahwa sebaran dari data mengikuti distribusi normal.
henze<-mvn(data, mvnTest = c("hz"), covariance = TRUE, multivariatePlot = "none")
henze
## $multivariateNormality
## Test HZ p value MVN
## 1 Henze-Zirkler 0.2363198 0.7425679 YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Anderson-Darling Value1 0.2596 0.6287 YES
## 2 Anderson-Darling Value2 0.3241 0.4589 YES
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## Value1 10 5.200 3.259175 4.500 1.00 11 3.0000 7.5000 0.4117889 -1.345329
## Value2 10 12.481 5.554671 13.475 3.99 19 7.8525 17.3475 -0.1806222 -1.709567
Dari Henze-Zirkler’s Multivariate Normality Test menghasilkan nilai p-value = 0.7425 > α = 0.05. Hal ini berarti data mendukung untuk Terima Ho, dengan demikian dapat dikatakan bahwa peubah-peubah tersebut mengikuti distribusi normal ganda.
royston<-mvn(data, mvnTest = c("royston"), covariance = TRUE, multivariatePlot = "persp")
royston
## $multivariateNormality
## Test H p value MVN
## 1 Royston 0.2596638 0.3587813 YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Anderson-Darling Value1 0.2596 0.6287 YES
## 2 Anderson-Darling Value2 0.3241 0.4589 YES
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## Value1 10 5.200 3.259175 4.500 1.00 11 3.0000 7.5000 0.4117889 -1.345329
## Value2 10 12.481 5.554671 13.475 3.99 19 7.8525 17.3475 -0.1806222 -1.709567
Dari Royston Test menghasilkan nilai p-value = 0.3587 > α = 0.05. Hasil uji ini juga menunjukkan data mendukung untuk tak tolak Ho, dengan demikian dapat dikatakan bahwa peubah-peubah tersebut mengikuti distribusi normal ganda.
royston<-mvn(data, mvnTest = c("royston"), covariance = TRUE, multivariatePlot = "contour")
royston
## $multivariateNormality
## Test H p value MVN
## 1 Royston 0.2596638 0.3587813 YES
##
## $univariateNormality
## Test Variable Statistic p value Normality
## 1 Anderson-Darling Value1 0.2596 0.6287 YES
## 2 Anderson-Darling Value2 0.3241 0.4589 YES
##
## $Descriptives
## n Mean Std.Dev Median Min Max 25th 75th Skew Kurtosis
## Value1 10 5.200 3.259175 4.500 1.00 11 3.0000 7.5000 0.4117889 -1.345329
## Value2 10 12.481 5.554671 13.475 3.99 19 7.8525 17.3475 -0.1806222 -1.709567
Berdasarkan beberapa uji normalitas ganda di atas, dapat disimpulkan bahwa data menyebar bivariat normal sehingga tidak perlu dilakukan penanganan lanjutan terhadap data tersebut. Data dikatakan bivariat normal karena berdasarkan uji normalitas ganda di atas disimpulkan bahwa tidak tolak H0. Artinya tidak cukup bukti untuk menyatakan bahwa peubah ganda tidak berdistribusi normal.