library(readxl)
data_bps <- read_excel("D:/Matana/Semester 5/ANALISIS MULTIVARIAT/data CCA.xlsx")
data_bps
## # A tibble: 34 × 7
## Provinsi IPM UMP Tingkat Partisipasi …¹ TPT Persentase Penduduk …²
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Aceh 74.7 3.17e6 64.8 6.03 12.6
## 2 Sumatera Ut… 75.1 2.50e6 71.1 5.89 7.19
## 3 Sumatera Ba… 75.6 2.48e6 69.6 5.94 5.42
## 4 Riau 75.0 2.89e6 64.4 4.23 6.36
## 5 Jambi 73.7 2.63e6 68.8 4.53 7.26
## 6 Sumatera Se… 73.2 3.04e6 70.7 4.11 10.5
## 7 Bengkulu 74.3 2.21e6 70.9 3.42 12.5
## 8 Lampung 72.5 2.43e6 70.0 4.23 10.6
## 9 Kepulauan B… 74.1 3.23e6 68.3 4.56 5.08
## 10 Kepulauan R… 79.1 3.01e6 68.7 6.8 4.78
## # ℹ 24 more rows
## # ℹ abbreviated names: ¹`Tingkat Partisipasi Angkatan Kerja`,
## # ²`Persentase Penduduk Miskin`
## # ℹ 1 more variable: `Rata rata lama sekolah` <dbl>
#Variabel
# Pisahkan X dan Y
X <- data_bps[, c("IPM", "UMP", "Tingkat Partisipasi Angkatan Kerja")]
Y <- data_bps[, c("TPT", "Persentase Penduduk Miskin", "Rata rata lama sekolah")]
library(CCA)
## Loading required package: fda
## Loading required package: splines
## Loading required package: fds
## Loading required package: rainbow
## Loading required package: MASS
## Loading required package: pcaPP
## Loading required package: RCurl
## Loading required package: deSolve
##
## Attaching package: 'fda'
## The following object is masked from 'package:graphics':
##
## matplot
## Loading required package: fields
## Loading required package: spam
## Spam version 2.11-1 (2025-01-20) is loaded.
## Type 'help( Spam)' or 'demo( spam)' for a short introduction
## and overview of this package.
## Help for individual functions is also obtained by adding the
## suffix '.spam' to the function name, e.g. 'help( chol.spam)'.
##
## Attaching package: 'spam'
## The following objects are masked from 'package:base':
##
## backsolve, forwardsolve
## Loading required package: viridisLite
##
## Try help(fields) to get started.
library(CCP)
cca_res <- cancor(X, Y)
cca_res$cor # nilai korelasi kanonik
## [1] 0.8445058 0.6133588 0.2951660
berikut merupakan koefisien dari variabel X dan juga variabel Y
cca_res$xcoef # loadings (koef variabel X)
## [,1] [,2] [,3]
## IPM 3.833496e-02 -1.378376e-02 -2.238891e-02
## UMP 1.190981e-07 -1.619416e-07 3.211359e-07
## Tingkat Partisipasi Angkatan Kerja -8.916420e-03 -6.090510e-02 1.337475e-02
cca_res$ycoef # loadings (koef variabel Y)
## [,1] [,2] [,3]
## TPT 0.0006428904 0.137951269 -0.03171617
## Persentase Penduduk Miskin -0.0225981930 0.009855873 0.03230794
## Rata rata lama sekolah 0.1437263042 -0.075885424 0.17777459
melakukan wilks test
# n = jumlah provinsi (baris)
n <- nrow(X)
p <- ncol(X)
q <- ncol(Y)
# Wilks’ lambda test
p_asym <- p.asym(cca_res$cor, n, p, q, tstat = "Wilks")
## Wilks' Lambda, using F-approximation (Rao's F):
## stat approx df1 df2 p.value
## 1 to 3: 0.1633224 8.388821 9 68.29525 2.608228e-08
## 2 to 3: 0.5694445 4.715085 4 58.00000 2.308849e-03
## 3 to 3: 0.9128770 2.863134 1 30.00000 1.009939e-01
p_asym
## $id
## [1] "Wilks"
##
## $stat
## [1] 0.1633224 0.5694445 0.9128770
##
## $approx
## [1] 8.388821 4.715085 2.863134
##
## $df1
## [1] 9 4 1
##
## $df2
## [1] 68.29525 58.00000 30.00000
##
## $p.value
## [1] 2.608228e-08 2.308849e-03 1.009939e-01
berdasarkan hasil uji wilks’, didapatkan hasil bahwa pasangan kanonik 1 dengan 3 dan 2 dengan 3 menunjukkan hasil yang signifikan . namun, pasangan kombinasi kanonik ketiga menunjukkan nilai p-value yang lebih besar daripada 0.005 sehingga hal ini membuktikan bahwa kombinasi kanonik ketiga tidak signifikan.