# 1. LOAD PACKAGE
library(lavaan)
library(semPlot)
library(psych)
library(dplyr)
library(car)
library(corrplot)
library(MVN)


# 2. MEMBACA DATASET
data <- read.csv("student.csv")


# 3. CEK STRUKTUR DATA
str(data)
## 'data.frame':    149 obs. of  13 variables:
##  $ Timestamp                                                 : chr  "13/08/2022 21:04:40" "13/08/2022 21:05:48" "13/08/2022 21:13:20" "13/08/2022 21:14:14" ...
##  $ Age                                                       : int  23 22 23 18 19 20 18 22 22 26 ...
##  $ gender                                                    : chr  "Male" "Male" "Male" "Male" ...
##  $ Level.of.Education                                        : chr  "Under Graduation" "Under Graduation" "Under Graduation" "HSC" ...
##  $ Are.you.Playing.Online.Games.                             : chr  "Sometimes" "Yes" "Yes" "Sometimes" ...
##  $ How.much.time.spend.in.gaming.                            : chr  "Below 1 hour" "1-2" "1-2" "1-2" ...
##  $ When.do.you.play.the.game.most.of.the.time.during.the.day.: chr  "Mid-Night" "Mid-Night" "Mid-Night" "Evening" ...
##  $ Do.you.feel.Hamper.in.sleep.                              : chr  "Sometimes" "Sometimes" "No" "No" ...
##  $ Do..you.feel.the.Headache.                                : chr  "Sometimes" "Yes" "No" "Sometimes" ...
##  $ Do.you.feel.mental.Stress.                                : chr  "Yes" "No" "No" "Yes" ...
##  $ Do.you.feel.Depression.                                   : chr  "Yes" "Yes" "No" "Yes" ...
##  $ Your.reading.attention.level.after.the.gaming.            : chr  "Good" "Good" "Good" "Average" ...
##  $ Your.Present.Academic.Result.                             : chr  "Good" "Good" "Good" "Average" ...
head(data)
##             Timestamp Age gender Level.of.Education
## 1 13/08/2022 21:04:40  23   Male   Under Graduation
## 2 13/08/2022 21:05:48  22   Male   Under Graduation
## 3 13/08/2022 21:13:20  23   Male   Under Graduation
## 4 13/08/2022 21:14:14  18   Male                HSC
## 5 13/08/2022 21:14:39  19   Male   Under Graduation
## 6 13/08/2022 21:15:38  20   Male   Under Graduation
##   Are.you.Playing.Online.Games. How.much.time.spend.in.gaming.
## 1                     Sometimes                   Below 1 hour
## 2                           Yes                            1-2
## 3                           Yes                            1-2
## 4                     Sometimes                            1-2
## 5                           Yes                            1-2
## 6                            No                   Below 1 hour
##   When.do.you.play.the.game.most.of.the.time.during.the.day.
## 1                                                  Mid-Night
## 2                                                  Mid-Night
## 3                                                  Mid-Night
## 4                                                    Evening
## 5                                                  Mid-Night
## 6                                                  Afternoon
##   Do.you.feel.Hamper.in.sleep. Do..you.feel.the.Headache.
## 1                    Sometimes                  Sometimes
## 2                    Sometimes                        Yes
## 3                           No                         No
## 4                           No                  Sometimes
## 5                    Sometimes                  Sometimes
## 6                           No                         No
##   Do.you.feel.mental.Stress. Do.you.feel.Depression.
## 1                        Yes                     Yes
## 2                         No                     Yes
## 3                         No                      No
## 4                        Yes                     Yes
## 5                         No               Sometimes
## 6                         No                      No
##   Your.reading.attention.level.after.the.gaming. Your.Present.Academic.Result.
## 1                                           Good                          Good
## 2                                           Good                          Good
## 3                                           Good                          Good
## 4                                        Average                       Average
## 5                                        Average                          Good
## 6                                           Good                       Average
dim(data)
## [1] 149  13
# 4. CEK MISSING VALUE
colSums(is.na(data))
##                                                  Timestamp 
##                                                          0 
##                                                        Age 
##                                                          0 
##                                                     gender 
##                                                          0 
##                                         Level.of.Education 
##                                                          0 
##                              Are.you.Playing.Online.Games. 
##                                                          0 
##                             How.much.time.spend.in.gaming. 
##                                                          0 
## When.do.you.play.the.game.most.of.the.time.during.the.day. 
##                                                          0 
##                               Do.you.feel.Hamper.in.sleep. 
##                                                          0 
##                                 Do..you.feel.the.Headache. 
##                                                          0 
##                                 Do.you.feel.mental.Stress. 
##                                                          0 
##                                    Do.you.feel.Depression. 
##                                                          0 
##             Your.reading.attention.level.after.the.gaming. 
##                                                          0 
##                              Your.Present.Academic.Result. 
##                                                          0
# 5. RENAME NAMA KOLOM
names(data) <- c(
  "timestamp",
  "age",
  "gender",
  "education",
  "play_games",
  "gaming_time",
  "gaming_period",
  "sleep_problem",
  "headache",
  "mental_stress",
  "depression",
  "reading_attention",
  "academic_result"
)


# 6. MEMILIH VARIABEL
data_sem <- data %>%
  select(
    gaming_time,
    sleep_problem,
    headache,
    mental_stress,
    depression,
    reading_attention,
    academic_result
  )


# 7. ENCODING DATA ORDINAL
encode_factor <- function(x) {
  as.numeric(as.factor(x))
}

data_sem <- data_sem %>%
  mutate(across(everything(), encode_factor))


# 8. RINGKASAN DATA
summary(data_sem)
##   gaming_time    sleep_problem      headache     mental_stress  
##  Min.   :1.000   Min.   :1.000   Min.   :1.000   Min.   :1.000  
##  1st Qu.:1.000   1st Qu.:1.000   1st Qu.:1.000   1st Qu.:1.000  
##  Median :3.000   Median :1.000   Median :2.000   Median :2.000  
##  Mean   :2.631   Mean   :1.591   Mean   :1.819   Mean   :1.846  
##  3rd Qu.:4.000   3rd Qu.:2.000   3rd Qu.:3.000   3rd Qu.:3.000  
##  Max.   :4.000   Max.   :3.000   Max.   :3.000   Max.   :3.000  
##    depression    reading_attention academic_result
##  Min.   :1.000   Min.   :1.000     Min.   :1.00   
##  1st Qu.:1.000   1st Qu.:1.000     1st Qu.:1.00   
##  Median :2.000   Median :2.000     Median :4.00   
##  Mean   :1.832   Mean   :2.383     Mean   :2.98   
##  3rd Qu.:3.000   3rd Qu.:4.000     3rd Qu.:4.00   
##  Max.   :3.000   Max.   :4.000     Max.   :4.00
# 9. STANDARISASI DATA
data_sem_scaled <- as.data.frame(scale(data_sem))

summary(data_sem_scaled)
##   gaming_time      sleep_problem        headache       mental_stress    
##  Min.   :-1.1842   Min.   :-0.7838   Min.   :-0.9858   Min.   :-1.0214  
##  1st Qu.:-1.1842   1st Qu.:-0.7838   1st Qu.:-0.9858   1st Qu.:-1.0214  
##  Median : 0.2680   Median :-0.7838   Median : 0.2182   Median : 0.1864  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.9942   3rd Qu.: 0.5433   3rd Qu.: 1.4221   3rd Qu.: 1.3943  
##  Max.   : 0.9942   Max.   : 1.8705   Max.   : 1.4221   Max.   : 1.3943  
##    depression      reading_attention academic_result  
##  Min.   :-1.0084   Min.   :-1.0290   Min.   :-1.5145  
##  1st Qu.:-1.0084   1st Qu.:-1.0290   1st Qu.:-1.5145  
##  Median : 0.2033   Median :-0.2847   Median : 0.7803  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 1.4150   3rd Qu.: 1.2038   3rd Qu.: 0.7803  
##  Max.   : 1.4150   Max.   : 1.2038   Max.   : 0.7803
# 10. UJI KMO / MSA
kmo_result <- KMO(data_sem_scaled)

kmo_result
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = data_sem_scaled)
## Overall MSA =  0.66
## MSA for each item = 
##       gaming_time     sleep_problem          headache     mental_stress 
##              0.62              0.67              0.71              0.66 
##        depression reading_attention   academic_result 
##              0.64              0.51              0.57
# 11. UJI MULTIKOLINEARITAS
model_vif <- lm(
  academic_result ~
    gaming_time +
    sleep_problem +
    headache +
    mental_stress +
    depression +
    reading_attention,
  data = data_sem_scaled
)

vif_result <- vif(model_vif)

vif_result
##       gaming_time     sleep_problem          headache     mental_stress 
##          1.073511          1.418851          1.609433          1.866483 
##        depression reading_attention 
##          1.687467          1.023811
# 12. UJI NORMALITAS MULTIVARIAT
mvn_result <- MVN::mvn(data_sem_scaled)

mvn_result
## $multivariate_normality
##            Test Statistic p.value     Method          MVN
## 1 Henze-Zirkler     2.242  <0.001 asymptotic ✗ Not normal
## 
## $univariate_normality
##               Test          Variable Statistic p.value    Normality
## 1 Anderson-Darling       gaming_time    17.752  <0.001 ✗ Not normal
## 2 Anderson-Darling     sleep_problem    18.228  <0.001 ✗ Not normal
## 3 Anderson-Darling          headache    14.078  <0.001 ✗ Not normal
## 4 Anderson-Darling     mental_stress    13.501  <0.001 ✗ Not normal
## 5 Anderson-Darling        depression    13.622  <0.001 ✗ Not normal
## 6 Anderson-Darling reading_attention    15.491  <0.001 ✗ Not normal
## 7 Anderson-Darling   academic_result    21.205  <0.001 ✗ Not normal
## 
## $descriptives
##            Variable   n Mean Std.Dev Median    Min   Max   25th  75th   Skew
## 1       gaming_time 149    0       1  0.268 -1.184 0.994 -1.184 0.994 -0.142
## 2     sleep_problem 149    0       1 -0.784 -0.784 1.870 -0.784 0.543  0.831
## 3          headache 149    0       1  0.218 -0.986 1.422 -0.986 1.422  0.348
## 4     mental_stress 149    0       1  0.186 -1.021 1.394 -1.021 1.394  0.293
## 5        depression 149    0       1  0.203 -1.008 1.415 -1.008 1.415  0.319
## 6 reading_attention 149    0       1 -0.285 -1.029 1.204 -1.029 1.204  0.134
## 7   academic_result 149    0       1  0.780 -1.514 0.780 -1.514 0.780 -0.727
##   Kurtosis
## 1    1.180
## 2    2.240
## 3    1.544
## 4    1.528
## 5    1.548
## 6    1.231
## 7    1.717
## 
## $data
##     gaming_time sleep_problem   headache mental_stress depression
## 1     0.9941573     0.5433321  0.2181623     1.3942727  1.4149856
## 2    -1.1842168     0.5433321  1.4220952    -1.0213858  1.4149856
## 3    -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 4    -1.1842168    -0.7838234  0.2181623     1.3942727  1.4149856
## 5    -1.1842168     0.5433321  0.2181623    -1.0213858  0.2033025
## 6     0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 7    -1.1842168     0.5433321 -0.9857706     0.1864434  0.2033025
## 8     0.9941573     1.8704877  1.4220952     0.1864434  0.2033025
## 9    -0.4580921    -0.7838234 -0.9857706    -1.0213858  1.4149856
## 10    0.2680326    -0.7838234  1.4220952     0.1864434  0.2033025
## 11    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 12   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 13    0.9941573     1.8704877  1.4220952     0.1864434 -1.0083805
## 14   -1.1842168     1.8704877  1.4220952     0.1864434  0.2033025
## 15   -1.1842168     0.5433321  0.2181623     1.3942727  0.2033025
## 16    0.9941573     0.5433321 -0.9857706    -1.0213858  1.4149856
## 17    0.9941573    -0.7838234 -0.9857706     1.3942727  1.4149856
## 18    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 19    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 20    0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 21    0.9941573    -0.7838234 -0.9857706     1.3942727 -1.0083805
## 22    0.9941573    -0.7838234 -0.9857706     1.3942727  1.4149856
## 23    0.9941573     1.8704877 -0.9857706     1.3942727  1.4149856
## 24   -1.1842168     0.5433321 -0.9857706     0.1864434 -1.0083805
## 25    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 26    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 27   -0.4580921     0.5433321  0.2181623     1.3942727  1.4149856
## 28   -1.1842168     1.8704877  0.2181623     1.3942727  1.4149856
## 29   -1.1842168     0.5433321  0.2181623     0.1864434  0.2033025
## 30    0.9941573    -0.7838234  0.2181623     1.3942727  1.4149856
## 31    0.9941573    -0.7838234 -0.9857706     0.1864434 -1.0083805
## 32    0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 33   -1.1842168     0.5433321 -0.9857706     0.1864434 -1.0083805
## 34    0.2680326    -0.7838234 -0.9857706     0.1864434  0.2033025
## 35   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 36    0.9941573    -0.7838234  0.2181623    -1.0213858  1.4149856
## 37   -0.4580921    -0.7838234 -0.9857706     0.1864434  0.2033025
## 38    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 39    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 40   -0.4580921     1.8704877  1.4220952     1.3942727  1.4149856
## 41   -0.4580921     1.8704877  1.4220952    -1.0213858  1.4149856
## 42    0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 43   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 44    0.9941573     0.5433321  1.4220952     1.3942727  1.4149856
## 45   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 46    0.9941573    -0.7838234 -0.9857706     1.3942727  1.4149856
## 47   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 48   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 49    0.9941573     0.5433321  0.2181623     0.1864434 -1.0083805
## 50   -1.1842168    -0.7838234  1.4220952     1.3942727  1.4149856
## 51    0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 52    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 53    0.9941573     1.8704877  0.2181623     0.1864434 -1.0083805
## 54    0.9941573    -0.7838234 -0.9857706     0.1864434  0.2033025
## 55    0.9941573    -0.7838234  0.2181623    -1.0213858 -1.0083805
## 56    0.9941573     1.8704877  1.4220952     1.3942727 -1.0083805
## 57    0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 58    0.2680326    -0.7838234 -0.9857706     0.1864434  0.2033025
## 59   -1.1842168     0.5433321  0.2181623     0.1864434  0.2033025
## 60   -0.4580921    -0.7838234 -0.9857706    -1.0213858  1.4149856
## 61    0.9941573     1.8704877  0.2181623     1.3942727  1.4149856
## 62   -0.4580921     0.5433321 -0.9857706    -1.0213858 -1.0083805
## 63    0.9941573     0.5433321  1.4220952    -1.0213858  0.2033025
## 64   -0.4580921    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 65   -1.1842168    -0.7838234  0.2181623    -1.0213858  0.2033025
## 66   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 67   -1.1842168     0.5433321 -0.9857706    -1.0213858 -1.0083805
## 68   -1.1842168     0.5433321  0.2181623     0.1864434  0.2033025
## 69   -1.1842168    -0.7838234 -0.9857706     0.1864434  0.2033025
## 70   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 71   -0.4580921    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 72    0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 73   -1.1842168    -0.7838234  1.4220952     1.3942727  1.4149856
## 74    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 75   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 76   -1.1842168     0.5433321  0.2181623     0.1864434  1.4149856
## 77    0.2680326    -0.7838234 -0.9857706    -1.0213858  0.2033025
## 78   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 79   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 80   -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 81    0.9941573     0.5433321  1.4220952     1.3942727  1.4149856
## 82    0.2680326     1.8704877  1.4220952     0.1864434  0.2033025
## 83    0.9941573     1.8704877  1.4220952    -1.0213858 -1.0083805
## 84    0.9941573    -0.7838234  1.4220952     0.1864434  0.2033025
## 85    0.9941573     0.5433321  1.4220952     0.1864434  0.2033025
## 86    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 87   -1.1842168    -0.7838234  1.4220952    -1.0213858 -1.0083805
## 88   -0.4580921     0.5433321  0.2181623     0.1864434  0.2033025
## 89   -0.4580921     0.5433321  0.2181623     0.1864434  0.2033025
## 90    0.2680326     0.5433321  0.2181623     0.1864434  0.2033025
## 91    0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 92    0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 93   -1.1842168     0.5433321  0.2181623     0.1864434 -1.0083805
## 94    0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 95    0.9941573    -0.7838234  1.4220952     1.3942727  1.4149856
## 96    0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 97   -0.4580921     1.8704877  1.4220952     1.3942727  1.4149856
## 98    0.9941573    -0.7838234  0.2181623     0.1864434 -1.0083805
## 99    0.9941573     1.8704877 -0.9857706    -1.0213858 -1.0083805
## 100  -0.4580921    -0.7838234  0.2181623    -1.0213858 -1.0083805
## 101  -0.4580921    -0.7838234  0.2181623    -1.0213858 -1.0083805
## 102   0.9941573     0.5433321  1.4220952    -1.0213858  0.2033025
## 103  -1.1842168    -0.7838234 -0.9857706     0.1864434  0.2033025
## 104   0.9941573     0.5433321  0.2181623     0.1864434 -1.0083805
## 105   0.9941573    -0.7838234 -0.9857706     1.3942727  1.4149856
## 106  -1.1842168    -0.7838234 -0.9857706     1.3942727  1.4149856
## 107  -0.4580921     0.5433321  0.2181623     0.1864434  0.2033025
## 108   0.2680326    -0.7838234 -0.9857706     0.1864434 -1.0083805
## 109  -0.4580921    -0.7838234  0.2181623    -1.0213858 -1.0083805
## 110   0.9941573    -0.7838234  0.2181623     0.1864434  0.2033025
## 111  -1.1842168    -0.7838234  0.2181623     1.3942727  0.2033025
## 112   0.9941573    -0.7838234  1.4220952    -1.0213858 -1.0083805
## 113  -1.1842168    -0.7838234 -0.9857706    -1.0213858  0.2033025
## 114   0.9941573    -0.7838234  0.2181623    -1.0213858 -1.0083805
## 115   0.9941573    -0.7838234  1.4220952    -1.0213858 -1.0083805
## 116   0.9941573    -0.7838234  0.2181623     0.1864434  0.2033025
## 117  -1.1842168    -0.7838234 -0.9857706     0.1864434 -1.0083805
## 118   0.9941573     0.5433321  1.4220952     1.3942727  1.4149856
## 119  -0.4580921    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 120   0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 121  -1.1842168    -0.7838234 -0.9857706    -1.0213858  1.4149856
## 122  -1.1842168    -0.7838234 -0.9857706     1.3942727 -1.0083805
## 123  -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 124  -1.1842168    -0.7838234  0.2181623     1.3942727  1.4149856
## 125   0.9941573     1.8704877  1.4220952     1.3942727  1.4149856
## 126   0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 127   0.9941573     0.5433321  1.4220952     1.3942727  0.2033025
## 128   0.9941573    -0.7838234  1.4220952     1.3942727  1.4149856
## 129  -1.1842168     1.8704877  1.4220952     1.3942727 -1.0083805
## 130  -0.4580921    -0.7838234  1.4220952     1.3942727  1.4149856
## 131   0.9941573    -0.7838234  1.4220952     1.3942727  1.4149856
## 132   0.9941573    -0.7838234  1.4220952     0.1864434  0.2033025
## 133   0.9941573     0.5433321  1.4220952     1.3942727  0.2033025
## 134  -1.1842168     1.8704877 -0.9857706    -1.0213858 -1.0083805
## 135  -1.1842168     0.5433321  0.2181623     1.3942727  1.4149856
## 136  -1.1842168    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 137  -0.4580921     1.8704877  0.2181623     1.3942727 -1.0083805
## 138   0.9941573     0.5433321  0.2181623     0.1864434  0.2033025
## 139  -1.1842168     0.5433321  0.2181623     0.1864434  0.2033025
## 140   0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 141  -1.1842168    -0.7838234 -0.9857706     0.1864434  0.2033025
## 142  -1.1842168     0.5433321  0.2181623    -1.0213858 -1.0083805
## 143  -1.1842168     0.5433321  1.4220952     1.3942727  0.2033025
## 144   0.9941573    -0.7838234 -0.9857706    -1.0213858 -1.0083805
## 145   0.9941573    -0.7838234  1.4220952    -1.0213858 -1.0083805
## 146  -1.1842168     1.8704877  1.4220952    -1.0213858 -1.0083805
## 147  -1.1842168    -0.7838234 -0.9857706    -1.0213858  1.4149856
## 148   0.9941573    -0.7838234 -0.9857706     0.1864434  0.2033025
## 149  -1.1842168    -0.7838234 -0.9857706    -1.0213858  0.2033025
##     reading_attention academic_result
## 1           1.2037818       0.7803326
## 2           1.2037818       0.7803326
## 3           1.2037818       0.7803326
## 4          -1.0289587      -1.5144613
## 5          -1.0289587       0.7803326
## 6           1.2037818      -1.5144613
## 7          -1.0289587       0.7803326
## 8          -1.0289587       0.7803326
## 9           0.4595350      -1.5144613
## 10         -0.2847119      -1.5144613
## 11          0.4595350       0.7803326
## 12         -1.0289587       0.7803326
## 13         -0.2847119      -0.7495300
## 14         -0.2847119      -1.5144613
## 15          1.2037818       0.0154013
## 16         -1.0289587       0.7803326
## 17          0.4595350      -1.5144613
## 18          1.2037818       0.7803326
## 19          0.4595350       0.7803326
## 20          0.4595350       0.0154013
## 21         -1.0289587      -1.5144613
## 22          1.2037818       0.7803326
## 23         -1.0289587      -1.5144613
## 24         -1.0289587       0.7803326
## 25          1.2037818       0.7803326
## 26          1.2037818       0.7803326
## 27          1.2037818      -1.5144613
## 28         -0.2847119      -1.5144613
## 29          1.2037818      -1.5144613
## 30          0.4595350       0.7803326
## 31         -1.0289587       0.0154013
## 32         -0.2847119      -1.5144613
## 33         -0.2847119       0.7803326
## 34         -1.0289587       0.7803326
## 35          1.2037818       0.7803326
## 36          1.2037818       0.7803326
## 37          0.4595350      -1.5144613
## 38          1.2037818       0.7803326
## 39          1.2037818       0.7803326
## 40         -0.2847119      -1.5144613
## 41         -1.0289587       0.7803326
## 42          0.4595350       0.0154013
## 43         -1.0289587       0.7803326
## 44         -1.0289587      -1.5144613
## 45         -1.0289587      -1.5144613
## 46         -1.0289587       0.7803326
## 47         -1.0289587      -1.5144613
## 48          1.2037818       0.0154013
## 49         -1.0289587       0.7803326
## 50         -1.0289587       0.7803326
## 51         -1.0289587       0.7803326
## 52         -1.0289587      -0.7495300
## 53          1.2037818       0.7803326
## 54         -1.0289587       0.7803326
## 55         -1.0289587      -1.5144613
## 56         -1.0289587      -1.5144613
## 57         -1.0289587       0.7803326
## 58         -1.0289587       0.7803326
## 59         -1.0289587      -1.5144613
## 60          0.4595350       0.0154013
## 61          0.4595350      -1.5144613
## 62          1.2037818       0.7803326
## 63          0.4595350      -1.5144613
## 64          1.2037818       0.0154013
## 65         -1.0289587       0.7803326
## 66          1.2037818       0.7803326
## 67         -1.0289587       0.0154013
## 68          1.2037818       0.7803326
## 69         -1.0289587      -1.5144613
## 70         -1.0289587       0.7803326
## 71         -1.0289587      -1.5144613
## 72         -1.0289587       0.7803326
## 73         -1.0289587       0.0154013
## 74          1.2037818       0.7803326
## 75         -1.0289587      -1.5144613
## 76         -1.0289587      -1.5144613
## 77         -0.2847119      -1.5144613
## 78          1.2037818       0.7803326
## 79         -1.0289587      -1.5144613
## 80         -1.0289587       0.7803326
## 81          1.2037818       0.7803326
## 82         -0.2847119       0.7803326
## 83          1.2037818       0.7803326
## 84         -1.0289587      -1.5144613
## 85         -0.2847119       0.7803326
## 86         -1.0289587      -1.5144613
## 87         -1.0289587       0.0154013
## 88          1.2037818       0.7803326
## 89          1.2037818       0.7803326
## 90          0.4595350       0.7803326
## 91          0.4595350       0.0154013
## 92         -1.0289587       0.7803326
## 93          1.2037818       0.0154013
## 94         -1.0289587      -1.5144613
## 95          1.2037818       0.7803326
## 96         -0.2847119       0.7803326
## 97         -1.0289587       0.7803326
## 98         -1.0289587       0.7803326
## 99          1.2037818       0.7803326
## 100        -1.0289587       0.7803326
## 101         0.4595350      -1.5144613
## 102         1.2037818       0.7803326
## 103         1.2037818       0.7803326
## 104        -1.0289587      -1.5144613
## 105        -1.0289587       0.7803326
## 106         0.4595350       0.7803326
## 107         1.2037818      -1.5144613
## 108         1.2037818       0.0154013
## 109        -1.0289587      -1.5144613
## 110         1.2037818      -1.5144613
## 111         0.4595350      -1.5144613
## 112        -1.0289587       0.7803326
## 113         1.2037818      -1.5144613
## 114         1.2037818       0.0154013
## 115         1.2037818       0.7803326
## 116         0.4595350       0.0154013
## 117        -1.0289587       0.7803326
## 118         1.2037818       0.7803326
## 119         1.2037818       0.7803326
## 120         1.2037818       0.7803326
## 121        -1.0289587       0.7803326
## 122         0.4595350       0.0154013
## 123        -1.0289587       0.0154013
## 124        -1.0289587       0.0154013
## 125         1.2037818       0.0154013
## 126        -1.0289587       0.7803326
## 127        -0.2847119       0.7803326
## 128        -1.0289587       0.7803326
## 129        -1.0289587       0.7803326
## 130         1.2037818       0.0154013
## 131         1.2037818       0.7803326
## 132        -1.0289587      -1.5144613
## 133        -1.0289587       0.7803326
## 134         1.2037818       0.7803326
## 135        -1.0289587       0.7803326
## 136        -1.0289587       0.7803326
## 137         0.4595350      -1.5144613
## 138        -1.0289587       0.7803326
## 139        -1.0289587       0.7803326
## 140         0.4595350       0.0154013
## 141        -1.0289587       0.0154013
## 142         1.2037818       0.7803326
## 143         1.2037818       0.7803326
## 144         1.2037818       0.7803326
## 145         1.2037818       0.7803326
## 146        -0.2847119      -1.5144613
## 147         1.2037818       0.7803326
## 148         1.2037818       0.7803326
## 149        -1.0289587      -1.5144613
## 
## $subset
## NULL
## 
## $outlierMethod
## [1] "none"
## 
## attr(,"class")
## [1] "mvn"
# 13. STATISTIK DESKRIPTIF
describe(data_sem_scaled)
##                   vars   n mean sd median trimmed  mad   min  max range  skew
## gaming_time          1 149    0  1   0.27    0.02 1.08 -1.18 0.99  2.18 -0.14
## sleep_problem        2 149    0  1  -0.78   -0.13 0.00 -0.78 1.87  2.65  0.82
## headache             3 149    0  1   0.22   -0.05 1.78 -0.99 1.42  2.41  0.34
## mental_stress        4 149    0  1   0.19   -0.04 1.79 -1.02 1.39  2.42  0.29
## depression           5 149    0  1   0.20   -0.05 1.80 -1.01 1.41  2.42  0.32
## reading_attention    6 149    0  1  -0.28   -0.02 1.10 -1.03 1.20  2.23  0.13
## academic_result      7 149    0  1   0.78    0.08 0.00 -1.51 0.78  2.29 -0.72
##                   kurtosis   se
## gaming_time          -1.84 0.08
## sleep_problem        -0.79 0.08
## headache             -1.48 0.08
## mental_stress        -1.49 0.08
## depression           -1.47 0.08
## reading_attention    -1.79 0.08
## academic_result      -1.31 0.08
# 14. VISUALISASI KORELASI
cor_matrix <- cor(data_sem_scaled)

corrplot(
  cor_matrix,
  method = "color",
  type = "upper",
  addCoef.col = "black",
  tl.cex = 0.8,
  number.cex = 0.7
)

# 15. MODEL CB-SEM
model_cbsem <- '

# ==================================================
# MEASUREMENT MODEL
# ==================================================

Mental_Health =~ sleep_problem + headache + mental_stress + depression

Academic_Performance =~ reading_attention + academic_result

# ==================================================
# STRUCTURAL MODEL
# ==================================================

Mental_Health ~ a*gaming_time

Academic_Performance ~ b*Mental_Health + c*gaming_time

# ==================================================
# RESIDUAL COVARIANCE
# ==================================================

mental_stress ~~ depression

sleep_problem ~~ headache

# ==================================================
# INDIRECT EFFECT
# ==================================================

indirect_gaming := a*b

# ==================================================
# TOTAL EFFECT
# ==================================================

total_gaming := c + (a*b)

'

cat(model_cbsem)
## 
## 
## # ==================================================
## # MEASUREMENT MODEL
## # ==================================================
## 
## Mental_Health =~ sleep_problem + headache + mental_stress + depression
## 
## Academic_Performance =~ reading_attention + academic_result
## 
## # ==================================================
## # STRUCTURAL MODEL
## # ==================================================
## 
## Mental_Health ~ a*gaming_time
## 
## Academic_Performance ~ b*Mental_Health + c*gaming_time
## 
## # ==================================================
## # RESIDUAL COVARIANCE
## # ==================================================
## 
## mental_stress ~~ depression
## 
## sleep_problem ~~ headache
## 
## # ==================================================
## # INDIRECT EFFECT
## # ==================================================
## 
## indirect_gaming := a*b
## 
## # ==================================================
## # TOTAL EFFECT
## # ==================================================
## 
## total_gaming := c + (a*b)
# 16. ESTIMASI MODEL
fit_cbsem <- sem(
  model_cbsem,
  data = data_sem_scaled,
  estimator = "MLR",
  missing = "fiml"
)


# 17. RINGKASAN HASIL SEM
summary(
  fit_cbsem,
  fit.measures = TRUE,
  standardized = TRUE,
  rsquare = TRUE
)
## lavaan 0.6-21 ended normally after 41 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        23
## 
##   Number of observations                           149
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 4.966       5.382
##   Degrees of freedom                                10          10
##   P-value (Chi-square)                           0.893       0.864
##   Scaling correction factor                                  0.923
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                               179.275     155.679
##   Degrees of freedom                                21          21
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.152
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.067       1.072
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.063
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1178.367   -1178.367
##   Scaling correction factor                                  0.994
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)      -1175.884   -1175.884
##   Scaling correction factor                                  0.972
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                                2402.734    2402.734
##   Bayesian (BIC)                              2471.824    2471.824
##   Sample-size adjusted Bayesian (SABIC)       2399.036    2399.036
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.000
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.040       0.051
##   P-value H_0: RMSEA <= 0.050                    0.967       0.948
##   P-value H_0: RMSEA >= 0.080                    0.005       0.009
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.042
##   P-value H_0: Robust RMSEA <= 0.050                         0.965
##   P-value H_0: Robust RMSEA >= 0.080                         0.005
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.019       0.019
## 
## Parameter Estimates:
## 
##   Standard errors                             Sandwich
##   Information bread                           Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                           Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Mental_Health =~                                                             
##     sleep_problem            1.000                               0.548    0.550
##     headache                 1.363    0.355    3.842    0.000    0.747    0.750
##     mental_stress            1.100    0.567    1.939    0.053    0.603    0.605
##     depression               0.876    0.447    1.960    0.050    0.481    0.482
##   Academic_Performance =~                                                      
##     reading_attntn           1.000                               0.435    0.436
##     academic_reslt           0.952    0.852    1.117    0.264    0.414    0.416
## 
## Regressions:
##                          Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Mental_Health ~                                                             
##     gaming_tim (a)          0.139    0.063    2.198    0.028    0.254    0.253
##   Academic_Performance ~                                                      
##     Mentl_Hlth (b)         -0.160    0.198   -0.806    0.420   -0.202   -0.202
##     gaming_tim (c)          0.125    0.089    1.399    0.162    0.287    0.286
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .mental_stress ~~                                                      
##    .depression        0.330    0.159    2.072    0.038    0.330    0.477
##  .sleep_problem ~~                                                      
##    .headache          0.104    0.227    0.460    0.646    0.104    0.190
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .sleep_problem    -0.000    0.081   -0.000    1.000   -0.000   -0.000
##    .headache          0.000    0.080    0.000    1.000    0.000    0.000
##    .mental_stress    -0.000    0.081   -0.000    1.000   -0.000   -0.000
##    .depression        0.000    0.081    0.000    1.000    0.000    0.000
##    .reading_attntn   -0.000    0.081   -0.000    1.000   -0.000   -0.000
##    .academic_reslt   -0.000    0.081   -0.000    1.000   -0.000   -0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .sleep_problem     0.693    0.186    3.716    0.000    0.693    0.697
##    .headache          0.435    0.343    1.266    0.206    0.435    0.437
##    .mental_stress     0.630    0.214    2.944    0.003    0.630    0.634
##    .depression        0.762    0.130    5.863    0.000    0.762    0.768
##    .reading_attntn    0.804    0.186    4.323    0.000    0.804    0.810
##    .academic_reslt    0.822    0.169    4.850    0.000    0.822    0.827
##    .Mental_Health     0.281    0.166    1.693    0.090    0.936    0.936
##    .Acadmc_Prfrmnc    0.172    0.176    0.973    0.331    0.907    0.907
## 
## R-Square:
##                    Estimate
##     sleep_problem     0.303
##     headache          0.563
##     mental_stress     0.366
##     depression        0.232
##     reading_attntn    0.190
##     academic_reslt    0.173
##     Mental_Health     0.064
##     Acadmc_Prfrmnc    0.093
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     indirect_gamng   -0.022    0.026   -0.866    0.386   -0.051   -0.051
##     total_gaming      0.102    0.085    1.206    0.228    0.235    0.235
# 18. MODEL FIT
fitMeasures(
  fit_cbsem,
  c(
    "chisq",
    "df",
    "pvalue",
    "cfi",
    "tli",
    "rmsea",
    "srmr"
  )
)
##  chisq     df pvalue    cfi    tli  rmsea   srmr 
##  4.966 10.000  0.893  1.000  1.067  0.000  0.019
# 19. LOADING FACTOR
parameterEstimates(
  fit_cbsem,
  standardized = TRUE
) %>%
  filter(op == "=~") %>%
  select(
    lhs,
    rhs,
    est,
    se,
    z,
    pvalue,
    std.all
  )
##                    lhs               rhs   est    se     z pvalue std.all
## 1        Mental_Health     sleep_problem 1.000 0.000    NA     NA   0.550
## 2        Mental_Health          headache 1.363 0.355 3.842  0.000   0.750
## 3        Mental_Health     mental_stress 1.100 0.567 1.939  0.053   0.605
## 4        Mental_Health        depression 0.876 0.447 1.960  0.050   0.482
## 5 Academic_Performance reading_attention 1.000 0.000    NA     NA   0.436
## 6 Academic_Performance   academic_result 0.952 0.852 1.117  0.264   0.416
# 20. KOEFISIEN JALUR
parameterEstimates(
  fit_cbsem,
  standardized = TRUE
) %>%
  filter(op == "~") %>%
  select(
    lhs,
    rhs,
    est,
    se,
    z,
    pvalue,
    std.all
  )
##                    lhs           rhs    est    se      z pvalue std.all
## 1        Mental_Health   gaming_time  0.139 0.063  2.198  0.028   0.253
## 2 Academic_Performance Mental_Health -0.160 0.198 -0.806  0.420  -0.202
## 3 Academic_Performance   gaming_time  0.125 0.089  1.399  0.162   0.286
# 21. INDIRECT EFFECT
parameterEstimates(
  fit_cbsem,
  standardized = TRUE
) %>%
  filter(op == ":=") %>%
  select(
    lhs,
    est,
    se,
    z,
    pvalue,
    std.all
  )
##               lhs    est    se      z pvalue std.all
## 1 indirect_gaming -0.022 0.026 -0.866  0.386  -0.051
## 2    total_gaming  0.102 0.085  1.206  0.228   0.235
# 22. R-SQUARE
inspect(fit_cbsem, "r2")
##        sleep_problem             headache        mental_stress 
##                0.303                0.563                0.366 
##           depression    reading_attention      academic_result 
##                0.232                0.190                0.173 
##        Mental_Health Academic_Performance 
##                0.064                0.093
# 23. MODIFICATION INDICES
modindices(
  fit_cbsem,
  sort. = TRUE,
  maximum.number = 10
)
##                     lhs op               rhs    mi    epc sepc.lv sepc.all
## 42             headache ~~     mental_stress 3.079 -0.154  -0.154   -0.295
## 38        sleep_problem ~~     mental_stress 2.232  0.101   0.101    0.153
## 43             headache ~~        depression 1.907  0.102   0.102    0.176
## 39        sleep_problem ~~        depression 1.188 -0.062  -0.062   -0.085
## 36 Academic_Performance =~     mental_stress 0.799 -0.220  -0.096   -0.096
## 46        mental_stress ~~ reading_attention 0.740 -0.052  -0.052   -0.073
## 35 Academic_Performance =~          headache 0.613  0.233   0.101    0.102
## 47        mental_stress ~~   academic_result 0.335 -0.035  -0.035   -0.049
## 48           depression ~~ reading_attention 0.287  0.033   0.033    0.042
## 40        sleep_problem ~~ reading_attention 0.229  0.033   0.033    0.044
##    sepc.nox
## 42   -0.295
## 38    0.153
## 43    0.176
## 39   -0.085
## 36   -0.096
## 46   -0.073
## 35    0.102
## 47   -0.049
## 48    0.042
## 40    0.044
# 24. VISUALISASI SEM
semPaths(
  fit_cbsem,
  what = "std",
  whatLabels = "std",
  style = "ram",
  layout = "tree",
  rotation = 2,
  sizeLat = 8,
  sizeMan = 6,
  edge.label.cex = 0.8,
  label.cex = 0.9,
  residuals = FALSE,
  intercepts = FALSE
)

# 25. BOOTSTRAPPING
fit_boot <- sem(
  model_cbsem,
  data = data_sem_scaled,
  estimator = "ML",
  se = "bootstrap",
  bootstrap = 500,
  missing = "fiml"
)

summary(
  fit_boot,
  standardized = TRUE,
  fit.measures = TRUE,
  rsquare = TRUE
)
## lavaan 0.6-21 ended normally after 41 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        23
## 
##   Number of observations                           149
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 4.966
##   Degrees of freedom                                10
##   P-value (Chi-square)                           0.893
## 
## Model Test Baseline Model:
## 
##   Test statistic                               179.275
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.067
##                                                       
##   Robust Comparative Fit Index (CFI)             1.000
##   Robust Tucker-Lewis Index (TLI)                1.067
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -1178.367
##   Loglikelihood unrestricted model (H1)      -1175.884
##                                                       
##   Akaike (AIC)                                2402.734
##   Bayesian (BIC)                              2471.824
##   Sample-size adjusted Bayesian (SABIC)       2399.036
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.040
##   P-value H_0: RMSEA <= 0.050                    0.967
##   P-value H_0: RMSEA >= 0.080                    0.005
##                                                       
##   Robust RMSEA                                   0.000
##   90 Percent confidence interval - lower         0.000
##   90 Percent confidence interval - upper         0.040
##   P-value H_0: Robust RMSEA <= 0.050             0.967
##   P-value H_0: Robust RMSEA >= 0.080             0.005
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.019
## 
## Parameter Estimates:
## 
##   Standard errors                            Bootstrap
##   Number of requested bootstrap draws              500
##   Number of successful bootstrap draws             387
## 
## Latent Variables:
##                           Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Mental_Health =~                                                             
##     sleep_problem            1.000                               0.548    0.550
##     headache                 1.363    1.180    1.155    0.248    0.747    0.750
##     mental_stress            1.100    1.435    0.766    0.444    0.603    0.605
##     depression               0.876    1.277    0.686    0.493    0.481    0.482
##   Academic_Performance =~                                                      
##     reading_attntn           1.000                               0.435    0.436
##     academic_reslt           0.952    3.004    0.317    0.751    0.414    0.416
## 
## Regressions:
##                          Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Mental_Health ~                                                             
##     gaming_tim (a)          0.139    0.068    2.037    0.042    0.254    0.253
##   Academic_Performance ~                                                      
##     Mentl_Hlth (b)         -0.160    0.243   -0.658    0.511   -0.202   -0.202
##     gaming_tim (c)          0.125    0.081    1.539    0.124    0.287    0.286
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .mental_stress ~~                                                      
##    .depression        0.330    0.350    0.944    0.345    0.330    0.477
##  .sleep_problem ~~                                                      
##    .headache          0.104    0.563    0.185    0.853    0.104    0.190
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .sleep_problem    -0.000    0.084   -0.000    1.000   -0.000   -0.000
##    .headache          0.000    0.083    0.000    1.000    0.000    0.000
##    .mental_stress    -0.000    0.076   -0.000    1.000   -0.000   -0.000
##    .depression        0.000    0.077    0.000    1.000    0.000    0.000
##    .reading_attntn   -0.000    0.081   -0.000    1.000   -0.000   -0.000
##    .academic_reslt   -0.000    0.080   -0.000    1.000   -0.000   -0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .sleep_problem     0.693    0.417    1.662    0.097    0.693    0.697
##    .headache          0.435    0.890    0.488    0.625    0.435    0.437
##    .mental_stress     0.630    0.441    1.428    0.153    0.630    0.634
##    .depression        0.762    0.296    2.578    0.010    0.762    0.768
##    .reading_attntn    0.804    0.584    1.377    0.169    0.804    0.810
##    .academic_reslt    0.822    0.651    1.262    0.207    0.822    0.827
##    .Mental_Health     0.281    0.398    0.707    0.480    0.936    0.936
##    .Acadmc_Prfrmnc    0.172    0.579    0.296    0.767    0.907    0.907
## 
## R-Square:
##                    Estimate
##     sleep_problem     0.303
##     headache          0.563
##     mental_stress     0.366
##     depression        0.232
##     reading_attntn    0.190
##     academic_reslt    0.173
##     Mental_Health     0.064
##     Acadmc_Prfrmnc    0.093
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     indirect_gamng   -0.022    0.027   -0.817    0.414   -0.051   -0.051
##     total_gaming      0.102    0.077    1.326    0.185    0.235    0.235
# 26. BOOTSTRAP CONFIDENCE INTERVAL
parameterEstimates(
  fit_boot,
  standardized = TRUE,
  boot.ci.type = "bca.simple"
) %>%
  filter(op %in% c("~", ":=", "=~")) %>%
  select(
    lhs,
    op,
    rhs,
    est,
    ci.lower,
    ci.upper,
    pvalue,
    std.all
  )
##                     lhs op               rhs    est ci.lower ci.upper pvalue
## 1         Mental_Health =~     sleep_problem  1.000    1.000    1.000     NA
## 2         Mental_Health =~          headache  1.363    0.852    2.842  0.248
## 3         Mental_Health =~     mental_stress  1.100    0.129    3.282  0.444
## 4         Mental_Health =~        depression  0.876    0.202    3.279  0.493
## 5  Academic_Performance =~ reading_attention  1.000    1.000    1.000     NA
## 6  Academic_Performance =~   academic_result  0.952    0.127   10.575  0.751
## 7         Mental_Health  ~       gaming_time  0.139    0.012    0.293  0.042
## 8  Academic_Performance  ~     Mental_Health -0.160   -0.690    0.262  0.511
## 9  Academic_Performance  ~       gaming_time  0.125   -0.013    0.274  0.124
## 10      indirect_gaming :=               a*b -0.022   -0.102    0.018  0.414
## 11         total_gaming :=           c+(a*b)  0.102   -0.019    0.251  0.185
##    std.all
## 1    0.550
## 2    0.750
## 3    0.605
## 4    0.482
## 5    0.436
## 6    0.416
## 7    0.253
## 8   -0.202
## 9    0.286
## 10  -0.051
## 11   0.235