library(readxl)
## Warning: package 'readxl' was built under R version 4.3.1
data <- read_excel("C:/Users/fedh/Downloads/Data soal_Olimstat SMATIC 6.0.xlsx", sheet = "all")
# Jumlah missing value per kolom
colSums(is.na(data))
## id_responden Pajanan_Teknologi_Pendidikan
## 0 0
## Partisipasi_Seni_Olahraga Indeks_Kematangan_Karakter
## 0 0
## Indeks_Gizi_Seimbang Skor_Kognitif_Terstandarisasi
## 0 0
## Kualitas_Interaksi_OrangTua Iklim_Belajar_Sekolah
## 0 0
# Atau proporsi missing per kolom
sapply(data, function(x) sum(is.na(x)) / length(x))
## id_responden Pajanan_Teknologi_Pendidikan
## 0 0
## Partisipasi_Seni_Olahraga Indeks_Kematangan_Karakter
## 0 0
## Indeks_Gizi_Seimbang Skor_Kognitif_Terstandarisasi
## 0 0
## Kualitas_Interaksi_OrangTua Iklim_Belajar_Sekolah
## 0 0
# Cek kategori unik untuk kolom kategorik
sapply(data[, sapply(data, is.factor) | sapply(data, is.character)], unique)
## named list()
# Pilih hanya kolom numerik
data_numeric <- data[sapply(data, is.numeric)]
# Hilangkan baris yang memiliki NA
data_numeric_clean <- na.omit(data_numeric)
# Hitung Mahalanobis distance
mahal_dist <- mahalanobis(data_numeric_clean,
colMeans(data_numeric_clean),
cov(data_numeric_clean))
# Threshold untuk outlier (misalnya p < 0.001)
threshold <- qchisq(0.95, df = ncol(data_numeric_clean))
# Cek baris mana yang outlier
outliers <- which(mahal_dist > threshold)
outliers
## integer(0)
# Tampilkan data outlier
print(data_numeric_clean[outliers, ])
## # A tibble: 0 × 8
## # ℹ 8 variables: id_responden <dbl>, Pajanan_Teknologi_Pendidikan <dbl>,
## # Partisipasi_Seni_Olahraga <dbl>, Indeks_Kematangan_Karakter <dbl>,
## # Indeks_Gizi_Seimbang <dbl>, Skor_Kognitif_Terstandarisasi <dbl>,
## # Kualitas_Interaksi_OrangTua <dbl>, Iklim_Belajar_Sekolah <dbl>
print(mahal_dist)
## [1] 8.044916 6.852646 13.477065 5.473531 11.654947 9.776378 9.226613
## [8] 7.954114 4.451310 11.384368 7.022103 10.821188 4.351534 12.192431
## [15] 3.287329 7.618555 12.686761 8.893243 12.469638 7.382805 5.959790
## [22] 5.954849 9.595686 10.617078 7.044247 8.686328 4.018015 10.839334
## [29] 9.896216 6.986202 10.047581 9.125144 3.397451 6.737675 11.258849
## [36] 3.313559 15.253950 8.023365 12.330639 1.956474 7.182699 6.809685
## [43] 7.695384 11.665571 4.227995 8.546107 7.030540 6.083638 6.532287
## [50] 9.513534 3.352283 5.391119 4.638721 5.185014 7.094302 5.017018
## [57] 4.927295 10.369345 9.262915 6.099181 5.457737 5.582657 7.768061
## [64] 7.705372 3.632260 6.371837 9.788965 5.079905 7.266427 11.579464
## [71] 7.513874 8.088548 3.814434 5.000587 11.417476 6.297667 7.845627
## [78] 4.858003 6.653045 7.250934 9.003277 7.126210 4.835000 10.555607
## [85] 6.827366 5.287018 13.608833 11.485042 8.951839 9.521158 11.075939
## [92] 9.637999 8.763002 9.528837 9.015739 8.724662 9.504224 9.192156
## [99] 6.514639 11.180033
print(threshold)
## [1] 15.50731
# Ringkasan untuk seluruh variabel
summary(data)
## id_responden Pajanan_Teknologi_Pendidikan Partisipasi_Seni_Olahraga
## Min. : 1.00 Min. :1.000 Min. :0.00
## 1st Qu.: 25.75 1st Qu.:3.300 1st Qu.:0.00
## Median : 50.50 Median :5.850 Median :1.00
## Mean : 50.50 Mean :5.717 Mean :0.65
## 3rd Qu.: 75.25 3rd Qu.:7.850 3rd Qu.:1.00
## Max. :100.00 Max. :9.900 Max. :1.00
## Indeks_Kematangan_Karakter Indeks_Gizi_Seimbang Skor_Kognitif_Terstandarisasi
## Min. : 51.69 Min. :2.500 Min. :53.00
## 1st Qu.: 70.84 1st Qu.:4.375 1st Qu.:66.92
## Median : 75.95 Median :6.700 Median :73.84
## Mean : 76.35 Mean :6.399 Mean :74.52
## 3rd Qu.: 82.52 3rd Qu.:8.125 3rd Qu.:81.88
## Max. :100.00 Max. :9.700 Max. :97.66
## Kualitas_Interaksi_OrangTua Iklim_Belajar_Sekolah
## Min. : 1.900 Min. :3.500
## 1st Qu.: 3.300 1st Qu.:5.300
## Median : 5.200 Median :6.600
## Mean : 5.413 Mean :6.772
## 3rd Qu.: 6.750 3rd Qu.:8.400
## Max. :10.000 Max. :9.900
# Statistik deskriptif lebih detail untuk variabel numerik
library(psych)
## Warning: package 'psych' was built under R version 4.3.3
describe(data)
## vars n mean sd median trimmed mad min
## id_responden 1 100 50.50 29.01 50.50 50.50 37.06 1.00
## Pajanan_Teknologi_Pendidikan 2 100 5.72 2.72 5.85 5.78 3.48 1.00
## Partisipasi_Seni_Olahraga 3 100 0.65 0.48 1.00 0.69 0.00 0.00
## Indeks_Kematangan_Karakter 4 100 76.35 9.90 75.95 76.39 8.27 51.69
## Indeks_Gizi_Seimbang 5 100 6.40 2.12 6.70 6.43 2.52 2.50
## Skor_Kognitif_Terstandarisasi 6 100 74.52 9.70 73.84 74.43 11.21 53.00
## Kualitas_Interaksi_OrangTua 7 100 5.41 2.35 5.20 5.31 2.82 1.90
## Iklim_Belajar_Sekolah 8 100 6.77 1.93 6.60 6.76 2.37 3.50
## max range skew kurtosis se
## id_responden 100.00 99.00 0.00 -1.24 2.90
## Pajanan_Teknologi_Pendidikan 9.90 8.90 -0.14 -1.23 0.27
## Partisipasi_Seni_Olahraga 1.00 1.00 -0.62 -1.63 0.05
## Indeks_Kematangan_Karakter 100.00 48.31 0.01 -0.14 0.99
## Indeks_Gizi_Seimbang 9.70 7.20 -0.20 -1.27 0.21
## Skor_Kognitif_Terstandarisasi 97.66 44.66 0.07 -0.56 0.97
## Kualitas_Interaksi_OrangTua 10.00 8.10 0.37 -1.01 0.24
## Iklim_Belajar_Sekolah 9.90 6.40 0.08 -1.24 0.19
# Cek frekuensi
table(data$Partisipasi_Seni_Olahraga)
##
## 0 1
## 35 65
# Cek proporsi
prop.table(table(data$Partisipasi_Seni_Olahraga))
##
## 0 1
## 0.35 0.65
# Contoh nama variabel
x_vars <- c("Pajanan_Teknologi_Pendidikan", "Indeks_Gizi_Seimbang",
"Iklim_Belajar_Sekolah", "Kualitas_Interaksi_OrangTua")
y_vars <- c("Skor_Kognitif_Terstandarisasi", "Indeks_Kematangan_Karakter")
library(psych)
# Hanya korelasi X ke Y
corr_table <- corr.test(data[x_vars], data[y_vars], method = "spearman")
# Lihat korelasi dan p-value
corr_table$r # nilai korelasi
## Skor_Kognitif_Terstandarisasi
## Pajanan_Teknologi_Pendidikan 0.5957405
## Indeks_Gizi_Seimbang 0.4002071
## Iklim_Belajar_Sekolah 0.3697091
## Kualitas_Interaksi_OrangTua 0.1325489
## Indeks_Kematangan_Karakter
## Pajanan_Teknologi_Pendidikan 0.2294371
## Indeks_Gizi_Seimbang 0.1777000
## Iklim_Belajar_Sekolah 0.4895195
## Kualitas_Interaksi_OrangTua 0.4972690
corr_table$p # p-value
## Skor_Kognitif_Terstandarisasi
## Pajanan_Teknologi_Pendidikan 6.224327e-11
## Indeks_Gizi_Seimbang 3.698449e-05
## Iklim_Belajar_Sekolah 1.533034e-04
## Kualitas_Interaksi_OrangTua 1.886334e-01
## Indeks_Kematangan_Karakter
## Pajanan_Teknologi_Pendidikan 2.166173e-02
## Indeks_Gizi_Seimbang 7.693326e-02
## Iklim_Belajar_Sekolah 2.359644e-07
## Kualitas_Interaksi_OrangTua 1.417133e-07
# 1. Install dan load paket
library(lavaan)
## Warning: package 'lavaan' was built under R version 4.3.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
# 2. Import data dari sheet bernama "0"
data_0 <- read_excel("C:/Users/fedh/Downloads/Data soal_Olimstat SMATIC 6.0.xlsx", sheet = "0")
# 3. Tentukan model path analysis
model <- '
# Hubungan langsung ke skor_kognitif_terintegrasi (Y2)
Skor_Kognitif_Terstandarisasi ~ Pajanan_Teknologi_Pendidikan +
Indeks_Gizi_Seimbang +
Iklim_Belajar_Sekolah +
Indeks_Kematangan_Karakter
# Hubungan langsung ke indeks_kematangan_karakter (Y1)
Indeks_Kematangan_Karakter ~ Kualitas_Interaksi_OrangTua +
Iklim_Belajar_Sekolah +
Skor_Kognitif_Terstandarisasi
# Korelasi antar residual Y1 dan Y2
Indeks_Kematangan_Karakter ~~ Skor_Kognitif_Terstandarisasi
'
# 4. Estimasi model
fit <- sem(model, data = data_0, meanstructure = TRUE)
# 5. Tampilkan ringkasan hasil
summary(fit, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
## lavaan 0.6-19 ended normally after 38 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 35
##
## Model Test User Model:
##
## Test statistic 0.480
## Degrees of freedom 1
## P-value (Chi-square) 0.488
##
## Model Test Baseline Model:
##
## Test statistic 125.114
## Degrees of freedom 9
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.040
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -200.961
## Loglikelihood unrestricted model (H1) -200.721
##
## Akaike (AIC) 425.922
## Bayesian (BIC) 444.586
## Sample-size adjusted Bayesian (SABIC) 407.116
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.393
## P-value H_0: RMSEA <= 0.050 0.507
## P-value H_0: RMSEA >= 0.080 0.465
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.013
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv
## Skor_Kognitif_Terstandarisasi ~
## Pjnn_Tknlg_Pnd 2.478 0.272 9.111 0.000 2.478
## Indks_Gz_Smbng 2.200 0.302 7.288 0.000 2.200
## Iklm_Bljr_Sklh 2.292 0.539 4.250 0.000 2.292
## Indks_Kmtngn_K 0.131 0.128 1.026 0.305 0.131
## Indeks_Kematangan_Karakter ~
## Klts_Intrks_OT 2.321 0.373 6.219 0.000 2.321
## Iklm_Bljr_Sklh 2.264 0.499 4.541 0.000 2.264
## Skr_Kgntf_Trst 0.200 0.098 2.037 0.042 0.200
## Std.all
##
## 0.597
## 0.431
## 0.404
## 0.121
##
## 0.542
## 0.434
## 0.218
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv
## .Skor_Kognitif_Terstandarisasi ~~
## .Indks_Kmtngn_K 11.260 5.736 1.963 0.050 11.260
## Std.all
##
## 0.535
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Skr_Kgntf_Trst 23.091 7.048 3.276 0.001 23.091 2.127
## .Indks_Kmtngn_K 31.058 6.595 4.709 0.000 31.058 3.116
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Skr_Kgntf_Trst 17.226 5.650 3.049 0.002 17.226 0.146
## .Indks_Kmtngn_K 25.682 6.811 3.771 0.000 25.682 0.258
##
## R-Square:
## Estimate
## Skr_Kgntf_Trst 0.854
## Indks_Kmtngn_K 0.742
#asumsi
library(lmtest)
## Warning: package 'lmtest' was built under R version 4.3.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.3.1
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
model_kognitif <- lm(Skor_Kognitif_Terstandarisasi ~ Pajanan_Teknologi_Pendidikan +
Indeks_Gizi_Seimbang + Iklim_Belajar_Sekolah +
Indeks_Kematangan_Karakter, data = data_0)
model_karakter <- lm(Indeks_Kematangan_Karakter ~ Kualitas_Interaksi_OrangTua +
Iklim_Belajar_Sekolah + Skor_Kognitif_Terstandarisasi, data = data_0)
model_y1_y2 <- lm(Skor_Kognitif_Terstandarisasi~Indeks_Kematangan_Karakter, data=data_0)
resettest(model_kognitif)
##
## RESET test
##
## data: model_kognitif
## RESET = 1.1278, df1 = 2, df2 = 28, p-value = 0.338
resettest(model_karakter)
##
## RESET test
##
## data: model_karakter
## RESET = 0.71947, df1 = 2, df2 = 29, p-value = 0.4955
resettest(model_y1_y2)
##
## RESET test
##
## data: model_y1_y2
## RESET = 1.0802, df1 = 2, df2 = 31, p-value = 0.352
#p-value > 0.05 → Tidak ada pelanggaran linearitas (✅ aman)
r2_1_0 <- 0.881 # R² Y1
r2_2_0 <- 0.754 # R² Y2
rho_e1 <- 1 - r2_1_0
rho_e2 <- 1 - r2_2_0
r2_total_sem <- 1 - (rho_e1 * rho_e2)
r2_total_sem * 100 # dalam persen
## [1] 97.0726
# 2. Import data dari sheet bernama "0"
data_1 <- read_excel("C:/Users/fedh/Downloads/Data soal_Olimstat SMATIC 6.0.xlsx", sheet = "1")
# 3. Tentukan model path analysis
model <- '
# Hubungan langsung ke skor_kognitif_terintegrasi (Y2)
Skor_Kognitif_Terstandarisasi ~ Pajanan_Teknologi_Pendidikan +
Indeks_Gizi_Seimbang +
Iklim_Belajar_Sekolah +
Indeks_Kematangan_Karakter
# Hubungan langsung ke indeks_kematangan_karakter (Y1)
Indeks_Kematangan_Karakter ~ Kualitas_Interaksi_OrangTua +
Iklim_Belajar_Sekolah +
Skor_Kognitif_Terstandarisasi
# Korelasi antar residual Y1 dan Y2
Indeks_Kematangan_Karakter ~~ Skor_Kognitif_Terstandarisasi
'
# 4. Estimasi model
fit <- sem(model, data = data_1, meanstructure = TRUE)
# 5. Tampilkan ringkasan hasil
summary(fit, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
## lavaan 0.6-19 ended normally after 46 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 12
##
## Number of observations 65
##
## Model Test User Model:
##
## Test statistic 10.493
## Degrees of freedom 1
## P-value (Chi-square) 0.001
##
## Model Test Baseline Model:
##
## Test statistic 153.823
## Degrees of freedom 9
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.934
## Tucker-Lewis Index (TLI) 0.410
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -400.595
## Loglikelihood unrestricted model (H1) -395.349
##
## Akaike (AIC) 825.191
## Bayesian (BIC) 851.283
## Sample-size adjusted Bayesian (SABIC) 813.510
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.382
## 90 Percent confidence interval - lower 0.198
## 90 Percent confidence interval - upper 0.606
## P-value H_0: RMSEA <= 0.050 0.002
## P-value H_0: RMSEA >= 0.080 0.995
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.060
##
## Parameter Estimates:
##
## Standard errors Standard
## Information Expected
## Information saturated (h1) model Structured
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv
## Skor_Kognitif_Terstandarisasi ~
## Pjnn_Tknlg_Pnd 2.005 0.273 7.355 0.000 2.005
## Indks_Gz_Smbng 1.442 0.288 5.014 0.000 1.442
## Iklm_Bljr_Sklh 1.110 0.481 2.309 0.021 1.110
## Indks_Kmtngn_K 0.143 0.163 0.878 0.380 0.143
## Indeks_Kematangan_Karakter ~
## Klts_Intrks_OT 1.557 0.303 5.148 0.000 1.557
## Iklm_Bljr_Sklh 1.462 0.420 3.484 0.000 1.462
## Skr_Kgntf_Trst 0.379 0.116 3.268 0.001 0.379
## Std.all
##
## 0.601
## 0.340
## 0.237
## 0.150
##
## 0.389
## 0.298
## 0.361
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv
## .Skor_Kognitif_Terstandarisasi ~~
## .Indks_Kmtngn_K 10.264 7.923 1.295 0.195 10.264
## Std.all
##
## 0.364
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Skr_Kgntf_Trst 34.473 9.610 3.587 0.000 34.473 3.861
## .Indks_Kmtngn_K 31.186 7.761 4.018 0.000 31.186 3.325
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .Skr_Kgntf_Trst 24.784 8.039 3.083 0.002 24.784 0.311
## .Indks_Kmtngn_K 32.153 6.714 4.789 0.000 32.153 0.366
##
## R-Square:
## Estimate
## Skr_Kgntf_Trst 0.689
## Indks_Kmtngn_K 0.634
#asumsi
library(lmtest)
model_kognitif <- lm(Skor_Kognitif_Terstandarisasi ~ Pajanan_Teknologi_Pendidikan +
Indeks_Gizi_Seimbang + Iklim_Belajar_Sekolah +
Indeks_Kematangan_Karakter, data = data_1)
model_karakter <- lm(Indeks_Kematangan_Karakter ~ Kualitas_Interaksi_OrangTua +
Iklim_Belajar_Sekolah + Skor_Kognitif_Terstandarisasi, data = data_1)
model_y1_y2 <- lm(Skor_Kognitif_Terstandarisasi~Indeks_Kematangan_Karakter, data=data_1)
resettest(model_kognitif)
##
## RESET test
##
## data: model_kognitif
## RESET = 0.10561, df1 = 2, df2 = 58, p-value = 0.8999
resettest(model_karakter)
##
## RESET test
##
## data: model_karakter
## RESET = 0.84482, df1 = 2, df2 = 59, p-value = 0.4348
resettest(model_y1_y2)
##
## RESET test
##
## data: model_y1_y2
## RESET = 0.0059996, df1 = 2, df2 = 61, p-value = 0.994
#p-value > 0.05 → Tidak ada pelanggaran linearitas (✅ aman)
r2_1_0 <- 0.763 # R² Y1
r2_2_0 <- 0.653 # R² Y2
rho_e1 <- 1 - r2_1_0
rho_e2 <- 1 - r2_2_0
r2_total_sem <- 1 - (rho_e1 * rho_e2)
r2_total_sem * 100 # dalam persen
## [1] 91.7761