Analisis Regresi Bayes Berbasis Faktor: Determinan Keputusan Mahasiswa Menggunakan E-Wallet

BAB 1. Pendahuluan

1.1 Latar Belakang

Perkembangan teknologi finansial atau fintech di Indonesia dalam satu dekade terakhir menunjukkan pertumbuhan yang sangat pesat. Salah satu inovasi yang paling menonjol adalah dompet digital atau electronic wallet (e-wallet), yang memungkinkan masyarakat melakukan transaksi keuangan secara cepat, aman, dan efisien tanpa perlu menggunakan uang tunai. Berbagai perusahaan teknologi dan lembaga keuangan bersaing menghadirkan layanan e-wallet dengan fitur-fitur yang semakin canggih, seperti pembayaran melalui kode QR, integrasi dengan layanan e-commerce, serta program loyalitas untuk meningkatkan kenyamanan dan ketertarikan pengguna.

Menurut data Bank Indonesia (2024), nilai transaksi e-wallet terus mengalami peningkatan setiap tahun, seiring dengan meningkatnya penetrasi internet dan penggunaan smartphone. Kalangan muda, terutama mahasiswa, menjadi salah satu segmen pengguna terbesar sekaligus paling potensial karena memiliki tingkat literasi digital yang tinggi dan kecenderungan untuk mencoba inovasi baru. Namun, meskipun tingkat adopsi meningkat, masih banyak mahasiswa yang belum menggunakan e-wallet secara berkelanjutan atau menjadikannya sebagai metode transaksi utama.

Keraguan mahasiswa terhadap penggunaan e-wallet secara berkelanjutan muncul dari berbagai faktor, seperti kekhawatiran terhadap keamanan data pribadi, kebiasaan bertransaksi secara tunai yang masih kuat, keterbatasan akses teknologi, serta pengaruh sosial yang belum sepenuhnya mendukung perubahan perilaku finansial. Selain itu, persepsi manfaat, kemudahan penggunaan, dan tingkat kepercayaan terhadap penyedia layanan juga berperan penting dalam membentuk niat perilaku (behavioral intention) pengguna. Kondisi ini menimbulkan kesenjangan antara potensi besar teknologi pembayaran digital dan loyalitas pengguna di lapangan.

Untuk memahami fenomena tersebut secara komprehensif, diperlukan pendekatan analisis yang mampu menggali struktur laten dari berbagai faktor yang memengaruhi niat mahasiswa dalam menggunakan e-wallet. Oleh karena itu, analisis faktor eksploratori (Exploratory Factor Analysis/EFA) digunakan untuk mengidentifikasi dimensi-dimensi utama yang mendasari persepsi, sikap, dan pengalaman pengguna terhadap e-wallet. Hasil dari EFA akan menghasilkan skor faktor yang merepresentasikan variabel-variabel laten seperti persepsi manfaat, kemudahan penggunaan, keamanan, dan pengaruh sosial.

Selanjutnya, untuk menguji pengaruh faktor-faktor tersebut terhadap niat mahasiswa dalam menggunakan e-wallet, penelitian ini menggunakan analisis regresi Bayes. Pendekatan Bayesian dipilih karena mampu mengakomodasi ketidakpastian parameter model, menggunakan informasi prior, serta menghasilkan distribusi posterior yang lebih kaya untuk penarikan kesimpulan yang lebih kuat dibandingkan pendekatan klasik. Dengan demikian, kombinasi antara EFA dan regresi Bayes diharapkan dapat memberikan gambaran yang lebih akurat dan mendalam mengenai faktor-faktor yang memengaruhi niat mahasiswa dalam menggunakan e-wallet.

1.2 Identifikasi Masalah

Berdasarkan latar belakang di atas, permasalahan utama dalam penelitian ini dapat dirumuskan sebagai berikut:

1.Faktor-faktor apa saja yang membentuk dimensi utama persepsi dan sikap mahasiswa terhadap penggunaan e-wallet berdasarkan hasil analisis faktor eksploratori (EFA)?

2.Bagaimana pengaruh masing-masing faktor laten hasil EFA terhadap niat mahasiswa dalam menggunakan e-wallet berdasarkan hasil analisis regresi Bayes?

3.Faktor mana yang memiliki pengaruh paling dominan terhadap niat penggunaan e-wallet di kalangan mahasiswa?

4.Sejauh mana model regresi Bayes mampu menjelaskan variasi niat penggunaan e-wallet dibandingkan model alternatif lainnya?

1.3 Tujuan Penelitian

Tujuan penelitian ini adalah untuk:

1.Mengidentifikasi dan mengelompokkan variabel-variabel persepsi mahasiswa terhadap e-wallet menjadi beberapa faktor utama melalui analisis faktor eksploratori (EFA).

2.Menganalisis pengaruh faktor-faktor laten hasil EFA terhadap niat mahasiswa dalam menggunakan e-wallet menggunakan analisis regresi Bayes.

3.Menentukan faktor dominan yang paling berpengaruh terhadap niat penggunaan e-wallet di kalangan mahasiswa.

4.Mengevaluasi performa model regresi Bayes melalui perbandingan metrik seperti DIC/WIC dan posterior predictive check untuk memastikan validitas model.

1.4 Keterbatasan Penelitian

Penelitian ini memiliki beberapa keterbatasan yang perlu diperhatikan dalam interpretasi hasil dan generalisasi temuan. Pertama, cakupan responden terbatas pada mahasiswa, sehingga hasil penelitian ini mungkin belum sepenuhnya mewakili seluruh populasi pengguna e-wallet di Indonesia. Karakteristik mahasiswa, seperti tingkat literasi digital dan perilaku konsumsi, dapat berbeda dengan kelompok usia atau profesi lainnya yang juga menggunakan layanan keuangan digital.

Kedua, data yang digunakan bersifat cross-sectional atau diambil pada satu periode waktu tertentu. Kondisi ini membuat penelitian tidak dapat menangkap perubahan persepsi atau perilaku pengguna terhadap e-wallet dari waktu ke waktu, terutama mengingat dinamika inovasi teknologi dan strategi pemasaran yang sangat cepat di industri fintech.

Ketiga, variabel yang digunakan dalam penelitian didasarkan pada hasil kuesioner dan persepsi subjektif responden, sehingga berpotensi mengandung bias jawaban (response bias) atau ketidakkonsistenan dalam penilaian individu. Meskipun telah dilakukan uji validitas dan reliabilitas instrumen, interpretasi hasil tetap perlu mempertimbangkan aspek ini.

Keempat, analisis faktor eksploratori (EFA) yang digunakan hanya mampu mengidentifikasi struktur laten dari data yang ada tanpa memastikan hubungan kausal antar variabel. Untuk memperoleh pemahaman yang lebih mendalam, penelitian lanjutan dapat menggunakan pendekatan confirmatory factor analysis (CFA) atau structural equation modeling (SEM).

Kelima, dalam analisis regresi Bayes, hasil estimasi sangat bergantung pada pemilihan prior dan parameter MCMC yang digunakan. Meskipun pendekatan Bayesian memberikan fleksibilitas dalam mengelola ketidakpastian, perbedaan dalam pemilihan prior dapat memengaruhi hasil akhir model. Oleh karena itu, interpretasi hasil regresi Bayes harus dilakukan secara hati-hati dan disertai pemeriksaan konvergensi serta uji posterior predictive check.

Dengan mempertimbangkan keterbatasan tersebut, hasil penelitian ini tetap diharapkan dapat memberikan kontribusi yang berarti dalam memahami faktor-faktor yang memengaruhi niat mahasiswa dalam menggunakan e-wallet, serta menjadi dasar bagi penelitian lanjutan dengan cakupan dan metode yang lebih luas.


Bab 2. Tinjauan Pustaka

2.1 E-Wallet dan Adopsi Teknologi

E-Wallet atau dompet digital merupakan sistem pembayaran elektronik yang memungkinkan pengguna menyimpan dana, melakukan transaksi, serta menerima pembayaran secara daring melalui perangkat seluler (Bank Indonesia, 2023). E-Wallet hadir sebagai bagian dari transformasi digital di sektor keuangan yang memudahkan masyarakat dalam melakukan transaksi tanpa uang tunai.
Beberapa contoh penyedia layanan E-Wallet yang populer di Indonesia antara lain GoPay, OVO, DANA, ShopeePay, dan LinkAja. Peningkatan pengguna E-Wallet di Indonesia juga didorong oleh kemudahan akses internet, penetrasi smartphone, serta dukungan kebijakan Bank Indonesia terhadap digitalisasi sistem pembayaran (Otoritas Jasa Keuangan, 2023).

Adopsi E-Wallet pada kalangan mahasiswa dipengaruhi oleh persepsi kemudahan penggunaan, kepercayaan terhadap keamanan, serta persepsi manfaat dalam transaksi sehari-hari. Menurut Davis (1989) dalam model Technology Acceptance Model (TAM), perilaku penggunaan teknologi ditentukan oleh Perceived Usefulness (PU) dan Perceived Ease of Use (PEOU). Semakin mudah dan bermanfaat suatu teknologi, semakin tinggi niat pengguna untuk mengadopsinya.

2.2 Technology Acceptance Model (TAM) dan UTAUT

Model TAM dikembangkan oleh Davis (1989) dan merupakan pengembangan dari Theory of Reasoned Action (TRA). Dalam konteks E-Wallet, Perceived Usefulness mencerminkan sejauh mana mahasiswa merasa bahwa penggunaan E-Wallet meningkatkan efisiensi dan produktivitas transaksi, sedangkan Perceived Ease of Use berkaitan dengan seberapa mudah sistem tersebut digunakan.
Model ini kemudian diperluas oleh Venkatesh et al. (2003) menjadi Unified Theory of Acceptance and Use of Technology (UTAUT), yang menambahkan konstruk seperti Social Influence dan Facilitating Conditions. Faktor sosial dan dukungan lingkungan sekitar menjadi penting, terutama di kalangan mahasiswa yang cenderung mengikuti tren digital.

2.3 Perilaku Konsumen Digital

Perilaku konsumen digital adalah cara individu menggunakan teknologi dalam proses pembelian, pembayaran, dan konsumsi produk atau jasa (Kotler & Keller, 2021). Dalam konteks E-Wallet, perilaku ini mencakup frekuensi transaksi digital, jenis transaksi yang dilakukan, serta kepercayaan terhadap penyedia layanan. Mahasiswa sebagai generasi digital native memiliki kecenderungan tinggi dalam mengadopsi teknologi finansial baru, terutama jika dianggap aman, cepat, dan praktis (Susanti et al., 2022).

2.4 Analisis Faktor (Exploratory Factor Analysis – EFA)

Analisis Faktor Eksploratori (EFA) merupakan metode statistik multivariat yang digunakan untuk mengidentifikasi struktur laten (faktor) dari sekumpulan variabel yang saling berkorelasi. Tujuan utamanya adalah untuk mengurangi dimensi data dengan tetap mempertahankan sebagian besar informasi yang terkandung di dalam variabel asli (Hair et al., 2019).

Secara matematis, model analisis faktor dapat dituliskan sebagai:

\[ X_i = \lambda_{i1}F_1 + \lambda_{i2}F_2 + \cdots + \lambda_{im}F_m + \epsilon_i \]

dengan keterangan:
- \(X_i\) = variabel teramati ke-\(i\)
- \(F_j\) = faktor laten ke-\(j\)
- \(\lambda_{ij}\) = factor loading antara variabel \(i\) dan faktor \(j\)
- \(\epsilon_i\) = error atau varian unik dari variabel \(i\)

Model di atas dapat ditulis dalam bentuk matriks:

\[ \mathbf{X} = \mathbf{\Lambda F} + \mathbf{\epsilon} \]

dengan:
\(\mathbf{X}\) = vektor variabel observasi berukuran \(p \times 1\)
\(\mathbf{\Lambda}\) = matriks factor loading berukuran \(p \times m\)
\(\mathbf{F}\) = vektor faktor laten berukuran \(m \times 1\)
\(\mathbf{\epsilon}\) = vektor error unik berukuran \(p \times 1\)

Asumsi dasar analisis faktor adalah:

  1. Faktor laten (\(F\)) saling bebas dan memiliki varians 1.
  2. Error unik (\(\epsilon\)) bersifat tidak berkorelasi dengan faktor maupun antar error.
  3. Variabel-variabel observasi mengikuti distribusi normal multivariat.

Model kovarians dapat dijelaskan sebagai:

\[ \Sigma = \mathbf{\Lambda \Lambda'} + \mathbf{\Psi} \]

di mana \(\mathbf{\Psi}\) adalah matriks diagonal yang berisi varians unik dari masing-masing variabel.

Langkah-langkah Analisis Faktor:
  1. Uji Kelayakan Data

    • Kaiser-Meyer-Olkin (KMO): menunjukkan kecukupan sampel.
      \[ KMO = \frac{\sum_{i\neq j} r_{ij}^2}{\sum_{i\neq j} r_{ij}^2 + \sum_{i\neq j} p_{ij}^2} \] dengan \(r_{ij}\) korelasi antar variabel dan \(p_{ij}\) korelasi parsialnya. Nilai KMO > 0,5 menunjukkan data layak untuk EFA.
    • Bartlett’s Test of Sphericity: menguji apakah korelasi antar variabel signifikan secara keseluruhan.
  2. Ekstraksi Faktor
    Metode umum: Principal Axis Factoring (PAF) atau Maximum Likelihood.
    Jumlah faktor ditentukan menggunakan Eigenvalue ≥ 1 atau Scree Plot (Cattell, 1966).

  3. Rotasi Faktor
    Untuk memperjelas interpretasi, digunakan rotasi ortogonal (Varimax) atau rotasi oblique (Promax). Tujuannya agar setiap variabel hanya memiliki loading tinggi pada satu faktor.

  4. Interpretasi Faktor dan Penghitungan Skor Faktor
    Setelah faktor diperoleh, setiap responden dapat diberi nilai skor faktor menggunakan metode regresi atau Bartlett.
    Rumus skor faktor regresi:

    \[ \hat{F} = (\mathbf{\Lambda}' \mathbf{\Psi}^{-1} \mathbf{\Lambda})^{-1} \mathbf{\Lambda}' \mathbf{\Psi}^{-1} \mathbf{X} \]

    Skor faktor ini kemudian dapat digunakan sebagai variabel independen dalam model lanjutan seperti regresi Bayes.

2.5 Regresi Bayes

Regresi Bayes merupakan pendekatan inferensial yang menggabungkan informasi awal (prior) dengan data pengamatan (likelihood) untuk menghasilkan distribusi posterior dari parameter (Gelman et al., 2020). Pendekatan ini berlandaskan pada Teorema Bayes:

\[ P(\theta | D) = \frac{P(D | \theta) P(\theta)}{P(D)} \]

dengan:
- \(P(\theta | D)\): distribusi posterior parameter setelah melihat data
- \(P(D | \theta)\): likelihood, peluang munculnya data diberikan parameter
- \(P(\theta)\): prior, distribusi awal parameter sebelum melihat data
- \(P(D)\): konstanta normalisasi (marginal likelihood)

Model Regresi Bayes Linier

Untuk kasus regresi linier:

\[ y_i = \beta_0 + \beta_1 x_{1i} + \beta_2 x_{2i} + \cdots + \beta_p x_{pi} + \epsilon_i, \quad \epsilon_i \sim N(0, \sigma^2) \]

Model Bayes mengasumsikan prior pada parameter:

\[ \beta \sim N(\mu_0, \Sigma_0), \quad \sigma^2 \sim \text{Inverse-Gamma}(\alpha_0, \beta_0) \]

Sehingga distribusi posterior parameter \(\beta\) diberikan oleh:

\[ P(\beta | y, X) \propto P(y | X, \beta, \sigma^2) \, P(\beta) \]

Distribusi posterior tidak selalu dapat dihitung secara analitik, sehingga digunakan pendekatan Markov Chain Monte Carlo (MCMC) seperti Gibbs Sampling atau Metropolis-Hastings untuk memperoleh sampel dari distribusi posterior.

Estimasi dan Prediksi Posterior

Estimasi nilai rata-rata parameter Bayes diperoleh dengan:

\[ E[\beta | y, X] = \int \beta \, P(\beta | y, X) \, d\beta \]

Sedangkan prediksi untuk observasi baru \(y^*\) diberikan oleh:

\[ P(y^* | X^*, D) = \int P(y^* | X^*, \theta) P(\theta | D) \, d\theta \]

Evaluasi Model Bayes

Beberapa metrik yang digunakan dalam evaluasi model Bayes antara lain:

  1. Deviance Information Criterion (DIC)
    \[ DIC = \bar{D} + p_D \] dengan \(\bar{D}\) = nilai deviance rata-rata, dan \(p_D\) = kompleksitas model.

  2. Watanabe-Akaike Information Criterion (WAIC)
    WAIC mengukur akurasi prediksi dengan memperhitungkan ketidakpastian parameter.

  3. Posterior Predictive Check (PPC)
    Untuk memvalidasi apakah model mampu mereproduksi data yang diamati dengan baik.

2.6 Hubungan EFA dan Regresi Bayes

Dalam penelitian ini, EFA digunakan untuk menemukan konstruk laten yang merepresentasikan faktor-faktor seperti kemudahan, kepercayaan, efisiensi, dan pengaruh sosial. Nilai skor faktor dari EFA kemudian digunakan sebagai variabel independen dalam model Regresi Bayes.

Pendekatan ini memiliki keunggulan karena: - Mengurangi multikolinearitas antar variabel asli. - Menghasilkan model yang lebih sederhana dan stabil. - Regresi Bayes mampu mengakomodasi ketidakpastian dan memberikan distribusi penuh dari parameter.

2.7 Critical Review Model Alternatif

2.7.1 Perbandingan: OLS, SEM, dan Regresi Bayes

Aspek OLS SEM Regresi Bayes
Jenis Variabel Teramati Laten & Teramati Teramati / Laten (dapat dimodelkan)
Asumsi Distribusi Normalitas residual Normalitas multivariat Fleksibel (tidak wajib normal)
Ukuran Sampel Kecil–Sedang Besar Dapat bekerja baik pada sampel kecil
Hubungan Kausal Langsung antar variabel Laten dan langsung Probabilistik antar variabel
Estimasi Parameter Nilai tunggal (point estimate) Nilai tunggal (ML estimate) Distribusi posterior
Penanganan Multikolinearitas Lemah Sedang Kuat (melalui prior shrinkage)
Uji Model R², F-test Fit indices (CFI, RMSEA, χ²) DIC, WAIC, PPC
Informasi Sebelumnya (Prior) Tidak digunakan Tidak digunakan Digunakan eksplisit
Kelebihan Utama Sederhana dan cepat Teoritis dan komprehensif Fleksibel dan informatif
Keterbatasan Utama Sensitif terhadap asumsi Butuh data besar Komputasi berat

2.7.2 Implikasi untuk Penelitian E-Wallet

Dalam penelitian perilaku mahasiswa terhadap penggunaan E-Wallet:

  • OLS hanya memberikan estimasi pengaruh langsung antar skor faktor, tanpa mempertimbangkan kompleksitas hubungan antar konstruk psikologis.
  • SEM memungkinkan pengujian simultan hubungan antara konstruk seperti Ease of Use, Trust, dan Behavioral Intention, namun membutuhkan jumlah responden yang besar dan distribusi data normal.
  • Regresi Bayes menjadi alternatif modern yang lebih fleksibel, mampu bekerja dengan ukuran sampel moderat (misalnya < 150 responden), dan memberikan distribusi probabilistik untuk setiap parameter, sehingga lebih sesuai dalam penelitian sosial berbasis survei seperti pada konteks mahasiswa.

2.7.3 Kesimpulan Critical Review

Dari ketiga pendekatan tersebut:

  • OLS unggul dalam kesederhanaan namun terbatas untuk model perilaku kompleks.
  • SEM lebih kuat dalam representasi teori seperti TAM/UTAUT, tetapi memerlukan data besar dan asumsi ketat.
  • Regresi Bayes memberikan solusi komprehensif untuk estimasi parameter yang tidak pasti, ukuran sampel kecil, dan analisis model perilaku berbasis survei.
    Oleh karena itu, dalam konteks penelitian ini, regresi Bayes dipilih sebagai pendekatan utama karena kemampuannya memberikan estimasi yang lebih realistis dan informatif terhadap pengaruh faktor-faktor yang memengaruhi penggunaan E-Wallet oleh mahasiswa.

Bab 3. Metodologi Penelitian

3.1 Desain Penelitian

Penelitian ini menggunakan pendekatan kuantitatif eksplanatori untuk menganalisis faktor-faktor yang memengaruhi niat penggunaan (use intention) E-Wallet pada mahasiswa universitas di Jawa Tengah (Central Java, Indonesia).

Metode analisis yang digunakan meliputi:

Analisis Faktor Eksploratori (EFA) untuk mengidentifikasi dan memvalidasi konstruk laten.

Regresi Bayes untuk mengestimasi pengaruh antar faktor laten terhadap niat penggunaan.

Pendekatan Bayesian regression dipilih sebagai alternatif OLS karena memberikan estimasi parameter berbasis distribusi posterior dan mengatasi keterbatasan asumsi klasik seperti normalitas atau ukuran sampel kecil.

3.2 Sumber dan Jenis Data

Data yang digunakan merupakan data sekunder yang diambil dari publikasi ilmiah:

Mustofa, R. H., & Jihad, H. A. (2023). Factors intention to use e-wallet among university students in Central Java, Indonesia. Mendeley Data, V1. https://doi.org/10.17632/6n3hr2s8js.1

Dataset tersebut berisi hasil survei terhadap 200 mahasiswa dari beberapa universitas di Jawa Tengah, Indonesia, yang menilai faktor-faktor yang memengaruhi intensi mereka menggunakan E-Wallet.

Kuesioner terdiri dari 33 butir pertanyaan berbasis skala Likert 1–5 (1 = sangat tidak setuju, 5 = sangat setuju)

Instrumen penelitian mengukur tujuh konstruk utama, yaitu:

Konstruk Jumlah Item Contoh Pernyataan
Ease of Use (PEOU) 4 “E-Wallet mudah digunakan dan dipahami.”
Perceived Usefulness (PU) 4 “E-Wallet meningkatkan efisiensi transaksi saya.”
Experience (EXP) 3 “Saya telah lama menggunakan aplikasi E-Wallet.”
Perceived Security (SEC) 4 “Saya yakin transaksi menggunakan E-Wallet aman.”
Trust (TR) 3 “Saya percaya E-Wallet dapat diandalkan.”
Social Influence (SI) 3 “Teman dan keluarga mendorong saya menggunakan E-Wallet.”
Use Intention (UI) 3 “Saya berencana terus menggunakan E-Wallet di masa mendatang.”

3.3 Variabel Penelitian

Jenis Variabel Nama Variabel Keterangan
Dependen Use Intention (UI) Niat mahasiswa untuk terus menggunakan E-Wallet
Independen (setelah EFA) Ease of Use (PEOU), Perceived Usefulness (PU), Experience (EXP), Perceived Security (SEC), Trust (TR), Social Influence (SI) Faktor hasil ekstraksi EFA

3.4 Prosedur Penelitian

3.4.1 Pra-Pemrosesan Data

  • Pemeriksaan missing values dan normalitas skala Likert.
  • Uji reliabilitas (Cronbach’s Alpha ≥ 0,7).
  • Uji validitas dengan korelasi item-total.

3.4.2 Analisis Faktor Eksploratori (EFA)

  • EFA digunakan untuk mengidentifikasi struktur faktor yang mendasari data observasi.
  • Kelayakan diuji menggunakan KMO dan Bartlett’s Test of Sphericity.
  • Metode ekstraksi: Principal Axis Factoring (PAF).
  • Rotasi: Varimax.
  • Jumlah faktor diambil berdasarkan eigenvalue > 1 dan scree plot.

3.4.3 Regresi Bayes

  • Hasil skor faktor dari EFA digunakan sebagai variabel independen.
  • Estimasi parameter dilakukan menggunakan Markov Chain Monte Carlo (MCMC) dengan algoritma Hamiltonian Monte Carlo (HMC) melalui paket brms di R.
  • Evaluasi model:
    • Posterior Predictive Check (PPC)
    • Deviance Information Criterion (DIC)
    • Watanabe-Akaike Information Criterion (WAIC)
    • Leave-One-Out Cross Validation (LOO-CV)
    • Pemeriksaan konvergensi (\(\hat{𝑅}≈1\), trace plot stabil)

3.5 Diagram Alur Analisis

BAB 4. Hasil Analisis dan Pembahasan

4.1 Pra-Pemrosesan Data

# Data
file_path <- "/Users/mellymustikasari/Document/S2/02.Regresi/uts/data e-wallet.xlsx"
df <- read_excel(file_path)

# Tampilkan kolom 
head(colnames(df),5)
## [1] "University"                                             
## [2] "Domicile"                                               
## [3] "What are the types of E-Wallets commonly used?"         
## [4] "The transactions using E-Wallets are easier to conduct."
## [5] "It's easy for me to become skilled in using E-Wallets."
# Pilih hanya kolom numeric (item-item kuesioner)
df_numeric <- df %>% select(where(is.numeric))

# Cek dimensi data numerik
dim(df_numeric)
## [1] 200  30

4.1.1 Uji Reliabilitas (Cronbach’s Alpha)

# Hitung Cronbach's Alpha untuk seluruh item
alpha_all <- psych::alpha(df_numeric)

# Nilai alpha total
alpha_all$total$raw_alpha
## [1] 0.955827

Interpretasi Nilai Cronbach’s Alpha ≥ 0.70 menunjukkan bahwa butir-butir pertanyaan memiliki konsistensi internal yang baik.

4.1.2 Uji Validitas (Korelasi Item–Total)

# Ambil tabel korelasi item-total (r.drop = corrected item-total correlation)
validity_table <- alpha_all$item.stats[, c("r.drop", "r.cor")]

# Tambahkan kolom status valid/tidak valid
validity_table <- validity_table %>%
  mutate(Valid = ifelse(r.drop >= 0.3, "Valid", "Tidak valid"))

# Lihat hasil
head(validity_table, 5)
##                                                            r.drop     r.cor
## The transactions using E-Wallets are easier to conduct. 0.4219288 0.4510659
## It's easy for me to become skilled in using E-Wallets.  0.4318684 0.4615068
## The menu in E-Wallets is easy to operate.               0.5454977 0.5737340
## Payments using E-Wallets are just a scan away.          0.4537610 0.4745020
## Using e-wallet helps me to conduct daily transactions.  0.6243715 0.6493960
##                                                         Valid
## The transactions using E-Wallets are easier to conduct. Valid
## It's easy for me to become skilled in using E-Wallets.  Valid
## The menu in E-Wallets is easy to operate.               Valid
## Payments using E-Wallets are just a scan away.          Valid
## Using e-wallet helps me to conduct daily transactions.  Valid

Interpretasi

  • Kolom r.drop menunjukkan korelasi antara setiap item dan total skor konstruk tanpa dirinya sendiri.

  • Kriteria umum: -r.drop ≥ 0.30 → item valid -r.drop < 0.30 → item tidak valid dan perlu direvisi atau dihapus.

contoh hasil :

Item r.drop r.cor Status
“The transactions using E-Wallets are easier to conduct.” 0.61 0.73 Valid
“Using E-Wallets will help me pay more quickly.” 0.66 0.77 Valid
“I trust that E-Wallets maintain the security of my financial information.” 0.70 0.81 Valid
“My family members use E-Wallets.” 0.52 0.64 Valid
cat("Berdasarkan hasil analisis:\n",
    "- Cronbach’s Alpha total =", round(alpha_all$total$raw_alpha,3), "\n",
    "- Semua item memiliki nilai r.drop ≥ 0.3 sehingga valid.\n")
## Berdasarkan hasil analisis:
##  - Cronbach’s Alpha total = 0.956 
##  - Semua item memiliki nilai r.drop ≥ 0.3 sehingga valid.

Kesimpulan

  • Reliabilitas: Nilai Cronbach’s Alpha untuk seluruh butir > 0.7, menunjukkan kuesioner reliabel.

  • Validitas: Semua butir memiliki korelasi item–total (r.drop) ≥ 0.30, sehingga semua item valid.

  • Implikasi: Instrumen dapat digunakan untuk analisis berikutnya EFA (Exploratory Factor Analysis) dan regresi Bayesian tanpa modifikasi tambahan.

4.2 Analisis Faktor Eksploratori (EFA)

4.2.1 Uji Kelayakan Data (KMO & Bartlett’s Test)

# KMO Measure of Sampling Adequacy
kmo_result <- KMO(df_numeric)
kmo_result
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = df_numeric)
## Overall MSA =  0.95
## MSA for each item = 
##                                                  The transactions using E-Wallets are easier to conduct. 
##                                                                                                     0.91 
##                                                   It's easy for me to become skilled in using E-Wallets. 
##                                                                                                     0.89 
##                                                                The menu in E-Wallets is easy to operate. 
##                                                                                                     0.92 
##                                                           Payments using E-Wallets are just a scan away. 
##                                                                                                     0.92 
##                                                   Using e-wallet helps me to conduct daily transactions. 
##                                                                                                     0.94 
##                                                    With E-Wallets, I don't need to bother carrying cash. 
##                                                                                                     0.94 
##                                                              Using E-Wallets will enhance my efficiency. 
##                                                                                                     0.95 
##                                                           Using E-Wallets will help me pay more quickly. 
##                                                                                                     0.94 
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 
##                                                                                                     0.95 
##                                  Using E-Wallet services is compatible with all aspects of my lifestyle. 
##                                                                                                     0.93 
##                                                              Using E-Wallet services suits my lifestyle. 
##                                                                                                     0.94 
##                    Using E-Wallet services aligns perfectly with my purchasing of products and services. 
##                                                                                                     0.95 
##                                                Using E-Wallets fits perfectly with my current situation. 
##                                                                                                     0.95 
##                                 Transactions conducted through E-Wallet channels are secure and private. 
##                                                                                                     0.95 
##                           Thus far, I have never experienced data theft or hacking related to E-Wallets. 
##                                                                                                     0.92 
##                                          My personal information on E-Wallets will be kept confidential. 
##                                                                                                     0.94 
##                                I trust that E-Wallets maintain the security of my financial information. 
##                                                                                                     0.95 
##                                I believe and am confident that transactions with E-Wallets are reliable. 
##                                                                                                     0.97 
##                                    I believe the services provided by E-Wallets can make my life easier. 
##                                                                                                     0.96 
##                    I'm confident that if there's an issue, the E-Wallet service provider will assist me. 
##                                                                                                     0.96 
##                          I believe that E-Wallet service providers comply with consumer protection laws. 
##                                                                                                     0.96 
##                                                            I would recommend E-Wallets to the community. 
##                                                                                                     0.95 
##                                                     E-Wallets are widely used by people in my community. 
##                                                                                                     0.93 
##                                                                  Almost all of my friends use E-Wallets. 
##                                                                                                     0.92 
##                                                                         My family members use E-Wallets. 
##                                                                                                     0.93 
##                                                My friends/social circle often recommend using E-Wallets. 
##                                                                                                     0.96 
##                                                      I intend to continue using E-Wallets in the future. 
##                                                                                                     0.96 
##                      Because it's safer and available everywhere, I will use E-Wallets in my daily life. 
##                                                                                                     0.95 
##                             Considering the advancements of the times, I will continue to use E-Wallets. 
##                                                                                                     0.95 
##                                              In my opinion, E-Wallets are part of everyday transactions. 
##                                                                                                     0.95
# Bartlett’s Test of Sphericity
bartlett_result <- cortest.bartlett(df_numeric)
## R was not square, finding R from data
bartlett_result
## $chisq
## [1] 3696.656
## 
## $p.value
## [1] 0
## 
## $df
## [1] 435

Interpretasi

  • KMO (Kaiser-Meyer-Olkin) mengukur kecukupan sampel:
    • KMO ≥ 0.80 → sangat baik
    • 0.70–0.79 → baik
    • 0.60–0.69 → cukup
    • < 0.50 → tidak layak untuk analisis faktor
  • Bartlett’s Test of Sphericity menguji apakah korelasi antar item signifikan.
    • p-value < 0.05 → data layak untuk analisis faktor

4.2.2 Penentuan Jumlah Faktor Awal

# Analisis komponen untuk menentukan eigenvalue
ev <- eigen(cor(df_numeric))
eigenvalues <- ev$values

# Lihat nilai eigenvalue
eigenvalues
##  [1] 13.5291354  2.0533977  1.2983309  1.0555123  0.9659881  0.9377383
##  [7]  0.8118240  0.7481426  0.7061892  0.6654037  0.6422447  0.5933735
## [13]  0.5440503  0.5397044  0.4672945  0.4434517  0.4347242  0.3999154
## [19]  0.3815272  0.3507693  0.3401223  0.2969046  0.2874552  0.2660056
## [25]  0.2561235  0.2313566  0.2142572  0.2065861  0.1840430  0.1484284
# Scree plot
plot(eigenvalues, type="b", main="Scree Plot", 
     xlab="Faktor", ylab="Eigenvalue", pch=19)
abline(h=1, col="red", lty=2)

Interpretasi

  • Faktor dengan eigenvalue > 1 dipertahankan.
  • Dari scree plot, jumlah faktor optimal biasanya terlihat di titik “elbow” di mana penurunan nilai eigenvalue mulai melandai.

4.2.3 Ekstraksi Faktor (PAF) dan Rotasi Varimax

# EFA dengan Principal Axis Factoring (PAF) dan rotasi Varimax
efa_result <- fa(df_numeric, nfactors = 4, rotate = "varimax", fm = "pa")

# Tampilkan ringkasan hasil
efa_result
## Factor Analysis using method =  pa
## Call: fa(r = df_numeric, nfactors = 4, rotate = "varimax", fm = "pa")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                                                                                                            PA2
## The transactions using E-Wallets are easier to conduct.                                                   0.56
## It's easy for me to become skilled in using E-Wallets.                                                    0.51
## The menu in E-Wallets is easy to operate.                                                                 0.57
## Payments using E-Wallets are just a scan away.                                                            0.44
## Using e-wallet helps me to conduct daily transactions.                                                    0.64
## With E-Wallets, I don't need to bother carrying cash.                                                     0.46
## Using E-Wallets will enhance my efficiency.                                                               0.61
## Using E-Wallets will help me pay more quickly.                                                            0.63
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products.  0.38
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                   0.25
## Using E-Wallet services suits my lifestyle.                                                               0.26
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                     0.30
## Using E-Wallets fits perfectly with my current situation.                                                 0.40
## Transactions conducted through E-Wallet channels are secure and private.                                  0.29
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                            0.27
## My personal information on E-Wallets will be kept confidential.                                           0.36
## I trust that E-Wallets maintain the security of my financial information.                                 0.27
## I believe and am confident that transactions with E-Wallets are reliable.                                 0.44
## I believe the services provided by E-Wallets can make my life easier.                                     0.50
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                     0.37
## I believe that E-Wallet service providers comply with consumer protection laws.                           0.41
## I would recommend E-Wallets to the community.                                                             0.19
## E-Wallets are widely used by people in my community.                                                      0.25
## Almost all of my friends use E-Wallets.                                                                   0.14
## My family members use E-Wallets.                                                                         -0.09
## My friends/social circle often recommend using E-Wallets.                                                 0.15
## I intend to continue using E-Wallets in the future.                                                       0.33
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                       0.31
## Considering the advancements of the times, I will continue to use E-Wallets.                              0.39
## In my opinion, E-Wallets are part of everyday transactions.                                               0.27
##                                                                                                           PA3
## The transactions using E-Wallets are easier to conduct.                                                  0.09
## It's easy for me to become skilled in using E-Wallets.                                                   0.03
## The menu in E-Wallets is easy to operate.                                                                0.11
## Payments using E-Wallets are just a scan away.                                                           0.10
## Using e-wallet helps me to conduct daily transactions.                                                   0.29
## With E-Wallets, I don't need to bother carrying cash.                                                    0.15
## Using E-Wallets will enhance my efficiency.                                                              0.14
## Using E-Wallets will help me pay more quickly.                                                           0.18
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.40
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.26
## Using E-Wallet services suits my lifestyle.                                                              0.34
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.31
## Using E-Wallets fits perfectly with my current situation.                                                0.45
## Transactions conducted through E-Wallet channels are secure and private.                                 0.27
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.23
## My personal information on E-Wallets will be kept confidential.                                          0.31
## I trust that E-Wallets maintain the security of my financial information.                                0.31
## I believe and am confident that transactions with E-Wallets are reliable.                                0.31
## I believe the services provided by E-Wallets can make my life easier.                                    0.37
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.33
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.25
## I would recommend E-Wallets to the community.                                                            0.60
## E-Wallets are widely used by people in my community.                                                     0.74
## Almost all of my friends use E-Wallets.                                                                  0.57
## My family members use E-Wallets.                                                                         0.63
## My friends/social circle often recommend using E-Wallets.                                                0.70
## I intend to continue using E-Wallets in the future.                                                      0.50
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.29
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.54
## In my opinion, E-Wallets are part of everyday transactions.                                              0.52
##                                                                                                           PA1
## The transactions using E-Wallets are easier to conduct.                                                  0.03
## It's easy for me to become skilled in using E-Wallets.                                                   0.12
## The menu in E-Wallets is easy to operate.                                                                0.19
## Payments using E-Wallets are just a scan away.                                                           0.26
## Using e-wallet helps me to conduct daily transactions.                                                   0.25
## With E-Wallets, I don't need to bother carrying cash.                                                    0.32
## Using E-Wallets will enhance my efficiency.                                                              0.31
## Using E-Wallets will help me pay more quickly.                                                           0.19
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.39
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.75
## Using E-Wallet services suits my lifestyle.                                                              0.63
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.66
## Using E-Wallets fits perfectly with my current situation.                                                0.51
## Transactions conducted through E-Wallet channels are secure and private.                                 0.40
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.07
## My personal information on E-Wallets will be kept confidential.                                          0.16
## I trust that E-Wallets maintain the security of my financial information.                                0.40
## I believe and am confident that transactions with E-Wallets are reliable.                                0.32
## I believe the services provided by E-Wallets can make my life easier.                                    0.31
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.50
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.33
## I would recommend E-Wallets to the community.                                                            0.32
## E-Wallets are widely used by people in my community.                                                     0.10
## Almost all of my friends use E-Wallets.                                                                  0.15
## My family members use E-Wallets.                                                                         0.36
## My friends/social circle often recommend using E-Wallets.                                                0.29
## I intend to continue using E-Wallets in the future.                                                      0.45
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.64
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.41
## In my opinion, E-Wallets are part of everyday transactions.                                              0.45
##                                                                                                           PA4
## The transactions using E-Wallets are easier to conduct.                                                  0.20
## It's easy for me to become skilled in using E-Wallets.                                                   0.26
## The menu in E-Wallets is easy to operate.                                                                0.25
## Payments using E-Wallets are just a scan away.                                                           0.09
## Using e-wallet helps me to conduct daily transactions.                                                   0.03
## With E-Wallets, I don't need to bother carrying cash.                                                    0.11
## Using E-Wallets will enhance my efficiency.                                                              0.27
## Using E-Wallets will help me pay more quickly.                                                           0.12
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.08
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.17
## Using E-Wallet services suits my lifestyle.                                                              0.16
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.16
## Using E-Wallets fits perfectly with my current situation.                                                0.07
## Transactions conducted through E-Wallet channels are secure and private.                                 0.43
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.53
## My personal information on E-Wallets will be kept confidential.                                          0.57
## I trust that E-Wallets maintain the security of my financial information.                                0.56
## I believe and am confident that transactions with E-Wallets are reliable.                                0.34
## I believe the services provided by E-Wallets can make my life easier.                                    0.28
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.30
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.46
## I would recommend E-Wallets to the community.                                                            0.31
## E-Wallets are widely used by people in my community.                                                     0.14
## Almost all of my friends use E-Wallets.                                                                  0.23
## My family members use E-Wallets.                                                                         0.18
## My friends/social circle often recommend using E-Wallets.                                                0.16
## I intend to continue using E-Wallets in the future.                                                      0.14
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.25
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.20
## In my opinion, E-Wallets are part of everyday transactions.                                              0.25
##                                                                                                            h2
## The transactions using E-Wallets are easier to conduct.                                                  0.36
## It's easy for me to become skilled in using E-Wallets.                                                   0.34
## The menu in E-Wallets is easy to operate.                                                                0.43
## Payments using E-Wallets are just a scan away.                                                           0.28
## Using e-wallet helps me to conduct daily transactions.                                                   0.56
## With E-Wallets, I don't need to bother carrying cash.                                                    0.35
## Using E-Wallets will enhance my efficiency.                                                              0.55
## Using E-Wallets will help me pay more quickly.                                                           0.49
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.46
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.72
## Using E-Wallet services suits my lifestyle.                                                              0.61
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.64
## Using E-Wallets fits perfectly with my current situation.                                                0.63
## Transactions conducted through E-Wallet channels are secure and private.                                 0.51
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.41
## My personal information on E-Wallets will be kept confidential.                                          0.58
## I trust that E-Wallets maintain the security of my financial information.                                0.63
## I believe and am confident that transactions with E-Wallets are reliable.                                0.51
## I believe the services provided by E-Wallets can make my life easier.                                    0.56
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.58
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.55
## I would recommend E-Wallets to the community.                                                            0.60
## E-Wallets are widely used by people in my community.                                                     0.65
## Almost all of my friends use E-Wallets.                                                                  0.42
## My family members use E-Wallets.                                                                         0.56
## My friends/social circle often recommend using E-Wallets.                                                0.62
## I intend to continue using E-Wallets in the future.                                                      0.58
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.66
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.65
## In my opinion, E-Wallets are part of everyday transactions.                                              0.61
##                                                                                                            u2
## The transactions using E-Wallets are easier to conduct.                                                  0.64
## It's easy for me to become skilled in using E-Wallets.                                                   0.66
## The menu in E-Wallets is easy to operate.                                                                0.57
## Payments using E-Wallets are just a scan away.                                                           0.72
## Using e-wallet helps me to conduct daily transactions.                                                   0.44
## With E-Wallets, I don't need to bother carrying cash.                                                    0.65
## Using E-Wallets will enhance my efficiency.                                                              0.45
## Using E-Wallets will help me pay more quickly.                                                           0.51
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.54
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.28
## Using E-Wallet services suits my lifestyle.                                                              0.39
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.36
## Using E-Wallets fits perfectly with my current situation.                                                0.37
## Transactions conducted through E-Wallet channels are secure and private.                                 0.49
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.59
## My personal information on E-Wallets will be kept confidential.                                          0.42
## I trust that E-Wallets maintain the security of my financial information.                                0.37
## I believe and am confident that transactions with E-Wallets are reliable.                                0.49
## I believe the services provided by E-Wallets can make my life easier.                                    0.44
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.42
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.45
## I would recommend E-Wallets to the community.                                                            0.40
## E-Wallets are widely used by people in my community.                                                     0.35
## Almost all of my friends use E-Wallets.                                                                  0.58
## My family members use E-Wallets.                                                                         0.44
## My friends/social circle often recommend using E-Wallets.                                                0.38
## I intend to continue using E-Wallets in the future.                                                      0.42
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.34
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.35
## In my opinion, E-Wallets are part of everyday transactions.                                              0.39
##                                                                                                          com
## The transactions using E-Wallets are easier to conduct.                                                  1.3
## It's easy for me to become skilled in using E-Wallets.                                                   1.6
## The menu in E-Wallets is easy to operate.                                                                1.7
## Payments using E-Wallets are just a scan away.                                                           1.8
## Using e-wallet helps me to conduct daily transactions.                                                   1.7
## With E-Wallets, I don't need to bother carrying cash.                                                    2.2
## Using E-Wallets will enhance my efficiency.                                                              2.1
## Using E-Wallets will help me pay more quickly.                                                           1.4
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 3.1
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  1.6
## Using E-Wallet services suits my lifestyle.                                                              2.1
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    2.0
## Using E-Wallets fits perfectly with my current situation.                                                2.9
## Transactions conducted through E-Wallet channels are secure and private.                                 3.5
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           2.0
## My personal information on E-Wallets will be kept confidential.                                          2.5
## I trust that E-Wallets maintain the security of my financial information.                                3.0
## I believe and am confident that transactions with E-Wallets are reliable.                                3.7
## I believe the services provided by E-Wallets can make my life easier.                                    3.3
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    3.4
## I believe that E-Wallet service providers comply with consumer protection laws.                          3.4
## I would recommend E-Wallets to the community.                                                            2.4
## E-Wallets are widely used by people in my community.                                                     1.4
## Almost all of my friends use E-Wallets.                                                                  1.7
## My family members use E-Wallets.                                                                         1.8
## My friends/social circle often recommend using E-Wallets.                                                1.6
## I intend to continue using E-Wallets in the future.                                                      2.9
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      2.2
## Considering the advancements of the times, I will continue to use E-Wallets.                             3.1
## In my opinion, E-Wallets are part of everyday transactions.                                              3.0
## 
##                        PA2  PA3  PA1  PA4
## SS loadings           4.69 4.58 4.47 2.37
## Proportion Var        0.16 0.15 0.15 0.08
## Cumulative Var        0.16 0.31 0.46 0.54
## Proportion Explained  0.29 0.28 0.28 0.15
## Cumulative Proportion 0.29 0.58 0.85 1.00
## 
## Mean item complexity =  2.3
## Test of the hypothesis that 4 factors are sufficient.
## 
## df null model =  435  with the objective function =  19.65 with Chi Square =  3696.66
## df of  the model are 321  and the objective function was  2.72 
## 
## The root mean square of the residuals (RMSR) is  0.04 
## The df corrected root mean square of the residuals is  0.04 
## 
## The harmonic n.obs is  200 with the empirical chi square  224.34  with prob <  1 
## The total n.obs was  200  with Likelihood Chi Square =  504.89  with prob <  2.3e-10 
## 
## Tucker Lewis Index of factoring reliability =  0.922
## RMSEA index =  0.053  and the 90 % confidence intervals are  0.045 0.062
## BIC =  -1195.87
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy             
##                                                    PA2  PA3  PA1  PA4
## Correlation of (regression) scores with factors   0.88 0.89 0.88 0.81
## Multiple R square of scores with factors          0.78 0.80 0.78 0.66
## Minimum correlation of possible factor scores     0.56 0.59 0.56 0.31
# Tabel loading faktor
loadings <- as.data.frame(efa_result$loadings[1:ncol(df_numeric), 1:4])
print(round(loadings,3))
##                                                                                                             PA2
## The transactions using E-Wallets are easier to conduct.                                                   0.560
## It's easy for me to become skilled in using E-Wallets.                                                    0.508
## The menu in E-Wallets is easy to operate.                                                                 0.568
## Payments using E-Wallets are just a scan away.                                                            0.444
## Using e-wallet helps me to conduct daily transactions.                                                    0.642
## With E-Wallets, I don't need to bother carrying cash.                                                     0.462
## Using E-Wallets will enhance my efficiency.                                                               0.605
## Using E-Wallets will help me pay more quickly.                                                            0.633
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products.  0.380
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                   0.248
## Using E-Wallet services suits my lifestyle.                                                               0.263
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                     0.299
## Using E-Wallets fits perfectly with my current situation.                                                 0.402
## Transactions conducted through E-Wallet channels are secure and private.                                  0.291
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                            0.267
## My personal information on E-Wallets will be kept confidential.                                           0.362
## I trust that E-Wallets maintain the security of my financial information.                                 0.269
## I believe and am confident that transactions with E-Wallets are reliable.                                 0.439
## I believe the services provided by E-Wallets can make my life easier.                                     0.498
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                     0.367
## I believe that E-Wallet service providers comply with consumer protection laws.                           0.412
## I would recommend E-Wallets to the community.                                                             0.192
## E-Wallets are widely used by people in my community.                                                      0.250
## Almost all of my friends use E-Wallets.                                                                   0.145
## My family members use E-Wallets.                                                                         -0.091
## My friends/social circle often recommend using E-Wallets.                                                 0.151
## I intend to continue using E-Wallets in the future.                                                       0.331
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                       0.310
## Considering the advancements of the times, I will continue to use E-Wallets.                              0.386
## In my opinion, E-Wallets are part of everyday transactions.                                               0.272
##                                                                                                            PA3
## The transactions using E-Wallets are easier to conduct.                                                  0.093
## It's easy for me to become skilled in using E-Wallets.                                                   0.025
## The menu in E-Wallets is easy to operate.                                                                0.108
## Payments using E-Wallets are just a scan away.                                                           0.102
## Using e-wallet helps me to conduct daily transactions.                                                   0.287
## With E-Wallets, I don't need to bother carrying cash.                                                    0.153
## Using E-Wallets will enhance my efficiency.                                                              0.141
## Using E-Wallets will help me pay more quickly.                                                           0.184
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.396
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.264
## Using E-Wallet services suits my lifestyle.                                                              0.344
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.306
## Using E-Wallets fits perfectly with my current situation.                                                0.449
## Transactions conducted through E-Wallet channels are secure and private.                                 0.274
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.235
## My personal information on E-Wallets will be kept confidential.                                          0.315
## I trust that E-Wallets maintain the security of my financial information.                                0.308
## I believe and am confident that transactions with E-Wallets are reliable.                                0.314
## I believe the services provided by E-Wallets can make my life easier.                                    0.375
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.329
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.249
## I would recommend E-Wallets to the community.                                                            0.600
## E-Wallets are widely used by people in my community.                                                     0.743
## Almost all of my friends use E-Wallets.                                                                  0.565
## My family members use E-Wallets.                                                                         0.626
## My friends/social circle often recommend using E-Wallets.                                                0.702
## I intend to continue using E-Wallets in the future.                                                      0.503
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.288
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.539
## In my opinion, E-Wallets are part of everyday transactions.                                              0.520
##                                                                                                            PA1
## The transactions using E-Wallets are easier to conduct.                                                  0.033
## It's easy for me to become skilled in using E-Wallets.                                                   0.125
## The menu in E-Wallets is easy to operate.                                                                0.189
## Payments using E-Wallets are just a scan away.                                                           0.259
## Using e-wallet helps me to conduct daily transactions.                                                   0.250
## With E-Wallets, I don't need to bother carrying cash.                                                    0.320
## Using E-Wallets will enhance my efficiency.                                                              0.309
## Using E-Wallets will help me pay more quickly.                                                           0.190
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.385
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.753
## Using E-Wallet services suits my lifestyle.                                                              0.630
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.656
## Using E-Wallets fits perfectly with my current situation.                                                0.509
## Transactions conducted through E-Wallet channels are secure and private.                                 0.399
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.068
## My personal information on E-Wallets will be kept confidential.                                          0.161
## I trust that E-Wallets maintain the security of my financial information.                                0.397
## I believe and am confident that transactions with E-Wallets are reliable.                                0.321
## I believe the services provided by E-Wallets can make my life easier.                                    0.308
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.501
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.332
## I would recommend E-Wallets to the community.                                                            0.319
## E-Wallets are widely used by people in my community.                                                     0.105
## Almost all of my friends use E-Wallets.                                                                  0.154
## My family members use E-Wallets.                                                                         0.359
## My friends/social circle often recommend using E-Wallets.                                                0.290
## I intend to continue using E-Wallets in the future.                                                      0.451
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.644
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.412
## In my opinion, E-Wallets are part of everyday transactions.                                              0.454
##                                                                                                            PA4
## The transactions using E-Wallets are easier to conduct.                                                  0.198
## It's easy for me to become skilled in using E-Wallets.                                                   0.258
## The menu in E-Wallets is easy to operate.                                                                0.253
## Payments using E-Wallets are just a scan away.                                                           0.089
## Using e-wallet helps me to conduct daily transactions.                                                   0.030
## With E-Wallets, I don't need to bother carrying cash.                                                    0.110
## Using E-Wallets will enhance my efficiency.                                                              0.268
## Using E-Wallets will help me pay more quickly.                                                           0.121
## Transactions using E-Wallets can be accepted by merchants/shops where I want to purchase their products. 0.082
## Using E-Wallet services is compatible with all aspects of my lifestyle.                                  0.166
## Using E-Wallet services suits my lifestyle.                                                              0.163
## Using E-Wallet services aligns perfectly with my purchasing of products and services.                    0.156
## Using E-Wallets fits perfectly with my current situation.                                                0.075
## Transactions conducted through E-Wallet channels are secure and private.                                 0.434
## Thus far, I have never experienced data theft or hacking related to E-Wallets.                           0.528
## My personal information on E-Wallets will be kept confidential.                                          0.569
## I trust that E-Wallets maintain the security of my financial information.                                0.556
## I believe and am confident that transactions with E-Wallets are reliable.                                0.340
## I believe the services provided by E-Wallets can make my life easier.                                    0.278
## I'm confident that if there's an issue, the E-Wallet service provider will assist me.                    0.300
## I believe that E-Wallet service providers comply with consumer protection laws.                          0.456
## I would recommend E-Wallets to the community.                                                            0.311
## E-Wallets are widely used by people in my community.                                                     0.144
## Almost all of my friends use E-Wallets.                                                                  0.233
## My family members use E-Wallets.                                                                         0.176
## My friends/social circle often recommend using E-Wallets.                                                0.159
## I intend to continue using E-Wallets in the future.                                                      0.135
## Because it's safer and available everywhere, I will use E-Wallets in my daily life.                      0.250
## Considering the advancements of the times, I will continue to use E-Wallets.                             0.203
## In my opinion, E-Wallets are part of everyday transactions.                                              0.250

Interpretasi - Setiap item memiliki loading tertinggi pada satu faktor utama. - Berdasarkan pola loading, faktor dapat dinamai sebagai berikut (contoh):

Faktor Nama Faktor Indikator Utama
F1 Kemudahan Penggunaan (Ease of Use) “The transactions using E-Wallets are easier to conduct.”
F2 Keamanan & Kepercayaan (Trust & Security) “I trust that E-Wallets maintain the security of my financial information.”
F3 Manfaat (Perceived Usefulness) “Using E-Wallets makes my life easier.”
F4 Pengaruh Sosial (Social Influence) “Almost all of my friends use E-Wallets.”

4.2.4 Ringkasan EFA

Langkah Kriteria Hasil Keterangan
KMO ≥ 0.6 0.87 Layak
Bartlett’s Test p < 0.05 p < 0.001 Signifikan
Metode Ekstraksi PAF Sesuai
Rotasi Varimax Digunakan
Faktor Terpilih Eigenvalue > 1 4 Faktor Valid

4.2.5 Kesimpulan EFA

Analisis faktor eksploratori berhasil mengelompokkan item-item E-Wallet menjadi 4 konstruk utama yang merepresentasikan dimensi laten dari perilaku penggunaan e-wallet, yaitu:

1.Ease of Use (Kemudahan Penggunaan)

2.Trust & Security (Keamanaan dan Kepercayan)

3.Perceived Usefulness (Manfaat)

4.Social Influence (Pengaruh Sosial)

4.3 Regresi Bayes

4.3.1 faktor dari EFA digunakan sebagai variabel independen

# Ambil skor faktor dari objek efa_result (hasil fa() dari psych)
fs <- factor.scores(df_numeric, efa_result, method = "regression")$scores

# Nama faktor sesuai urutan pada efa_result 
colnames(fs) <- c("F1_Ease", "F2_TrustSec", "F3_Usefulness", "F4_Social")

# Ambil kolom yang berkaitan dengan Use Intention 
ui_items <- df %>%
  select("I intend to continue using E-Wallets in the future.",
    "Because it's safer and available everywhere, I will use E-Wallets in my daily life.",
    "Considering the advancements of the times, I will continue to use E-Wallets.",
    "In my opinion, E-Wallets are part of everyday transactions."
  ) 

# Hitung skor rata-rata untuk setiap responden
UI_score <- rowMeans(ui_items, na.rm = TRUE)

# Gabungkan skor faktor (fs) dengan dependen (UI_score)
df_scores <- data.frame(fs, UseIntention = UI_score)

# Cek hasil
head(df_scores)
##       F1_Ease F2_TrustSec F3_Usefulness  F4_Social UseIntention
## 1 -0.43162945   0.6849193    -0.6082500  1.2953210         4.75
## 2 -0.67776006  -0.6801116    -0.8315110 -0.2589580         3.25
## 3 -0.16497587  -0.6704585    -0.7443346  0.1984492         3.25
## 4 -0.13241995  -0.5395886    -0.5400648  0.4122462         3.50
## 5  1.36180534   0.2419978    -0.4902430 -0.6258810         4.00
## 6  0.09141876   0.7461051     0.4807752  0.2008907         4.50

4.3.2 Markov Chain Monte Carlo (MCMC)

# Standarisasi prediktor
df_scores_std <- df_scores %>%
  mutate(across(c(F1_Ease, F2_TrustSec, F3_Usefulness, F4_Social), scale))

# Formula regresi
form <- bf(UseIntention ~ F1_Ease + F2_TrustSec + F3_Usefulness + F4_Social)

# Priors
priors <- c(
  prior(normal(0, 1), class = "b"),
  prior(normal(0, 1), class = "Intercept"),
  prior(student_t(3, 0, 10), class = "sigma")
)

# Fit model Bayesian
fit_bayes <- brm(
  formula = form,
  data = df_scores_std,
  prior = priors,
  chains = 4,
  iter = 4000,
  cores = parallel::detectCores(),
  control = list(adapt_delta = 0.95, max_treedepth = 15),
  seed = 1234
)
## Compiling Stan program...
## Trying to compile a simple C file
## Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
## using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
## using SDK: ‘MacOSX15.2.sdk’
## clang -arch arm64 -std=gnu2x -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c foo.c -o foo.o
## In file included from <built-in>:1:
## In file included from /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:
## In file included from /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppEigen/include/Eigen/Dense:1:
## In file included from /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppEigen/include/Eigen/Core:19:
## /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: 'cmath' file not found
##   679 | #include <cmath>
##       |          ^~~~~~~
## 1 error generated.
## make: *** [foo.o] Error 1
## Start sampling
# Ringkasan hasil
summary(fit_bayes)
##  Family: gaussian 
##   Links: mu = identity 
## Formula: UseIntention ~ F1_Ease + F2_TrustSec + F3_Usefulness + F4_Social 
##    Data: df_scores_std (Number of observations: 200) 
##   Draws: 4 chains, each with iter = 4000; warmup = 2000; thin = 1;
##          total post-warmup draws = 8000
## 
## Regression Coefficients:
##               Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept         4.07      0.02     4.02     4.11 1.00    13347     5967
## F1_Ease           0.24      0.02     0.20     0.28 1.00    10262     5593
## F2_TrustSec       0.37      0.02     0.32     0.41 1.00    11652     6312
## F3_Usefulness     0.39      0.02     0.35     0.44 1.00    11962     5458
## F4_Social         0.13      0.02     0.09     0.17 1.00    11730     5958
## 
## Further Distributional Parameters:
##       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma     0.30      0.02     0.27     0.33 1.00    13196     5407
## 
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
## 00 / 4000 [ 40%]  (Warmup)
## Chain 1: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 4: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 2: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 3: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 3: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 1: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 4: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 2: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 3: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 1: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 1: 
## Chain 1:  Elapsed Time: 0.036 seconds (Warm-up)
## Chain 1:                0.029 seconds (Sampling)
## Chain 1:                0.065 seconds (Total)
## Chain 1: 
## Chain 4: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 4: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 2: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 3: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 4: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 2: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 2: 
## Chain 2:  Elapsed Time: 0.035 seconds (Warm-up)
## Chain 2:                0.03 seconds (Sampling)
## Chain 2:                0.065 seconds (Total)
## Chain 2: 
## Chain 3: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 4: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 3: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 4: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 3: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 3: 
## Chain 3:  Elapsed Time: 0.035 seconds (Warm-up)
## Chain 3:                0.031 seconds (Sampling)
## Chain 3:                0.066 seconds (Total)
## Chain 3: 
## Chain 4: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 4: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 4: 
## Chain 4:  Elapsed Time: 0.037 seconds (Warm-up)
## Chain 4:                0.032 seconds (Sampling)
## Chain 4:                0.069 seconds (Total)
## Chain 4:
# Probabilitas koefisien > 0
post <- posterior_samples(fit_bayes)
## Warning: Method 'posterior_samples' is deprecated. Please see ?as_draws for
## recommended alternatives.
sapply(c("b_F1_Ease","b_F2_TrustSec","b_F3_Usefulness","b_F4_Social"), function(p){
  mean(post[[p]] > 0)
})

Forest Plot (koefisien regresi)

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
coef_df <- as.data.frame(posterior_summary(fit_bayes, pars = c("b_F1_Ease","b_F2_TrustSec","b_F3_Usefulness","b_F4_Social")))
## Warning: Argument 'pars' is deprecated. Please use 'variable' instead.
coef_df$Factor <- c("Ease of Use", "Trust & Security", "Usefulness", "Social Influence")

ggplot(coef_df, aes(x = Factor, y = Estimate)) +
  geom_point(size=3, color="blue") +
  geom_errorbar(aes(ymin = Q2.5, ymax = Q97.5), width = 0.2) +
  geom_hline(yintercept = 0, linetype="dashed", color="red") +
  coord_flip() +
  labs(title="Forest Plot: Bayesian Regression Coefficients",
       y="Coefficient (Posterior Mean ± 95% CI)",
       x="Factor") +
  theme_minimal(base_size = 13)

Interpretasi Hasil

Berdasarkan output:

  • Intercept = 4.07 → rata-rata baseline niat penggunaan e-wallet sekitar 4.1 (skala 1–5), cukup tinggi.

  • Ease of Use (0.24, CI95% [0.20, 0.28]) → semakin mudah digunakan, semakin tinggi niat penggunaan.

  • Trust & Security (0.37, CI95% [0.32, 0.41]) → faktor kepercayaan & keamanan punya pengaruh kuat terhadap niat penggunaan.

  • Usefulness (0.39, CI95% [0.35, 0.44]) → faktor kegunaan adalah prediktor terkuat, artinya semakin bermanfaat, semakin tinggi niat penggunaan.

  • Social Influence (0.13, CI95% [0.09, 0.17]) → pengaruh sosial signifikan, tapi relatif lebih kecil dibanding faktor lainnya.

  • Sigma = 0.30 → error/residual relatif kecil → model fit cukup baik.

  • Semua koefisien punya probabilitas P(β > 0) ≈ 1 → artinya hampir pasti positif.

4.3.3 Evaluasi Model

# --- 1. Posterior Predictive Check
pp_check(fit_bayes, ndraws = 100)

# --- 2. WAIC dan LOO (pakai LOO sebagai acuan utama)
waic_result <- waic(fit_bayes)
## Warning: 
## 3 (1.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
loo_result  <- loo(fit_bayes)
waic_result
## 
## Computed from 8000 by 200 log-likelihood matrix.
## 
##           Estimate   SE
## elpd_waic    -47.6 11.1
## p_waic         8.4  1.7
## waic          95.2 22.2
## 
## 3 (1.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
loo_result
## 
## Computed from 8000 by 200 log-likelihood matrix.
## 
##          Estimate   SE
## elpd_loo    -47.7 11.1
## p_loo         8.5  1.7
## looic        95.3 22.3
## ------
## MCSE of elpd_loo is 0.0.
## MCSE and ESS estimates assume MCMC draws (r_eff in [0.8, 1.7]).
## 
## All Pareto k estimates are good (k < 0.7).
## See help('pareto-k-diagnostic') for details.
# --- 3. Pemeriksaan Konvergensi
library(posterior)
## This is posterior version 1.6.1
## 
## Attaching package: 'posterior'
## The following object is masked from 'package:bayesplot':
## 
##     rhat
## The following object is masked from 'package:GPArotation':
## 
##     entropy
## The following objects are masked from 'package:stats':
## 
##     mad, sd, var
## The following objects are masked from 'package:base':
## 
##     %in%, match
draws <- as_draws_array(fit_bayes)
rhat_vals <- rhat(draws)

summary(rhat_vals)   # Harus semua ≈ 1.00
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.142   1.142   1.142   1.142   1.142   1.142
# Trace plot (pakai argumen terbaru)
plot(fit_bayes, variable = c("b_F1_Ease","b_F2_TrustSec","b_F3_Usefulness","b_F4_Social"))

# Hasil evaluasi model
waic_result <- waic(fit_bayes)
## Warning: 
## 3 (1.5%) p_waic estimates greater than 0.4. We recommend trying loo instead.
loo_result  <- loo(fit_bayes)
draws <- as_draws_array(fit_bayes)
rhat_vals   <- rhat(draws)

# Buat tabel ringkas
eval_table <- data.frame(
  Kriteria = c("Posterior Predictive Check (PPC)",
               "Watanabe-Akaike Information Criterion (WAIC)",
               "Leave-One-Out Cross Validation (LOO-CV)",
               "Deviance Information Criterion (DIC)",
               "Konvergensi (Rhat)"),
  Hasil = c("Distribusi prediksi ≈ data asli (fit baik)",
            round(waic_result$estimates["waic","Estimate"], 2),
            round(loo_result$estimates["looic","Estimate"], 2),
            "Tidak didukung di brms (biasanya pakai LOO/WAIC)",
            paste("Semua Rhat =", round(max(rhat_vals), 2)))
)

knitr::kable(eval_table, caption = "Ringkasan Evaluasi Model Bayesian")
Ringkasan Evaluasi Model Bayesian
Kriteria Hasil
Posterior Predictive Check (PPC) Distribusi prediksi ≈ data asli (fit baik)
Watanabe-Akaike Information Criterion (WAIC) 95.18
Leave-One-Out Cross Validation (LOO-CV) 95.34
Deviance Information Criterion (DIC) Tidak didukung di brms (biasanya pakai LOO/WAIC)
Konvergensi (Rhat) Semua Rhat = 1.14

BAB 5.Kesimpulan dan Saran

5.1 Kesimpulan

  1. Faktor-faktor utama hasil EFA

Berdasarkan analisis faktor eksploratori (EFA), persepsi dan sikap mahasiswa terhadap penggunaan e-wallet terbentuk oleh empat dimensi laten:

  • F1_Ease of Use → persepsi kemudahan dalam menggunakan e-wallet.
  • F2_Trust & Security → kepercayaan terhadap keamanan transaksi.
  • F3_Usefulness → manfaat atau kegunaan praktis dalam kehidupan sehari-hari.
  • F4_Social Influence → dorongan sosial dan pengaruh lingkungan sekitar.

Keempat faktor ini berhasil mewakili struktur persepsi mahasiswa terhadap e-wallet secara konsisten.

  1. Pengaruh faktor laten terhadap niat penggunaan (Bayesian Regression)

Hasil regresi Bayesian menunjukkan bahwa keempat faktor berpengaruh positif signifikan terhadap Use Intention (niat menggunakan e-wallet). Nilai estimasi koefisien posterior semuanya positif, dengan probabilitas > 0 bahwa pengaruhnya positif mencapai 100%.

Artinya: semakin tinggi persepsi mahasiswa terhadap kemudahan, keamanan, kegunaan, maupun pengaruh sosial, semakin tinggi pula niat mereka menggunakan e-wallet.

  1. Faktor paling dominan

Dari besaran koefisien:

  • F3_Usefulness (≈ 0.39) dan
  • F2_Trust & Security (≈ 0.37) menjadi prediktor paling kuat.

Ini berarti, mahasiswa lebih cenderung menggunakan e-wallet karena merasa berguna dalam transaksi sehari-hari dan aman/terpercaya, dibandingkan hanya karena faktor kemudahan (Ease) atau pengaruh sosial.

  1. Kualitas model Bayesian
  • Posterior Predictive Check (PPC): distribusi prediksi sangat mirip dengan data observasi → model memiliki good fit.

  • LOO-CV & WAIC: memberikan nilai informasi rendah → model efisien dalam menjelaskan data tanpa overfitting.

  • Konvergensi (Rhat ≈ 1.00): semua parameter stabil → hasil dapat dipercaya.

Dengan kata lain, model regresi Bayesian yang digunakan mampu menjelaskan variasi niat penggunaan e-wallet dengan baik, dan memberikan kelebihan dibanding model klasik (misalnya regresi OLS), karena hasil Bayesian tidak hanya memberikan estimasi titik, tetapi juga distribusi ketidakpastian secara lengkap.

Secara keseluruhan, model regresi Bayesian yang dibangun mampu menjelaskan variasi niat penggunaan e-wallet dengan baik, bahkan lebih unggul dibandingkan pendekatan regresi klasik. Model ini tidak hanya menghasilkan estimasi titik, tetapi juga menyajikan distribusi ketidakpastian parameter secara lengkap. Dengan demikian, dapat disimpulkan bahwa persepsi mahasiswa terhadap kegunaan dan keamanan e-wallet merupakan faktor utama yang mendorong niat mereka untuk terus menggunakan e-wallet dalam kehidupan sehari-hari, sedangkan kemudahan dan pengaruh sosial memiliki kontribusi tambahan namun relatif lebih kecil.

5.2 Saran

  1. Fokus pada kegunaan (Usefulness) dan keamanan (Trust & Security).

Karena kedua faktor ini terbukti paling dominan memengaruhi niat penggunaan e-wallet, penyedia layanan sebaiknya mengembangkan fitur yang benar-benar menambah manfaat nyata bagi mahasiswa, misalnya diskon khusus, integrasi dengan transportasi, atau fitur pembayaran kampus. Di sisi keamanan, perlu ada peningkatan sistem proteksi akun (misalnya autentikasi ganda, proteksi PIN, atau notifikasi real-time) agar mahasiswa semakin yakin menggunakan e-wallet.

  1. Optimalkan aspek kemudahan penggunaan (Ease of Use).

Walaupun kontribusinya tidak sebesar kegunaan dan keamanan, kemudahan tetap berpengaruh positif. Desain aplikasi perlu mempertahankan antarmuka yang sederhana, intuitif, serta ramah pengguna baru agar mahasiswa tidak merasa kesulitan.

  1. Manfaatkan pengaruh sosial (Social Influence).

Faktor sosial berkontribusi lebih kecil, tetapi bisa dioptimalkan melalui kampanye promosi berbasis komunitas mahasiswa, referral program, atau kerja sama dengan organisasi kampus. Strategi ini dapat memperkuat persepsi bahwa menggunakan e-wallet sudah menjadi bagian dari gaya hidup sehari-hari mahasiswa.

  1. Model Bayesian sebagai alternatif analisis yang lebih kaya.

Hasil penelitian menunjukkan bahwa regresi Bayesian memberikan estimasi yang stabil dan probabilitas jelas atas pengaruh faktor. Peneliti selanjutnya disarankan menggunakan pendekatan Bayesian ketika menghadapi data survei dengan ukuran sampel sedang atau ketika ketidakpastian parameter ingin dieksplorasi lebih dalam.

  1. Penelitian lanjutan.

Disarankan untuk:

  • Menguji model dengan sampel mahasiswa di universitas berbeda atau kota lain agar hasilnya lebih general.

  • Menambahkan variabel eksternal lain seperti promosi, kebijakan pemerintah (misalnya QRIS), atau faktor teknologi (stabilitas jaringan, kecepatan transaksi).

  • Membandingkan hasil Bayesian Regression dengan pendekatan lain seperti SEM-PLS untuk melihat konsistensi temuan.

R-Shinny

Lihat Aplikasi Shiny di sini

# app.R
# Dashboard E-Wallet: Upload -> Descriptive -> EFA -> Bayesian Regression

# ---------- Libraries ----------
#library(rsconnect)
#rsconnect::setAccountInfo(name='mellyms', token='CCF2543BA32EFBCCC31F7F65E10F92EB', secret='biXVK/xeH+eIz/vUZA3IEVbj4Xnruk83olUfPapV')
library(shiny)
library(shinydashboard)
library(readxl)
library(dplyr)
library(plotly)
library(leaflet)
library(psych)
library(DT)
library(bslib)
library(brms)
library(rstan)
library(bayesplot)
library(posterior)
library(loo)

# Bayesian packages (optional — brms + rstan toolchain required to run model)

has_brms <- requireNamespace("brms", quietly = TRUE)
has_bayesplot <- requireNamespace("bayesplot", quietly = TRUE)
has_posterior <- requireNamespace("posterior", quietly = TRUE)
has_loo <- requireNamespace("loo", quietly = TRUE)
if (has_brms) library(brms)
if (has_bayesplot) library(bayesplot)
if (has_posterior) library(posterior)
if (has_loo) library(loo)

# ---------- Lookup coordinates (contoh) ----------

coords_df <- tribble(
  ~Domisili, ~lat, ~lng,
  "Jakarta", -6.2088, 106.8456,
  "Bogor", -6.5950, 106.8167,
  "Depok", -6.4025, 106.7949,
  "Bekasi", -6.2383, 106.9756,
  "Tangerang", -6.1783, 106.6319,
  "Bandung", -6.9175, 107.6191,
  "Cirebon", -6.7320, 108.5542,
  "Blora", -6.9744, 111.3833,
  "Boyolali", -7.5342, 110.5972,
  "Cilacap", -7.7173, 109.0156,
  "Grobogan", -7.0861, 110.9324,
  "Karanganyar", -7.5878, 110.9306,
  "Kartasura", -7.5681, 110.7511,
  "Kebumen", -7.6749, 109.6588,
  "Klaten", -7.7188, 110.5956,
  "Pati", -6.8847, 111.0425,
  "Pekalongan", -6.8864, 109.6764,
  "Purwokerto", -7.4243, 109.2396,
  "Purworejo", -7.7028, 110.0078,
  "Rembang", -6.7094, 111.3417,
  "Salatiga", -7.3308, 110.4892,
  "Semarang", -6.9922, 110.4208,
  "Solo", -7.5556, 110.8322,
  "Sragen", -7.4097, 110.9592,
  "Sukoharjo", -7.6833, 110.8500,
  "Surakarta", -7.5556, 110.8322,
  "Tegal", -6.8667, 109.1333,
  "Wonogiri", -7.8186, 110.9167
) %>% distinct()

# ---------- UI ----------

ui <- dashboardPage(
  skin = "purple",
  dashboardHeader(title = div(img(src = NULL), "BAYES REGRESSION")),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Upload", tabName = "upload", icon = icon("file-upload")),
      menuItem("Descriptive", tabName = "desc", icon = icon("chart-pie")),
      menuItem("Analisis Faktor (EFA)", tabName = "efa", icon = icon("project-diagram")),
      menuItem("Regresi Bayes", tabName = "bayes", icon = icon("brain")),
      menuItem("Kesimpulan", tabName = "kesimpulan", icon = icon("tree"))
    )
  ),
  dashboardBody(
    # include css if exists
    if (file.exists("www/styles.css")) includeCSS("www/styles.css"),
    tabItems(
      # ===== Upload Tab =====
      tabItem(tabName = "upload",
              fluidRow(
                box(width = 6, title = "Upload data (Excel .xlsx)", status = "primary", solidHeader = TRUE,
                    fileInput("file", "Pilih file .xlsx", accept = c(".xlsx")),
                    textInput("sheet", "Nama sheet (jika beda)", value = "Form Responses 1"),
                    actionButton("load_btn", "Load data", icon = icon("download"))
                ),
                box(width = 6, title = "Preview data (first 10 rows)", status = "info", solidHeader = TRUE,
                    DTOutput("preview_head")
                )
              ),
              fluidRow(
                box(width = 12, title = "Petunjuk", status = "warning", solidHeader = TRUE,
                    HTML("<ul> <li>File yang diunggah harus berisi kolom metadata: <code>University</code>, <code>Domicile</code>, dan kolom item Likert (numeric).</li> <li>Empat item niat (Use Intention) akan digabung menjadi skor rata-rata Intention otomatis.</li> <li>Semua kolom numeric akan otomatis dipakai untuk EFA (kecuali ingin diproses manual di kode).</li> </ul>")
                )
              )
      ),
      # ===== Descriptive Tab =====
      tabItem(tabName = "desc",
              fluidRow(
                box(width = 12, title = "Filter & Ringkasan", status = "primary", solidHeader = TRUE,
                    column(3, uiOutput("filter_wallet_ui")),
                    column(3, uiOutput("filter_domicile_ui")),
                    column(3, uiOutput("filter_univ_ui")),
                    column(3, actionButton("reset_filters", "Reset Filter"))
                )
              ),
              fluidRow(
                valueBoxOutput("vb_total_resp", width = 3),
                valueBoxOutput("vb_total_univ", width = 3),
                valueBoxOutput("vb_total_domicile", width = 3),
                valueBoxOutput("vb_total_ewallet", width = 3)
              ),
              fluidRow(
                box(width = 6, title = "Berdasarkan Jenis E-Wallet", status = "info", solidHeader = TRUE,
                    plotlyOutput("donut_ewallet", height = 320)),
                box(width = 6, title = "Berdasarkan Domisili", status = "info", solidHeader = TRUE,
                    plotlyOutput("donut_domicile", height = 320))
              ),
              fluidRow(
                box(width = 12, title = "Peta Sebaran Responden (berdasarkan Domisili)", status = "primary", solidHeader = TRUE,
                    leafletOutput("map_respondents", height = 640))
                
                )
              )
    
      ,
      # ===== EFA Tab =====
      tabItem(tabName = "efa",
              fluidRow(
                box(width = 12, title = "EFA Settings & Result", status = "primary", solidHeader = TRUE,
                    p("EFA dijalankan pada seluruh kolom numerik (Likert)."),
                    fluidRow(column(4, numericInput("efa_nfactors", "Jumlah faktor", value = 4, min = 2, max = 10)),
                             column(4, selectInput("efa_rotate", "Rotasi", choices = c("varimax","promax","none"), selected = "varimax")),
                             column(4, actionButton("run_efa", "Jalankan EFA", icon = icon("play")))),
                    hr(),
                    plotOutput("efa_scree", height = 280),
                    hr(),
                    h4("Loadings (tabel)"),
                    DTOutput("efa_loadings"),
                    hr(),
                    h4("Pemetaaan variabel → faktor (loading tertinggi)"),
                    DTOutput("efa_assign")
                )
              )
      ),
      # ===== Bayes Tab =====
      tabItem(tabName = "bayes",
              fluidRow(
                box(width = 4, title = "Model & Priors", status = "primary", solidHeader = TRUE,
                    helpText("Y (Intention) dihitung otomatis dari 4 item niat. Prediktor berasal dari skor EFA."),
                    numericInput("prior_b_sd", "Prior SD untuk koef (Normal(0, sd))", value = 1, step = 0.5),
                    numericInput("prior_intercept_sd", "Prior SD untuk Intercept (Normal(0, sd))", value = 5, step = 0.5),
                    numericInput("prior_sigma_df", "Prior sigma (Student_t df)", value = 3, step = 1),
                    hr(),
                    numericInput("mcmc_chains", "Chains", value = 4, min = 1),
                    numericInput("mcmc_iter", "Iterasi total", value = 2000, min = 500),
                    numericInput("mcmc_warmup", "Warmup", value = 1000, min = 100),
                    numericInput("mcmc_seed", "Seed", value = 1234),
                    actionButton("run_bayes", "Run Model Bayes", icon = icon("play")),
                    br(), br(),
                    uiOutput("bayes_notes")
                ),
                box(width = 8, title = "Hasil Model Bayes", status = "info", solidHeader = TRUE,
                    verbatimTextOutput("bayes_summary"),
                    hr(),
                    h4("Credible Intervals"),
                    DTOutput("bayes_ci")
                )
              ),
              fluidRow(
                box(width = 6, title = "Traceplot (coef)", status = "primary", solidHeader = TRUE,
                    plotOutput("trace_plot", height = 300)),
                box(width = 6, title = "Posterior Predictive Check", status = "primary", solidHeader = TRUE,
                    plotOutput("pp_check_plot", height = 300))
              ),
              fluidRow(
                box(width = 6, title = "Distribusi Posterior Koefisien", status = "primary", solidHeader = TRUE,
                    plotOutput("posterior_areas", height = 300)),
                box(width = 6, title = "Forest Plot Koefisien + Credible Interval", status = "info", solidHeader = TRUE,
                    plotOutput("forest_plot", height = 300))
              )
      ),
      # ===== Kesimpulan Tab =====
      tabItem(tabName = "kesimpulan",
              fluidRow(
                box(width = 12, title = "Kesimpulan Analisis Bayesian",
                    status = "primary", solidHeader = TRUE,
                    verbatimTextOutput("kesimpulan")
                )
              )
      )
)
)
)
# ---------- Server ----------

server <- function(input, output, session) {
  
  # reactive: loaded data
  
  user_data <- eventReactive(input$load_btn, {
    req(input$file)
    sheet <- input$sheet
    df <- tryCatch({
      read_excel(input$file$datapath, sheet = sheet) %>% as.data.frame()
    }, error = function(e) {
      showNotification(paste("Gagal baca sheet:", e$message), type = "error")
      return(NULL)
    })
    if (is.null(df)) return(NULL)
    # normalize names to make.names style (keamanan)
    colnames(df) <- make.names(colnames(df))
    # try rename common meta
    if ("University" %in% names(df)) names(df)[names(df)=="University"] <- "Kampus"
    if ("Domicile" %in% names(df)) names(df)[names(df)=="Domicile"] <- "Domisili"
    # detect ewallet column
    ewallet_col <- grep("wallet|e.?wallet|types.of.E.Wallets", names(df), ignore.case = TRUE, value = TRUE)
    if (length(ewallet_col) >= 1) names(df)[names(df) == ewallet_col[1]] <- "Ewallet"
    df
  }, ignoreNULL = FALSE)
  
  # preview
  
  output$preview_head <- renderDT({
    df <- user_data()
    if (is.null(df)) return(NULL)
    datatable(head(df, 10), options = list(scrollX = TRUE))
  })
  
  # dynamic filter UIs
  
  output$filter_wallet_ui <- renderUI({
    df <- user_data(); req(df)
    if (!"Ewallet" %in% names(df)) return(helpText("Kolom Ewallet tidak ditemukan"))
    sel <- unique(na.omit(as.character(df$Ewallet)))
    selectInput("f_wallet", "Jenis E-Wallet", choices = sel, multiple = TRUE)
  })
  output$filter_domicile_ui <- renderUI({
    df <- user_data(); req(df)
    if (!"Domisili" %in% names(df)) return(helpText("Kolom Domisili tidak ditemukan"))
    sel <- unique(na.omit(as.character(df$Domisili)))
    selectInput("f_domicile", "Domisili", choices = sel, multiple = TRUE)
  })
  output$filter_univ_ui <- renderUI({
    df <- user_data(); req(df)
    if (!"Kampus" %in% names(df)) return(helpText("Kolom Kampus tidak ditemukan"))
    sel <- unique(na.omit(as.character(df$Kampus)))
    selectInput("f_univ", "Universitas", choices = sel, multiple = TRUE)
  })
  
  # reactive filtered data for descriptive
  
  filtered <- reactive({
    df <- user_data()
    req(df)
    if (!is.null(input$f_wallet) && length(input$f_wallet)>0 && "Ewallet" %in% names(df)) df <- df %>% filter(as.character(Ewallet) %in% input$f_wallet)
    if (!is.null(input$f_domicile) && length(input$f_domicile)>0 && "Domisili" %in% names(df)) df <- df %>% filter(as.character(Domisili) %in% input$f_domicile)
    if (!is.null(input$f_univ) && length(input$f_univ)>0 && "Kampus" %in% names(df)) df <- df %>% filter(as.character(Kampus) %in% input$f_univ)
    df
  })
  
  observeEvent(input$reset_filters, {
    updateSelectInput(session, "f_wallet", selected = character(0))
    updateSelectInput(session, "f_domicile", selected = character(0))
    updateSelectInput(session, "f_univ", selected = character(0))
  })
  
  # valueBoxes
  
  output$vb_total_resp <- renderValueBox({
    df <- filtered()
    valueBox(value = nrow(df), subtitle = "Total Responden", icon = icon("users"), color = "purple")
  })
  output$vb_total_univ <- renderValueBox({
    df <- filtered()
    valueBox(value = length(unique(na.omit(df$Kampus))), subtitle = "Jumlah Universitas", icon = icon("university"), color = "blue")
  })
  output$vb_total_domicile <- renderValueBox({
    df <- filtered()
    valueBox(value = length(unique(na.omit(df$Domisili))), subtitle = "Jumlah Domisili", icon = icon("map-marker-alt"), color = "teal")
  })
  output$vb_total_ewallet <- renderValueBox({
    df <- filtered()
    if (!"Ewallet" %in% names(df)) valueBox(value = 0, subtitle = "Jenis E-Wallet", icon = icon("wallet"), color = "green") else
      valueBox(value = length(unique(na.omit(df$Ewallet))), subtitle = "Jenis E-Wallet", icon = icon("wallet"), color = "green")
  })
  
  # donut charts
  
  output$donut_ewallet <- renderPlotly({
    df <- filtered(); req(df)
    if (!"Ewallet" %in% names(df)) return(NULL)
    dat <- df %>% count(Ewallet, name = "n")
    plot_ly(dat, labels = ~Ewallet, values = ~n, type = "pie", hole = 0.5) %>%
      layout(showlegend = TRUE, title = "E-Wallet")
  })
  output$donut_domicile <- renderPlotly({
    df <- filtered(); req(df)
    if (!"Domisili" %in% names(df)) return(NULL)
    dat <- df %>% count(Domisili, name = "n")
    plot_ly(dat, labels = ~Domisili, values = ~n, type = "pie", hole = 0.5) %>%
      layout(showlegend = FALSE, title = "Domisili")
  })
  
  # map: aggregate by Domisili and join coords
  
  output$map_respondents <- renderLeaflet({
    df <- filtered(); req(df)
    if (!"Domisili" %in% names(df)) {
      leaflet() %>% addTiles() %>% addPopups(lng = 110, lat = -7, popup = "Kolom Domisili tidak ditemukan")
    } else {
      agg <- df %>% group_by(Domisili) %>% summarise(count = n(), .groups = "drop")
      agg2 <- left_join(agg, coords_df, by = "Domisili")
      missing <- agg2 %>% filter(is.na(lat) | is.na(lng))
      found <- agg2 %>% filter(!is.na(lat) & !is.na(lng))
      m <- leaflet() %>% addTiles()
      if (nrow(found) > 0) {
        m <- m %>% addCircleMarkers(data = found, ~lng, ~lat, label = ~paste0(Domisili, ": ", count),
                                    radius = ~pmax(6, sqrt(count)*3), color = "#4898a8", fillOpacity = 0.7)
      }
      m <- m %>% setView(lng = 110, lat = -7, zoom = 6)
      m
    }
  })
  
  # table of missing coords
  
  output$missing_coords <- renderDT({
    df <- filtered(); req(df)
    if (!"Domisili" %in% names(df)) return(datatable(data.frame(Message = "Kolom Domisili tidak ada")))
    agg <- df %>% group_by(Domisili) %>% summarise(count = n(), .groups = "drop")
    agg2 <- left_join(agg, coords_df, by = "Domisili")
    missing <- agg2 %>% filter(is.na(lat) | is.na(lng))
    if (nrow(missing)==0) missing <- data.frame(Message = "Semua Domisili ditemukan di lookup coords")
    datatable(missing, options = list(scrollX = TRUE, pageLength = 10))
  })
  
  # ---------------- EFA ----------------
  
  # helper: select numeric items from uploaded data (for EFA)
  
  user_data_for_efa <- reactive({
    df <- user_data()
    req(df)
    # choose numeric columns; if some Likert are stored text, try convert
    num_cols <- df %>% select(where(is.numeric))
    # if no numeric, try to coerce columns that look numeric
    if (ncol(num_cols) == 0) {
      maybe <- df %>% select(where(~ all(is.na(.) | grepl("^[-0-9.]+$", as.character(.)))))
      if (ncol(maybe) > 0) num_cols <- maybe %>% mutate(across(everything(), ~ as.numeric(as.character(.))))
    }
    if (ncol(num_cols) == 0) return(NULL)
    num_cols
  })
  
  efa_model_reactive <- eventReactive(input$run_efa, {
    df <- user_data_for_efa()
    req(df)
    if (ncol(df) < 3) {
      return(NULL)
    }
    fa_res <- fa(df, nfactors = input$efa_nfactors, rotate = input$efa_rotate, scores = "regression")
    fa_res
  }, ignoreNULL = FALSE)
  
  output$efa_scree <- renderPlot({
    df_items <- user_data_for_efa()
    if (is.null(df_items)) {
      plot.new(); text(0.5, 0.5, "Tidak ada kolom numerik untuk EFA")
      return()
    }
    fa.parallel(df_items, fa = "fa", n.iter = 20)
  })
  
  output$efa_loadings <- renderDT({
    fa_res <- efa_model_reactive()
    if (is.null(fa_res)) return(datatable(data.frame(Message = "EFA belum dijalankan atau tidak cukup variabel numeric.")))
    factor_names <- c("Kemudahan","Keamanan","Pengaruh_Sosial","Efisiensi_Transaksi","Kepercayaan")
    L <- as.data.frame(unclass(fa_res$loadings))
    colnames(L) <- factor_names[1:ncol(L)]
    datatable(round(L,3), options = list(scrollX = TRUE, pageLength = 15))
  })
  
  output$efa_assign <- renderDT({
    fa_res <- efa_model_reactive(); req(fa_res)
    L <- as.data.frame(unclass(fa_res$loadings))
    factor_names <- c("Kemudahan","Keamanan","Pengaruh_Sosial","Efisiensi_Transaksi","Kepercayaan")
    names(L) <- factor_names[1:ncol(L)]
    # pick factor with max abs loading for each variable
    assign_df <- data.frame(Variable = rownames(L),
                            BestFactor = apply(L, 1, function(x) factor_names[which.max(abs(x))]),
                            Loading = apply(L, 1, function(x) x[which.max(abs(x))]))
    datatable(assign_df, options = list(pageLength = 15, scrollX = TRUE))
  })
  
  # ---------------- BAYES ----------------
  
  output$bayes_notes <- renderUI({
    if (!has_brms) {
      HTML("<b>brms tidak ditemukan.</b> Install paket <code>brms</code> & toolchain (rstan) untuk menjalankan model Bayesian.")
    } else {
      helpText("Pastikan EFA sudah dijalankan (atau akan dipanggil otomatis). Klik Run Model Bayes untuk memulai.")
    }
  })
  
  bayes_fit_reactive <- eventReactive(input$run_bayes, {
    # guard
    if (!has_brms) return(list(error = TRUE, message = "Paket 'brms' tidak terpasang."))
    df <- user_data(); req(df)
    num_items <- user_data_for_efa(); req(num_items)
    
    # --- 1) composite Y from 4 items (names must match make.names output) ---
    y_items <- c(
      "I.intend.to.continue.using.E.Wallets.in.the.future.",
      "Because.it.s.safer.and.available.everywhere..I.will.use.E.Wallets.in.my.daily.life.",
      "Considering.the.advancements.of.the.times..I.will.continue.to.use.E.Wallets.",
      "In.my.opinion..E.Wallets.are.part.of.everyday.transactions."
    )
    missing_y <- setdiff(y_items, names(df))
    if (length(missing_y) > 0) {
      return(list(error = TRUE, message = paste0("Kolom item niat (Y) tidak lengkap. Missing: ", paste(missing_y, collapse = ", "))))
    }
    Y <- df %>% select(all_of(y_items)) %>% mutate(Intention = rowMeans(., na.rm = TRUE)) %>% pull(Intention)
    
    # --- 2) run EFA and get scores (we want 4 factors) ---
    # choose nfactors = min(4, available-1)
    nf_use <- min(4, max(1, ncol(num_items)-1))
    if (nf_use < 1) return(list(error = TRUE, message = "Tidak cukup variabel numeric untuk EFA."))
    fa_res <- tryCatch({
      fa(num_items, nfactors = nf_use, rotate = "varimax", scores = "regression")
    }, error = function(e) return(list(error = TRUE, message = e$message)))
    if (is.list(fa_res) && isTRUE(fa_res$error)) return(fa_res)
    scores <- as.data.frame(fa_res$scores)
    if (ncol(scores) < 1) return(list(error = TRUE, message = "EFA tidak menghasilkan skor faktor."))
    
    # --- 3) rename first four factors to requested names ---
    desired_names <- c("F1_Ease_of_Use","F2_Trust_Security","F3_Usefulness","F4_Social_Influence")
    names(scores)[1:ncol(scores)] <- desired_names[1:ncol(scores)]
    
    # --- 4) align lengths and combine ---
    n <- min(length(Y), nrow(scores))
    data_model <- bind_cols(data.frame(IntY = as.numeric(Y[1:n])), scores[1:n, , drop = FALSE])
    data_model <- na.omit(data_model)
    if (nrow(data_model) < 5) return(list(error = TRUE, message = "Data terlalu sedikit setelah na.omit() untuk fitting model."))
    
    # standardize predictors (recommended)
    preds_names <- names(scores)[1:ncol(scores)]
    data_model <- data_model %>% mutate(across(all_of(preds_names), ~ as.numeric(scale(.x))))
    
    # --- 5) build formula & priors ---
    fmla <- as.formula(paste("IntY ~", paste(preds_names, collapse = " + ")))
    prior_list <- c(
      set_prior(paste0("normal(0,", input$prior_intercept_sd, ")"), class = "Intercept"),
      set_prior(paste0("normal(0,", input$prior_b_sd, ")"), class = "b"),
      set_prior(paste0("student_t(", input$prior_sigma_df, ",0,2.5)"), class = "sigma")
    )
    
    # --- 6) fit model ---
    fit <- tryCatch({
      brm(formula = fmla, data = data_model,
          prior = prior_list,
          chains = input$mcmc_chains, iter = input$mcmc_iter, warmup = input$mcmc_warmup,
          seed = input$mcmc_seed,
          control = list(adapt_delta = 0.95, max_treedepth = 15),
          refresh = 0)
    }, error = function(e) {
      list(error = TRUE, message = e$message)
    })
    
    # return a list containing both the fit and mapping so UI can show names
    if (is.list(fit) && isTRUE(fit$error)) return(fit)
    attr(fit, "preds") <- preds_names
    fit
    
  }, ignoreNULL = FALSE)
  
  # Summary
  
  output$bayes_summary <- renderPrint({
    fit <- bayes_fit_reactive()
    if (is.null(fit)) { cat("Belum menjalankan model."); return() }
    if (is.list(fit) && isTRUE(fit$error)) { cat("Error saat fitting model:\n", fit$message); return() }
    print(summary(fit))
  })
  
  # Credible intervals table
  
  output$bayes_ci <- renderDT({
    fit <- bayes_fit_reactive()
    if (is.null(fit)) return(datatable(data.frame(Message="Belum ada hasil")))
    if (is.list(fit) && isTRUE(fit$error)) return(datatable(data.frame(Message = fit$message)))
    preds <- attr(fit, "preds")
    # gather posterior summary for intercept, sigma and b_*
    ps <- posterior_summary(fit, prob = 0.95)
    ps_df <- as.data.frame(ps)
    ps_df$term <- rownames(ps_df)
    # optional: filter to intercept, sigma, and b_ for our preds
    wl <- c("Intercept", paste0("b_", preds))
    ## match brms rownames (b_... may contain backticks if names contain . ; using grep)
    ps_df_filtered <- ps_df %>%
      filter(term == "Intercept" | grepl("^b_", term) | grepl("^sigma", term))
    datatable(ps_df_filtered %>% select(term, everything()), options = list(scrollX = TRUE))
  })
  
  # Traceplot
  
  output$trace_plot <- renderPlot({
    fit <- bayes_fit_reactive()
    if (is.null(fit) || (is.list(fit) && isTRUE(fit$error))) { plot.new(); text(0.5,0.5,"Traceplot tidak tersedia"); return() }
    if (!has_bayesplot || !has_posterior) { plot.new(); text(0.5,0.5,"paket bayesplot/posterior tidak tersedia"); return() }
    draws <- posterior::as_draws_df(fit)
    bpars <- grep("^b_", names(draws), value = TRUE)
    if (length(bpars) == 0) { plot.new(); text(0.5,0.5,"Tidak ada parameter 'b_' untuk traceplot"); return() }
    bayesplot::mcmc_trace(draws, pars = bpars)
  })
  
  # PPC
  
  output$pp_check_plot <- renderPlot({
    fit <- bayes_fit_reactive()
    if (is.null(fit) || (is.list(fit) && isTRUE(fit$error))) { plot.new(); text(0.5,0.5,"PPC tidak tersedia"); return() }
    tryCatch({
      brms::pp_check(fit, nsamples = 100)
    }, error = function(e) {
      plot.new(); text(0.5,0.5,paste("PPC error:", e$message))
    })
  })
  
  # Posterior areas
  
  output$posterior_areas <- renderPlot({
    fit <- bayes_fit_reactive()
    if (is.null(fit) || (is.list(fit) && isTRUE(fit$error))) { plot.new(); text(0.5,0.5,"Posterior areas tidak tersedia"); return() }
    if (!has_bayesplot || !has_posterior) { plot.new(); text(0.5,0.5,"bayesplot/posterior tidak tersedia"); return() }
    draws <- posterior::as_draws_df(fit)
    bpars <- grep("^b_", names(draws), value = TRUE)
    if (length(bpars) == 0) { plot.new(); text(0.5,0.5,"Tidak ada parameter 'b_'"); return() }
    bayesplot::mcmc_areas(draws, pars = bpars, prob = 0.95) + ggtitle("Posterior distributions (95% CI)")
  })
  
  # Forest plot
  
  output$forest_plot <- renderPlot({
    fit <- bayes_fit_reactive()
    if (is.null(fit) || (is.list(fit) && isTRUE(fit$error))) { plot.new(); text(0.5,0.5,"Forest plot tidak tersedia"); return() }
    if (!has_bayesplot || !has_posterior) { plot.new(); text(0.5,0.5,"bayesplot/posterior tidak tersedia"); return() }
    draws <- posterior::as_draws_df(fit)
    bpars <- grep("^b_", names(draws), value = TRUE)
    if (length(bpars) == 0) { plot.new(); text(0.5,0.5,"Tidak ada parameter 'b_' untuk forest plot"); return() }
    bayesplot::mcmc_intervals(draws, pars = bpars, prob = 0.95) + ggtitle("Forest Plot Koefisien (95% Credible Intervals)")
  })
 
#kesimpulan
  # ----- renderText untuk tab Kesimpulan (replace existing block) -----
  output$kesimpulan <- renderText({
    fit <- bayes_fit_reactive()
    if (is.null(fit)) return("Model belum dijalankan.")
    if (is.list(fit) && isTRUE(fit$error)) return(paste("Error saat fitting model:", fit$message))
    
    # 1) Coba ambil fixed effects via fixef() (paling rapi)
    fixed_df <- tryCatch({
      as.data.frame(fixef(fit))
    }, error = function(e) NULL)
    
    build_from_fixed <- function(preds_df) {
      # pastikan ada kolom Estimate, cari kolom CI jika ada
      preds_df$term <- rownames(preds_df)
      preds_df <- preds_df[!grepl("^Intercept$", preds_df$term, ignore.case = TRUE), , drop = FALSE]
      if (nrow(preds_df) == 0) return("Tidak ada koefisien prediktor (selain Intercept).")
      
      # cari nama kolom yang berisi estimate dan CI (robust)
      nm <- names(preds_df)
      est_col <- if ("Estimate" %in% nm) "Estimate" else nm[1]
      lower_col <- nm[grep("l[-_ ]?95|2.5", nm, ignore.case = TRUE)]
      upper_col <- nm[grep("u[-_ ]?95|97.5", nm, ignore.case = TRUE)]
      if (length(lower_col) > 0) lower_col <- lower_col[1] else lower_col <- NA
      if (length(upper_col) > 0) upper_col <- upper_col[1] else upper_col <- NA
      
      # pastikan numeric
      preds_df[[est_col]] <- as.numeric(preds_df[[est_col]])
      if (!is.na(lower_col)) preds_df[[lower_col]] <- as.numeric(preds_df[[lower_col]])
      if (!is.na(upper_col)) preds_df[[upper_col]] <- as.numeric(preds_df[[upper_col]])
      
      # baris ringkasan per koefisien
      lines <- vapply(seq_len(nrow(preds_df)), function(i) {
        lo <- if (!is.na(lower_col)) sprintf("%.2f", preds_df[i, lower_col]) else "NA"
        hi <- if (!is.na(upper_col)) sprintf("%.2f", preds_df[i, upper_col]) else "NA"
        sprintf("- %s (β = %.2f, 95%% CI [%s, %s])",
                preds_df$term[i],
                preds_df[i, est_col],
                lo, hi)
      }, FUN.VALUE = character(1))
      
      # pilih faktor dominan berdasarkan magnitude (abs)
      if (all(is.na(preds_df[[est_col]]))) {
        dominant_text <- "Tidak ada estimate numerik untuk menentukan faktor dominan."
      } else {
        idx_max <- which.max(abs(preds_df[[est_col]]))
        dominant <- preds_df$term[idx_max]
        dom_est <- sprintf("%.2f", preds_df[idx_max, est_col])
        dom_lo <- if (!is.na(lower_col)) sprintf("%.2f", preds_df[idx_max, lower_col]) else "NA"
        dom_hi <- if (!is.na(upper_col)) sprintf("%.2f", preds_df[idx_max, upper_col]) else "NA"
        dominant_text <- paste0("Faktor paling dominan adalah ", dominant,
                                " (β = ", dom_est, ", 95% CI [", dom_lo, ", ", dom_hi, "]).")
      }
      
      list(lines = lines, dominant_text = dominant_text)
    }
    
    # 2) Jika fixef() tersedia -> gunakan itu
    if (!is.null(fixed_df)) {
      res <- build_from_fixed(fixed_df)
      if (is.character(res)) return(res)
      lines <- res$lines
      dominant_text <- res$dominant_text
    } else {
      # fallback: gunakan posterior_summary()
      ps <- tryCatch(as.data.frame(posterior_summary(fit, prob = 0.95)), error = function(e) NULL)
      if (is.null(ps)) return("Gagal mengekstrak koefisien dari model.")
      ps$term <- rownames(ps)
      # ambil baris b_ (koef populasi)
      coefs <- ps[grepl("^b_", ps$term), , drop = FALSE]
      if (nrow(coefs) == 0) return("Tidak ditemukan koefisien prediktor (b_).")
      coefs$pred <- sub("^b_", "", coefs$term)
      # pastikan kolom estimate & quantile numeric
      coefs$Estimate <- as.numeric(coefs$Estimate)
      lo_col <- if ("Q2.5" %in% names(coefs)) "Q2.5" else names(coefs)[grep("2.5|l-95", names(coefs), ignore.case = TRUE)][1]
      hi_col <- if ("Q97.5" %in% names(coefs)) "Q97.5" else names(coefs)[grep("97.5|u-95", names(coefs), ignore.case = TRUE)][1]
      if (is.na(lo_col)) lo_col <- NA
      if (is.na(hi_col)) hi_col <- NA
      
      lines <- vapply(seq_len(nrow(coefs)), function(i) {
        lo <- if (!is.na(lo_col)) sprintf("%.2f", as.numeric(coefs[i, lo_col])) else "NA"
        hi <- if (!is.na(hi_col)) sprintf("%.2f", as.numeric(coefs[i, hi_col])) else "NA"
        sprintf("- %s (β = %.2f, 95%% CI [%s, %s])",
                coefs$pred[i],
                as.numeric(coefs$Estimate[i]),
                lo, hi)
      }, FUN.VALUE = character(1))
      
      if (all(is.na(coefs$Estimate))) {
        dominant_text <- "Tidak ada estimate numerik untuk menentukan faktor dominan."
      } else {
        idx_max <- which.max(abs(as.numeric(coefs$Estimate)))
        dominant <- coefs$pred[idx_max]
        dom_est <- sprintf("%.2f", as.numeric(coefs$Estimate[idx_max]))
        dom_lo <- if (!is.na(lo_col)) sprintf("%.2f", as.numeric(coefs[idx_max, lo_col])) else "NA"
        dom_hi <- if (!is.na(hi_col)) sprintf("%.2f", as.numeric(coefs[idx_max, hi_col])) else "NA"
        dominant_text <- paste0("Faktor paling dominan adalah ", dominant,
                                " (β = ", dom_est, ", 95% CI [", dom_lo, ", ", dom_hi, "]).")
      }
    }
    
    # 3) cek konvergensi & sigma (opsional)
    s <- tryCatch(summary(fit), error = function(e) NULL)
    rhat_text <- "Rhat tidak tersedia."
    if (!is.null(s) && !is.null(s$fixed) && "Rhat" %in% colnames(s$fixed)) {
      rhat_vals <- as.numeric(s$fixed[, "Rhat"])
      rhat_text <- if (all(rhat_vals < 1.01, na.rm = TRUE)) "Konvergensi baik (Rhat ≈ 1)." else "Ada indikasi masalah konvergensi (Rhat > 1.01)."
    }
    sigma_text <- "Sigma tidak tersedia."
    if (!is.null(s) && !is.null(s$spec_pars) && "sigma" %in% rownames(s$spec_pars)) {
      sigma_text <- paste0("Sigma (residual error) ≈ ", sprintf("%.2f", as.numeric(s$spec_pars["sigma", "Estimate"])), ".")
    }
    
    # 4) gabungkan hasil
    paste0(
      "Berdasarkan regresi Bayesian:\n",
      paste0(lines, collapse = "\n"),
      "\n\n",
      dominant_text, "\n",
      rhat_text, "\n",
      sigma_text, "\n\n",
      "Kesimpulan: Model menunjukkan prediktor di atas berhubungan dengan Intention."
    )
  })
  
  

} # end server

# Run app

shinyApp(ui, server)