This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
# 1. Load Library
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.3
## Warning: package 'ggplot2' was built under R version 4.4.3
## Warning: package 'tidyr' was built under R version 4.4.3
## Warning: package 'readr' was built under R version 4.4.3
## Warning: package 'purrr' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
## Warning: package 'forcats' was built under R version 4.4.3
## Warning: package 'lubridate' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(psych)
## Warning: package 'psych' was built under R version 4.4.3
##
## Attaching package: 'psych'
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(GPArotation)
## Warning: package 'GPArotation' was built under R version 4.4.3
##
## Attaching package: 'GPArotation'
##
## The following objects are masked from 'package:psych':
##
## equamax, varimin
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.4.3
## corrplot 0.95 loaded
library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 4.4.3
library(factoextra)
## Warning: package 'factoextra' was built under R version 4.4.3
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.4.3
## This is lavaan 0.6-19
## lavaan is FREE software! Please report any bugs.
##
## Attaching package: 'lavaan'
##
## The following object is masked from 'package:psych':
##
## cor2cov
library(semPlot)
## Warning: package 'semPlot' was built under R version 4.4.3
library(ggplot2)
library(semTools) # untuk reliabilitas SEM
## Warning: package 'semTools' was built under R version 4.4.3
##
## ###############################################################################
## This is semTools 0.5-7
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
##
## Attaching package: 'semTools'
##
## The following objects are masked from 'package:psych':
##
## reliability, skew
##
## The following object is masked from 'package:readr':
##
## clipboard
# 2. Load Data
data_raw <- read.csv("C:/Users/ASUS/Downloads/DataSet Academic Procrastination.csv",
header = FALSE, stringsAsFactors = FALSE)
# 3. Gunakan baris pertama sebagai header
header <- data_raw[1, ]
data_clean <- data_raw[-1, ]
colnames(data_clean) <- unlist(header)
# 3a. Ganti kolom kosong atau NA dengan nama buatan
colnames(data_clean)[is.na(colnames(data_clean)) | colnames(data_clean) == ""] <-
paste0("V", which(is.na(colnames(data_clean)) | colnames(data_clean) == ""))
# 4. Ambil kolom item mulai dari kolom ke-4
data_items <- data_clean[, 4:ncol(data_clean)]
# 5. Ubah semua ke numerik
data_items <- data_items %>% mutate(across(everything(), as.numeric))
## Warning: There were 52 warnings in `mutate()`.
## The first warning was:
## ℹ In argument: `across(everything(), as.numeric)`.
## Caused by warning:
## ! NAs introduced by coercion
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 51 remaining warnings.
# 6. Bersihkan NA
data_items <- data_items[, colMeans(is.na(data_items)) < 0.5]
data_items <- data_items[rowSums(is.na(data_items)) < ncol(data_items)*0.5, ]
data_items <- data_items %>%
mutate(across(everything(), ~ ifelse(is.na(.), mean(., na.rm = TRUE), .)))
# 6a. Ganti nama kolom item jadi Item1, Item2, dst
colnames(data_items) <- paste0("Item", 1:ncol(data_items))
# ===============================
# 6b. Deteksi dan Perlakuan Outlier
# ===============================
# Menghitung Z-score
z_scores <- scale(data_items)
outliers <- apply(z_scores, 1, function(row) any(abs(row) > 3))
# Menyimpan data tanpa outlier
data_items <- data_items[!outliers, ]
# ===============================
# 7. Statistik Deskriptif
# ===============================
print(describe(data_items))
## vars n mean sd median trimmed mad min max range skew
## Item1 1 473 3.89 1.03 4.00 4.02 1.48 1.00 5.00 4.00 -0.92
## Item2 2 473 4.04 0.86 4.00 4.12 1.48 2.00 5.00 3.00 -0.54
## Item3 3 473 3.60 1.12 4.00 3.70 1.48 1.00 5.00 4.00 -0.63
## Item4 4 473 3.87 1.03 4.00 4.00 1.48 1.00 5.00 4.00 -1.01
## Item5 5 473 4.01 0.84 4.00 4.08 1.48 2.00 5.00 3.00 -0.51
## Item6 6 473 4.13 0.86 4.00 4.23 1.48 2.00 5.00 3.00 -0.72
## Item7 7 473 3.69 0.89 4.00 3.72 1.48 1.00 5.00 4.00 -0.60
## Item8 8 473 3.72 1.16 4.00 3.84 1.48 1.00 5.00 4.00 -0.58
## Item9 9 473 3.91 1.05 4.00 4.05 1.48 1.00 5.00 4.00 -0.96
## Item10 10 473 4.02 0.88 4.00 4.11 1.48 2.00 5.00 3.00 -0.63
## Item11 11 473 3.65 1.13 4.00 3.79 1.48 1.00 5.00 4.00 -0.86
## Item12 12 473 3.84 0.92 4.00 3.91 1.48 1.00 5.00 4.00 -0.74
## Item13 13 473 3.62 1.11 4.00 3.72 1.48 1.00 5.00 4.00 -0.70
## Item14 14 473 3.89 1.10 4.00 4.04 1.48 1.00 5.00 4.00 -0.94
## Item15 15 473 3.74 1.01 4.00 3.84 1.48 1.00 5.00 4.00 -0.72
## Item16 16 473 3.77 1.13 4.00 3.92 1.48 1.00 5.00 4.00 -0.86
## Item17 17 473 3.88 1.08 4.00 4.04 1.48 1.00 5.00 4.00 -1.06
## Item18 18 473 3.82 1.03 4.00 3.96 1.48 1.00 5.00 4.00 -1.09
## Item19 19 473 3.85 1.05 4.00 3.95 1.48 1.00 5.00 4.00 -0.62
## Item20 20 473 3.39 1.03 3.00 3.37 1.48 1.00 5.00 4.00 0.17
## Item21 21 473 3.52 1.02 3.00 3.57 1.48 1.00 5.00 4.00 -0.28
## Item22 22 473 3.53 0.96 3.00 3.58 1.48 1.00 5.00 4.00 -0.21
## Item23 23 473 3.50 1.06 4.00 3.50 1.48 1.00 5.00 4.00 -0.08
## Item24 24 473 3.98 0.90 4.00 4.07 1.48 2.00 5.00 3.00 -0.56
## Item25 25 473 3.75 0.88 4.00 3.79 1.48 2.00 5.00 3.00 -0.18
## Item26 26 473 3.40 1.15 3.00 3.41 1.48 1.00 5.00 4.00 0.02
## Item27 27 473 3.75 1.02 4.00 3.83 1.48 1.00 5.00 4.00 -0.70
## Item28 28 473 3.52 1.06 4.00 3.54 1.48 1.00 5.00 4.00 -0.19
## Item29 29 473 3.91 0.76 4.00 3.92 1.48 2.00 5.00 3.00 -0.19
## Item30 30 473 4.15 0.78 4.00 4.22 1.48 2.00 5.00 3.00 -0.57
## Item31 31 473 3.64 1.00 4.00 3.72 1.48 1.00 5.00 4.00 -0.59
## Item32 32 473 3.83 1.25 4.00 4.02 1.48 1.00 5.00 4.00 -0.93
## Item33 33 473 3.68 1.22 4.00 3.85 1.48 1.00 5.00 4.00 -0.90
## Item34 34 473 3.84 0.99 4.00 3.96 1.48 1.00 5.00 4.00 -0.88
## Item35 35 473 3.65 0.98 4.00 3.73 1.48 1.00 5.00 4.00 -0.83
## Item36 36 473 3.75 1.12 4.00 3.87 1.48 1.00 5.00 4.00 -0.68
## Item37 37 473 3.60 1.16 4.00 3.72 1.48 1.00 5.00 4.00 -0.67
## Item38 38 473 3.80 1.05 4.00 3.94 1.48 1.00 5.00 4.00 -0.95
## Item39 39 473 4.00 0.73 4.00 4.02 0.00 2.00 5.00 3.00 -0.24
## Item40 40 473 3.66 1.01 4.00 3.74 1.48 1.00 5.00 4.00 -0.60
## Item41 41 473 3.77 1.25 4.00 3.96 1.48 1.00 5.00 4.00 -0.85
## Item42 42 473 3.85 1.14 4.00 4.01 1.48 1.00 5.00 4.00 -0.95
## Item43 43 473 3.84 1.03 4.00 3.98 1.48 1.00 5.00 4.00 -1.03
## Item44 44 473 3.70 1.08 4.00 3.83 1.48 1.00 5.00 4.00 -0.87
## Item45 45 473 69.10 5.09 70.00 69.35 4.45 54.00 80.00 26.00 -0.44
## Item46 46 473 96.84 6.00 97.00 96.96 5.93 80.00 111.00 31.00 -0.18
## Item47 47 473 3.84 0.28 3.89 3.85 0.25 3.00 4.44 1.44 -0.44
## Item48 48 473 3.72 0.23 3.73 3.73 0.22 3.08 4.27 1.19 -0.18
## kurtosis se
## Item1 0.57 0.05
## Item2 -0.49 0.04
## Item3 -0.31 0.05
## Item4 0.95 0.05
## Item5 -0.39 0.04
## Item6 -0.25 0.04
## Item7 0.83 0.04
## Item8 -0.51 0.05
## Item9 0.57 0.05
## Item10 -0.33 0.04
## Item11 0.12 0.05
## Item12 0.78 0.04
## Item13 -0.20 0.05
## Item14 0.29 0.05
## Item15 0.26 0.05
## Item16 0.15 0.05
## Item17 0.66 0.05
## Item18 1.08 0.05
## Item19 -0.51 0.05
## Item20 -1.07 0.05
## Item21 -0.30 0.05
## Item22 -0.15 0.04
## Item23 -1.09 0.05
## Item24 -0.47 0.04
## Item25 -0.75 0.04
## Item26 -1.11 0.05
## Item27 0.40 0.05
## Item28 -0.89 0.05
## Item29 -0.51 0.03
## Item30 -0.29 0.04
## Item31 0.21 0.05
## Item32 -0.09 0.06
## Item33 -0.03 0.06
## Item34 0.56 0.05
## Item35 0.85 0.04
## Item36 -0.23 0.05
## Item37 -0.32 0.05
## Item38 0.58 0.05
## Item39 -0.48 0.03
## Item40 0.24 0.05
## Item41 -0.21 0.06
## Item42 0.24 0.05
## Item43 0.85 0.05
## Item44 0.41 0.05
## Item45 -0.28 0.23
## Item46 -0.46 0.28
## Item47 -0.29 0.01
## Item48 -0.45 0.01
# 8. Korelasi dan Heatmap
cor_matrix <- cor(data_items)
corrplot(cor_matrix, method = "color", type = "upper", tl.cex = 0.6)
# 9. PCA dan Biplot
pca <- PCA(data_items, graph = FALSE)
fviz_eig(pca, addlabels = TRUE, ylim = c(0, 50))
fviz_pca_biplot(pca, repel = TRUE, col.var = "steelblue", col.ind = "orange")
# 10. Exploratory Factor Analysis (EFA)
fa_result <- fa(data_items, nfactors = 3, rotate = "varimax")
## Warning in cor.smooth(r): Matrix was not positive definite, smoothing was done
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs = np.obs, :
## The estimated weights for the factor scores are probably incorrect. Try a
## different factor score estimation method.
## Warning in fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, : An
## ultra-Heywood case was detected. Examine the results carefully
## In factor.scores, the correlation matrix is singular, the pseudo inverse is used
print(fa_result)
## Factor Analysis using method = minres
## Call: fa(r = data_items, nfactors = 3, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 MR2 MR3 h2 u2 com
## Item1 0.13 0.02 0.02 0.0190 0.981 1.1
## Item2 0.04 0.07 0.09 0.0150 0.985 2.4
## Item3 0.13 0.00 0.02 0.0179 0.982 1.0
## Item4 0.07 -0.01 0.10 0.0138 0.986 1.8
## Item5 0.33 -0.06 0.00 0.1148 0.885 1.1
## Item6 0.08 0.05 0.32 0.1129 0.887 1.2
## Item7 0.19 -0.04 -0.03 0.0400 0.960 1.1
## Item8 0.22 0.04 0.31 0.1454 0.855 1.8
## Item9 0.03 0.02 0.39 0.1560 0.844 1.0
## Item10 0.41 -0.04 -0.25 0.2306 0.769 1.7
## Item11 0.50 0.07 -0.22 0.3050 0.695 1.4
## Item12 0.17 -0.06 0.06 0.0364 0.964 1.5
## Item13 0.25 0.04 0.01 0.0636 0.936 1.1
## Item14 0.11 0.03 0.28 0.0894 0.911 1.3
## Item15 0.33 -0.04 0.04 0.1101 0.890 1.1
## Item16 0.03 0.05 0.51 0.2665 0.733 1.0
## Item17 0.39 0.00 -0.07 0.1545 0.846 1.1
## Item18 0.42 0.01 -0.24 0.2350 0.765 1.6
## Item19 0.13 0.13 -0.08 0.0419 0.958 2.6
## Item20 -0.06 0.18 0.16 0.0597 0.940 2.2
## Item21 0.00 0.05 -0.16 0.0297 0.970 1.2
## Item22 0.00 0.13 0.02 0.0164 0.984 1.1
## Item23 -0.09 0.24 0.19 0.1015 0.898 2.2
## Item24 -0.09 0.13 0.13 0.0405 0.959 2.8
## Item25 0.08 0.10 -0.18 0.0500 0.950 2.0
## Item26 -0.08 0.20 0.24 0.1034 0.897 2.2
## Item27 -0.04 0.18 0.00 0.0332 0.967 1.1
## Item28 -0.16 0.20 0.19 0.0997 0.900 2.9
## Item29 0.05 0.16 -0.13 0.0477 0.952 2.1
## Item30 0.08 0.03 -0.27 0.0825 0.918 1.2
## Item31 -0.07 0.06 0.00 0.0077 0.992 2.0
## Item32 -0.09 0.32 -0.09 0.1164 0.884 1.3
## Item33 -0.15 0.28 -0.13 0.1175 0.883 2.1
## Item34 0.06 0.28 0.06 0.0834 0.917 1.2
## Item35 -0.01 0.31 0.19 0.1287 0.871 1.7
## Item36 0.14 0.20 0.04 0.0613 0.939 1.9
## Item37 0.00 0.26 0.00 0.0669 0.933 1.0
## Item38 -0.07 0.21 -0.04 0.0503 0.950 1.3
## Item39 0.05 0.08 -0.17 0.0361 0.964 1.6
## Item40 0.09 0.15 -0.16 0.0559 0.944 2.5
## Item41 0.05 0.23 0.03 0.0545 0.945 1.1
## Item42 0.03 0.20 -0.06 0.0453 0.955 1.2
## Item43 0.06 0.14 -0.03 0.0261 0.974 1.5
## Item44 -0.08 0.08 0.04 0.0151 0.985 2.5
## Item45 0.95 0.05 0.39 1.0597 -0.060 1.3
## Item46 -0.05 1.04 -0.04 1.0753 -0.075 1.0
## Item47 0.95 0.05 0.38 1.0598 -0.060 1.3
## Item48 -0.05 1.03 -0.04 1.0751 -0.075 1.0
##
## MR1 MR2 MR3
## SS loadings 3.20 3.12 1.65
## Proportion Var 0.07 0.07 0.03
## Cumulative Var 0.07 0.13 0.17
## Proportion Explained 0.40 0.39 0.21
## Cumulative Proportion 0.40 0.79 1.00
##
## Mean item complexity = 1.6
## Test of the hypothesis that 3 factors are sufficient.
##
## df null model = 1128 with the objective function = 68.34 with Chi Square = 31106.96
## df of the model are 987 and the objective function was 58.53
##
## The root mean square of the residuals (RMSR) is 0.06
## The df corrected root mean square of the residuals is 0.07
##
## The harmonic n.obs is 473 with the empirical chi square 3960.27 with prob < 0
## The total n.obs was 473 with Likelihood Chi Square = 26523.56 with prob < 0
##
## Tucker Lewis Index of factoring reliability = 0.022
## RMSEA index = 0.234 and the 90 % confidence intervals are 0.232 0.237
## BIC = 20444.53
## Fit based upon off diagonal values = 0.69
fa.diagram(fa_result)
# 11. CFA
cfa_model <- '
Faktor1 =~ Item1 + Item2 + Item3 + Item4 + Item5
Faktor2 =~ Item6 + Item7 + Item8 + Item9 + Item10
Faktor3 =~ Item11 + Item12 + Item13 + Item14 + Item15
'
fit_cfa <- cfa(cfa_model, data = data_items)
## Warning: lavaan->lav_object_post_check():
## some estimated lv variances are negative
summary(fit_cfa, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 190 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 33
##
## Number of observations 473
##
## Model Test User Model:
##
## Test statistic 315.569
## Degrees of freedom 87
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 468.983
## Degrees of freedom 105
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.372
## Tucker-Lewis Index (TLI) 0.242
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -9939.571
## Loglikelihood unrestricted model (H1) -9781.786
##
## Akaike (AIC) 19945.141
## Bayesian (BIC) 20082.391
## Sample-size adjusted Bayesian (SABIC) 19977.655
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.075
## 90 Percent confidence interval - lower 0.066
## 90 Percent confidence interval - upper 0.083
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 0.160
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.072
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Faktor1 =~
## Item1 1.000 0.470 0.457
## Item2 -0.124 0.143 -0.867 0.386 -0.058 -0.068
## Item3 0.051 0.181 0.280 0.779 0.024 0.021
## Item4 0.941 0.413 2.278 0.023 0.442 0.430
## Item5 -0.459 0.193 -2.376 0.018 -0.216 -0.257
## Faktor2 =~
## Item6 1.000 0.040 0.047
## Item7 -5.950 6.847 -0.869 0.385 -0.240 -0.269
## Item8 3.432 4.183 0.820 0.412 0.138 0.119
## Item9 7.462 8.573 0.870 0.384 0.301 0.286
## Item10 -18.560 21.491 -0.864 0.388 -0.748 -0.848
## Faktor3 =~
## Item11 1.000 NA NA
## Item12 0.055 0.059 0.927 0.354 NA NA
## Item13 0.071 0.075 0.940 0.347 NA NA
## Item14 0.021 0.040 0.513 0.608 NA NA
## Item15 -0.100 0.101 -0.998 0.318 NA NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Faktor1 ~~
## Faktor2 0.000 0.002 0.215 0.830 0.020 0.020
## Faktor3 -0.075 0.042 -1.781 0.075 -0.140 -0.140
## Faktor2 ~~
## Faktor3 -0.016 0.018 -0.858 0.391 -0.343 -0.343
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Item1 0.835 0.114 7.292 0.000 0.835 0.791
## .Item2 0.737 0.048 15.259 0.000 0.737 0.995
## .Item3 1.254 0.082 15.367 0.000 1.254 1.000
## .Item4 0.863 0.106 8.165 0.000 0.863 0.815
## .Item5 0.660 0.049 13.450 0.000 0.660 0.934
## .Item6 0.735 0.048 15.366 0.000 0.735 0.998
## .Item7 0.736 0.051 14.522 0.000 0.736 0.927
## .Item8 1.333 0.087 15.287 0.000 1.333 0.986
## .Item9 1.015 0.071 14.337 0.000 1.015 0.918
## .Item10 0.219 0.145 1.517 0.129 0.219 0.281
## .Item11 2.577 1.461 1.764 0.078 2.577 2.021
## .Item12 0.842 0.055 15.239 0.000 0.842 1.005
## .Item13 1.231 0.081 15.218 0.000 1.231 1.005
## .Item14 1.212 0.079 15.367 0.000 1.212 1.000
## .Item15 1.032 0.069 14.897 0.000 1.032 1.013
## Faktor1 0.220 0.109 2.020 0.043 1.000 1.000
## Faktor2 0.002 0.004 0.439 0.661 1.000 1.000
## Faktor3 -1.302 1.444 -0.901 0.367 NA NA
semPaths(fit_cfa, "std", layout = "tree", whatLabels = "std", edge.label.cex = 0.8)
## Warning in qgraph::qgraph(Edgelist, labels = nLab, bidirectional = Bidir, :
## Non-finite weights are omitted
# 11a. Reliabilitas (Cronbach's Alpha)
cat("\n=== Cronbach's Alpha ===\n")
##
## === Cronbach's Alpha ===
cat("Faktor 1:\n"); print(alpha(data_items[, 1:5]))
## Faktor 1:
## Warning in alpha(data_items[, 1:5]): Some items were negatively correlated with the first principal component and probably
## should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( Item2 Item5 ) were negatively correlated with the first principal component and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Reliability analysis
## Call: alpha(x = data_items[, 1:5])
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.059 0.046 0.075 0.0096 0.048 0.068 3.9 0.45 -0.007
##
## 95% confidence boundaries
## lower alpha upper
## Feldt -0.08 0.06 0.19
## Duhachek -0.07 0.06 0.19
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Item1 0.013 0.016 0.0325 0.0041 0.016 0.073 0.0076 0.0097
## Item2 -0.017 -0.049 0.0024 -0.0117 -0.046 0.075 0.0156 -0.0424
## Item3 0.075 0.056 0.0737 0.0146 0.059 0.068 0.0140 -0.0131
## Item4 -0.054 -0.049 -0.0114 -0.0118 -0.047 0.078 0.0089 -0.0193
## Item5 0.184 0.182 0.1638 0.0528 0.223 0.061 0.0092 0.0097
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Item1 473 0.50 0.47 0.207 0.0498 3.9 1.03
## Item2 473 0.46 0.51 0.302 0.0835 4.0 0.86
## Item3 473 0.50 0.44 0.062 0.0055 3.6 1.12
## Item4 473 0.54 0.51 0.349 0.0982 3.9 1.03
## Item5 473 0.26 0.34 -0.298 -0.1146 4.0 0.84
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Item1 0.04 0.05 0.21 0.39 0.31 0
## Item2 0.00 0.05 0.20 0.40 0.34 0
## Item3 0.06 0.11 0.22 0.38 0.22 0
## Item4 0.05 0.02 0.23 0.41 0.30 0
## Item5 0.00 0.05 0.20 0.44 0.31 0
cat("Faktor 2:\n"); print(alpha(data_items[, 6:10]))
## Faktor 2:
## Warning in alpha(data_items[, 6:10]): Some items were negatively correlated with the first principal component and probably
## should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( Item7 Item10 ) were negatively correlated with the first principal component and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Reliability analysis
## Call: alpha(x = data_items[, 6:10])
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.066 0.085 0.14 0.018 0.093 0.068 3.9 0.45 0.033
##
## 95% confidence boundaries
## lower alpha upper
## Feldt -0.07 0.07 0.19
## Duhachek -0.07 0.07 0.20
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Item6 -0.182 -0.178 -0.064 -0.039 -0.151 0.088 0.028 -0.094
## Item7 0.035 0.016 0.065 0.004 0.016 0.070 0.024 0.033
## Item8 0.041 0.075 0.132 0.020 0.081 0.073 0.033 0.057
## Item9 0.147 0.178 0.184 0.051 0.216 0.065 0.020 0.059
## Item10 0.179 0.190 0.189 0.055 0.234 0.061 0.017 0.123
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Item6 473 0.58 0.61 0.564 0.232 4.1 0.86
## Item7 473 0.44 0.50 0.288 0.045 3.7 0.89
## Item8 473 0.55 0.46 0.121 0.036 3.7 1.16
## Item9 473 0.43 0.38 -0.042 -0.043 3.9 1.05
## Item10 473 0.30 0.37 -0.058 -0.093 4.0 0.88
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Item6 0.00 0.05 0.16 0.39 0.40 0
## Item7 0.03 0.02 0.35 0.43 0.17 0
## Item8 0.05 0.10 0.26 0.27 0.33 0
## Item9 0.04 0.04 0.20 0.37 0.33 0
## Item10 0.00 0.07 0.18 0.42 0.33 0
cat("Faktor 3:\n"); print(alpha(data_items[, 11:15]))
## Faktor 3:
## Warning in alpha(data_items[, 11:15]): Some items were negatively correlated with the first principal component and probably
## should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Some items ( Item14 ) were negatively correlated with the first principal component and
## probably should be reversed.
## To do this, run the function again with the 'check.keys=TRUE' option
## Reliability analysis
## Call: alpha(x = data_items[, 11:15])
##
## raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r
## 0.13 0.14 0.13 0.032 0.16 0.063 3.7 0.5 0.035
##
## 95% confidence boundaries
## lower alpha upper
## Feldt 0 0.13 0.25
## Duhachek 0 0.13 0.25
##
## Reliability if an item is dropped:
## raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r
## Item11 0.145 0.1598 0.1342 0.045 0.1902 0.064 0.0042 0.0758
## Item12 0.081 0.0890 0.0824 0.024 0.0977 0.069 0.0059 0.0021
## Item13 0.118 0.1239 0.1123 0.034 0.1414 0.066 0.0066 0.0352
## Item14 0.189 0.1923 0.1666 0.056 0.2381 0.061 0.0064 0.0877
## Item15 -0.016 -0.0041 0.0097 -0.001 -0.0041 0.076 0.0049 -0.0111
##
## Item statistics
## n raw.r std.r r.cor r.drop mean sd
## Item11 473 0.47 0.44 0.085 0.023 3.7 1.13
## Item12 473 0.44 0.49 0.233 0.081 3.8 0.92
## Item13 473 0.48 0.47 0.152 0.045 3.6 1.11
## Item14 473 0.43 0.41 -0.011 -0.016 3.9 1.10
## Item15 473 0.54 0.56 0.413 0.162 3.7 1.01
##
## Non missing response frequency for each item
## 1 2 3 4 5 miss
## Item11 0.08 0.07 0.19 0.44 0.22 0
## Item12 0.03 0.03 0.27 0.43 0.25 0
## Item13 0.05 0.11 0.20 0.42 0.22 0
## Item14 0.05 0.07 0.18 0.36 0.34 0
## Item15 0.04 0.07 0.25 0.41 0.23 0
# 11b. Composite Reliability & AVE
cat("\n=== Composite Reliability & AVE ===\n")
##
## === Composite Reliability & AVE ===
print(reliability(fit_cfa))
## Warning in reliability(fit_cfa):
## The reliability() function was deprecated in 2022 and will cease to be included in future versions of semTools. See help('semTools-deprecated) for details.
##
## It is replaced by the compRelSEM() function, which can estimate alpha and model-based reliability in an even wider variety of models and data types, with greater control in specifying the desired type of reliability coefficient (i.e., more explicitly choosing assumptions).
##
## The average variance extracted should never have been included because it is not a reliability coefficient. It is now available from the AVE() function.
## Faktor1 Faktor2 Faktor3
## alpha 0.05870084 0.06641604 0.1287633
## omega 0.09143158 0.06021951 -0.2603575
## omega2 0.09143158 0.06021951 -0.2603575
## omega3 0.08662117 0.05139681 -0.2294176
## avevar 0.09681929 0.15289663 -0.2381208
# 12. SEM
sem_model <- '
Faktor1 =~ Item1 + Item2 + Item3 + Item4 + Item5
Faktor2 =~ Item6 + Item7 + Item8 + Item9 + Item10
Faktor3 =~ Item11 + Item12 + Item13 + Item14 + Item15
Faktor3 ~ Faktor1 + Faktor2
'
fit_sem <- sem(sem_model, data = data_items)
## Warning: lavaan->lav_object_post_check():
## some estimated lv variances are negative
summary(fit_sem, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-19 ended normally after 174 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 33
##
## Number of observations 473
##
## Model Test User Model:
##
## Test statistic 315.569
## Degrees of freedom 87
## P-value (Chi-square) 0.000
##
## Model Test Baseline Model:
##
## Test statistic 468.983
## Degrees of freedom 105
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.372
## Tucker-Lewis Index (TLI) 0.242
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -9939.571
## Loglikelihood unrestricted model (H1) -9781.786
##
## Akaike (AIC) 19945.141
## Bayesian (BIC) 20082.391
## Sample-size adjusted Bayesian (SABIC) 19977.655
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.075
## 90 Percent confidence interval - lower 0.066
## 90 Percent confidence interval - upper 0.083
## P-value H_0: RMSEA <= 0.050 0.000
## P-value H_0: RMSEA >= 0.080 0.160
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.072
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Faktor1 =~
## Item1 1.000 0.470 0.457
## Item2 -0.124 0.143 -0.867 0.386 -0.058 -0.068
## Item3 0.051 0.181 0.280 0.779 0.024 0.021
## Item4 0.941 0.413 2.279 0.023 0.442 0.430
## Item5 -0.459 0.193 -2.376 0.018 -0.216 -0.257
## Faktor2 =~
## Item6 1.000 0.040 0.047
## Item7 -5.950 6.847 -0.869 0.385 -0.240 -0.269
## Item8 3.432 4.184 0.820 0.412 0.138 0.119
## Item9 7.462 8.574 0.870 0.384 0.301 0.286
## Item10 -18.561 21.492 -0.864 0.388 -0.748 -0.848
## Faktor3 =~
## Item11 1.000 NA NA
## Item12 0.055 0.059 0.927 0.354 NA NA
## Item13 0.071 0.075 0.940 0.347 NA NA
## Item14 0.021 0.040 0.513 0.608 NA NA
## Item15 -0.100 0.101 -0.998 0.318 NA NA
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Faktor3 ~
## Faktor1 -0.324 0.191 -1.691 0.091 NA NA
## Faktor2 -9.638 11.029 -0.874 0.382 NA NA
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## Faktor1 ~~
## Faktor2 0.000 0.002 0.215 0.830 0.020 0.020
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Item1 0.835 0.114 7.293 0.000 0.835 0.791
## .Item2 0.737 0.048 15.258 0.000 0.737 0.995
## .Item3 1.254 0.082 15.367 0.000 1.254 1.000
## .Item4 0.863 0.106 8.165 0.000 0.863 0.815
## .Item5 0.660 0.049 13.450 0.000 0.660 0.934
## .Item6 0.735 0.048 15.366 0.000 0.735 0.998
## .Item7 0.736 0.051 14.522 0.000 0.736 0.927
## .Item8 1.333 0.087 15.287 0.000 1.333 0.986
## .Item9 1.015 0.071 14.337 0.000 1.015 0.918
## .Item10 0.219 0.145 1.517 0.129 0.219 0.281
## .Item11 2.577 1.461 1.764 0.078 2.577 2.021
## .Item12 0.842 0.055 15.239 0.000 0.842 1.005
## .Item13 1.231 0.081 15.218 0.000 1.231 1.005
## .Item14 1.212 0.079 15.367 0.000 1.212 1.000
## .Item15 1.032 0.069 14.897 0.000 1.032 1.013
## Faktor1 0.220 0.109 2.020 0.043 1.000 1.000
## Faktor2 0.002 0.004 0.439 0.661 1.000 1.000
## .Faktor3 -1.478 1.459 -1.013 0.311 NA NA
semPaths(fit_sem, "std", layout = "circle", whatLabels = "std", edge.label.cex = 0.8)
## Warning in qgraph::qgraph(Edgelist, labels = nLab, bidirectional = Bidir, :
## Non-finite weights are omitted
# 13. MDS - Perceptual Mapping
dist_matrix <- dist(data_items)
mds_result <- cmdscale(dist_matrix, k = 2)
mds_df <- as.data.frame(mds_result)
colnames(mds_df) <- c("Dim1", "Dim2")
ggplot(mds_df, aes(x = Dim1, y = Dim2)) +
geom_point(color = "blue") +
geom_text(aes(label = rownames(mds_df)), vjust = -0.5) +
ggtitle("Perceptual Mapping dengan MDS")
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.