#clear R Environment and set the seed
rm(list=ls())
set.seed(2000)
#load dplyr package for data manipulation, ggplot2 for visualization, and writexl to write results into excel
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
library(writexl)
## Warning: package 'writexl' was built under R version 4.4.3
#load lavaan and semTools packages to perform confirmatory factor analysis and measure composite reliability
library(lavaan)    
## This is lavaan 0.6-19
## lavaan is FREE software! Please report any bugs.
library(semTools)
## 
## ###############################################################################
## This is semTools 0.5-6
## All users of R (or SEM) are invited to submit functions or ideas for functions.
## ###############################################################################
#load robustbase and car packages to perform robust multiple linear regression
library(robustbase)
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
#load nnet package to perform multinominal regression
library(nnet)
## Warning: package 'nnet' was built under R version 4.4.3
#load the ppcor package to calculate the partial spearman's rank correlation
library(ppcor)
## Loading required package: MASS
## Warning: package 'MASS' was built under R version 4.4.3
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
#load the data file
data <- as.data.frame(read.csv("sim_input.csv"))
#Convert coded dichotomous columns into labelled factors 
coded_cols <- c(14:19)
data[,coded_cols] <- lapply(data[,coded_cols], 
                            function(x) factor(x, levels = c(0, 1), labels = c("No", "Yes"))
                            )

#Data cleaning
cols_to_change <- c(88, 90, 91)
data[,cols_to_change] <- lapply(data[,cols_to_change], 
                                function(x) {
  x[x == "0_1"] <- "0"
  x[x == "0_2"] <- "0"
  x[x == "1_2"] <- "1"
  x[x == "2_2"] <- "2"
  return(x)
  }
  )

#Subset data based on device ID
cat("No. of responses: ", 
    nrow(data), 
    "\n"
    )
## No. of responses:  10000
data_unique <- data[!duplicated(data$deviceid),]
cat("No. of unique responses: ", 
    nrow(data_unique), 
    "\n"
    )
## No. of unique responses:  9700
#Keep responses from undergraduate students
data_under <- data_unique[data_unique$undergrad_now == "Yes", ]
cat("No. of undergraduate participants: ", 
    nrow(data_under), 
    "\n"
    )
## No. of undergraduate participants:  8306
#Exclude non-smokers
sample <- data_under[data_under$smoke_stat == "smoker" | data_under$smoke_stat == "ex_smoker", ]
cat("No. of responses following exclusion of non-smokers: ", 
    nrow(sample),
    "\n"
    )
## No. of responses following exclusion of non-smokers:  6196
#Keep responses from attentive participants
sample$attention <- ifelse(
   (!is.na(sample$attention_check_a) & sample$attention_check_a == 3) |
   (!is.na(sample$attention_check_b) & sample$attention_check_b == 6),
   "Yes", "No"
)
data_attentive <- sample[sample$attention == "Yes", ]
cat("No. of attentive participants: ", 
    nrow(data_attentive), 
    "\n"
    )
## No. of attentive participants:  5544
#Keep responses with sufficient response time
data_attentive$response_threshold <- apply(data_attentive, 
                                         1, function(row) (sum(!is.na(row))*2)-12  #12 is subtracted for ID and multiple-response variables
                                         )
data_cleaned <- data_attentive[data_attentive$response_time > data_attentive$response_threshold, ]
cat("No. of responses following exclusion based on response time: ", 
    nrow(data_cleaned),
    "\n"
    )
## No. of responses following exclusion based on response time:  5457
#Convert behavioral rating scales into factors for data summarization
scale_cols <- c(22:42, 44:99)
data_cleaned[,scale_cols] <- lapply(data_cleaned[,scale_cols], 
                                    function(x) factor(x)
                                    )

#Create a function to summarize each variable
summarize_variable <- function(var) {
  
  if (is.numeric(var)) {
    q <- quantile(var, 
                  probs = c(0.25, 0.5, 0.75), 
                  na.rm = TRUE
                  )
    return(sprintf("Median: %.1f (Q1: %.1f, Q3: %.1f)", q[2], q[1], q[3]))
    
  } else {
    tbl <- table(var)
    prop <- prop.table(tbl)
    return(paste0(
      names(tbl), ": ", as.integer(tbl), " (", round(100 * prop, 1), "%)",
      collapse = "; "
      )
      )
  }
}

#Report summary statistics
exc_var <- c(1, 3, 13)
summary_df <- data.frame(Characteristic = names(data_cleaned[,-exc_var]),
                         Distribution = sapply(data_cleaned[,-exc_var], summarize_variable),
                         row.names = NULL
                         )
summary_df
##             Characteristic
## 1            response_time
## 2                      age
## 3                      sex
## 4               smoke_stat
## 5                ethnicity
## 6                provience
## 7             marital_stat
## 8                residence
## 9            undergrad_now
## 10              speciality
## 11    smoke_now.cigarettes
## 12  smoke_now.e_cigarettes
## 13        smoke_now.hookah
## 14   smoke_past.cigarettes
## 15 smoke_past.e_cigarettes
## 16       smoke_past.hookah
## 17            smoke_most_a
## 18     time_since_quitting
## 19                     hc1
## 20                     sc1
## 21                     ir1
## 22                     sp1
## 23                     hc2
## 24                     sc2
## 25                     ir2
## 26                     sp2
## 27                     hc3
## 28                     sc3
## 29                     ir3
## 30                     sp3
## 31                     hc4
## 32       attention_check_a
## 33                     sc4
## 34                     ir4
## 35                     sp4
## 36                     hc5
## 37                     sc5
## 38                     ir5
## 39                     sp5
## 40            smoke_most_b
## 41                   auto1
## 42                    loc1
## 43                    tol1
## 44                craving1
## 45                  taste1
## 46                  cog_e1
## 47              w_control1
## 48                    cue1
## 49                 affect1
## 50                   auto2
## 51                 attach1
## 52                    cue2
## 53                  cog_e2
## 54                   auto3
## 55                  taste2
## 56                    loc2
## 57                craving2
## 58                 social1
## 59              w_control2
## 60                  taste3
## 61                    loc3
## 62                 attach2
## 63                craving3
## 64                    cue3
## 65                   auto4
## 66                 attach3
## 67                 social2
## 68       attention_check_b
## 69                    tol2
## 70                craving4
## 71                 social3
## 72                    tol3
## 73                  cog_e3
## 74                 affect2
## 75              w_control3
## 76                    loc4
## 77                    tol4
## 78                 affect3
## 79                 cigg_f1
## 80                 cigg_f2
## 81                 cigg_f3
## 82                 cigg_f4
## 83                 cigg_f5
## 84                 cigg_f6
## 85                ecigg_f1
## 86                ecigg_f2
## 87                ecigg_f3
## 88                ecigg_f4
## 89                ecigg_f5
## 90                ecigg_f6
## 91                    h_f1
## 92                    h_f2
## 93                    h_f3
## 94                    h_f4
## 95                    h_f5
## 96                    h_f6
## 97               attention
## 98      response_threshold
##                                                                                                            Distribution
## 1                                                                                  Median: 350.0 (Q1: 338.0, Q3: 361.0)
## 2                                                                                     Median: 21.0 (Q1: 19.0, Q3: 23.0)
## 3                                                                              Female: 2752 (50.4%); Male: 2705 (49.6%)
## 4                                                                         ex_smoker: 2373 (43.5%); smoker: 3084 (56.5%)
## 5                                         Arab: 2172 (39.8%); Kurd: 2184 (40%); Other: 236 (4.3%); Turkman: 865 (15.9%)
## 6                                 Baghdad: 1940 (35.6%); Erbil: 1299 (23.8%); Karbala: 1682 (30.8%); Kirkuk: 536 (9.8%)
## 7                                  Divorced: 445 (8.2%); Married: 1080 (19.8%); Single: 3818 (70%); Widowed: 114 (2.1%)
## 8                                                                              Rural: 1087 (19.9%); Urban: 4370 (80.1%)
## 9                                                                                                      Yes: 5457 (100%)
## 10 Business: 1045 (19.1%); Engineering: 1081 (19.8%); Medicine: 1090 (20%); Other: 1160 (21.3%); Sciences: 1081 (19.8%)
## 11                                                                                  No: 3844 (70.4%); Yes: 1613 (29.6%)
## 12                                                                                      No: 4367 (80%); Yes: 1090 (20%)
## 13                                                                                       No: 4911 (90%); Yes: 546 (10%)
## 14                                                                                  No: 3286 (60.2%); Yes: 2171 (39.8%)
## 15                                                                                  No: 3826 (70.1%); Yes: 1631 (29.9%)
## 16                                                                                  No: 4390 (80.4%); Yes: 1067 (19.6%)
## 17                           cigarettes: 2130 (39%); e_cigarettes: 1683 (30.8%); hookah: 1115 (20.4%); none: 529 (9.7%)
## 18                                     <6 months: 2189 (40.1%); => 1 year: 1312 (24%); 6 months to 1 year: 1956 (35.8%)
## 19                                      0: 413 (7.6%); 1: 1462 (26.8%); 2: 2116 (38.8%); 3: 1220 (22.4%); 4: 246 (4.5%)
## 20                                      0: 343 (6.3%); 1: 1394 (25.5%); 2: 2174 (39.8%); 3: 1267 (23.2%); 4: 279 (5.1%)
## 21                                        0: 653 (12%); 1: 1846 (33.8%); 2: 2093 (38.4%); 3: 761 (13.9%); 4: 104 (1.9%)
## 22                                      0: 504 (9.2%); 1: 1658 (30.4%); 2: 2107 (38.6%); 3: 1009 (18.5%); 4: 179 (3.3%)
## 23                                      0: 370 (6.8%); 1: 1318 (24.2%); 2: 2139 (39.2%); 3: 1277 (23.4%); 4: 353 (6.5%)
## 24                                      0: 297 (5.4%); 1: 1225 (22.4%); 2: 2081 (38.1%); 3: 1460 (26.8%); 4: 394 (7.2%)
## 25                                        0: 597 (10.9%); 1: 1739 (31.9%); 2: 2075 (38%); 3: 903 (16.5%); 4: 143 (2.6%)
## 26                                      0: 589 (10.8%); 1: 1708 (31.3%); 2: 2092 (38.3%); 3: 901 (16.5%); 4: 167 (3.1%)
## 27                                       0: 495 (9.1%); 1: 1682 (30.8%); 2: 2194 (40.2%); 3: 933 (17.1%); 4: 153 (2.8%)
## 28                                        0: 383 (7%); 1: 1542 (28.3%); 2: 2275 (41.7%); 3: 1067 (19.6%); 4: 190 (3.5%)
## 29                                          0: 551 (10.1%); 1: 1639 (30%); 2: 2130 (39%); 3: 957 (17.5%); 4: 180 (3.3%)
## 30                                        0: 494 (9.1%); 1: 1542 (28.3%); 2: 2104 (38.6%); 3: 1098 (20.1%); 4: 219 (4%)
## 31                                      0: 470 (8.6%); 1: 1587 (29.1%); 2: 2163 (39.6%); 3: 1047 (19.2%); 4: 190 (3.5%)
## 32            1: 253 (4.6%); 2: 213 (3.9%); 3: 4052 (74.3%); 4: 240 (4.4%); 5: 235 (4.3%); 6: 231 (4.2%); 7: 233 (4.3%)
## 33                                      0: 311 (5.7%); 1: 1360 (24.9%); 2: 2091 (38.3%); 3: 1354 (24.8%); 4: 341 (6.2%)
## 34                                       0: 670 (12.3%); 1: 1879 (34.4%); 2: 2080 (38.1%); 3: 731 (13.4%); 4: 97 (1.8%)
## 35                                       0: 514 (9.4%); 1: 1701 (31.2%); 2: 2068 (37.9%); 3: 996 (18.3%); 4: 178 (3.3%)
## 36                                      0: 407 (7.5%); 1: 1371 (25.1%); 2: 2107 (38.6%); 3: 1280 (23.5%); 4: 292 (5.4%)
## 37                                      0: 356 (6.5%); 1: 1448 (26.5%); 2: 2204 (40.4%); 3: 1206 (22.1%); 4: 243 (4.5%)
## 38                                        0: 600 (11%); 1: 1762 (32.3%); 2: 2145 (39.3%); 3: 849 (15.6%); 4: 101 (1.9%)
## 39                                        0: 546 (10%); 1: 1779 (32.6%); 2: 2114 (38.7%); 3: 906 (16.6%); 4: 112 (2.1%)
## 40                             cigarettes: 2262 (41.5%); e_cigarettes: 1580 (29%); hookah: 1094 (20%); none: 521 (9.5%)
## 41            1: 18 (0.3%); 2: 255 (4.7%); 3: 1172 (21.5%); 4: 2197 (40.3%); 5: 1418 (26%); 6: 374 (6.9%); 7: 23 (0.4%)
## 42              1: 20 (0.4%); 2: 306 (5.6%); 3: 1296 (23.7%); 4: 2128 (39%); 5: 1364 (25%); 6: 312 (5.7%); 7: 31 (0.6%)
## 43            1: 19 (0.3%); 2: 198 (3.6%); 3: 1102 (20.2%); 4: 2097 (38.4%); 5: 1576 (28.9%); 6: 409 (7.5%); 7: 56 (1%)
## 44          1: 23 (0.4%); 2: 270 (4.9%); 3: 1260 (23.1%); 4: 2143 (39.3%); 5: 1403 (25.7%); 6: 339 (6.2%); 7: 19 (0.3%)
## 45            1: 37 (0.7%); 2: 327 (6%); 3: 1400 (25.7%); 4: 2145 (39.3%); 5: 1220 (22.4%); 6: 306 (5.6%); 7: 22 (0.4%)
## 46             1: 6 (0.1%); 2: 205 (3.8%); 3: 1039 (19%); 4: 2116 (38.8%); 5: 1626 (29.8%); 6: 425 (7.8%); 7: 40 (0.7%)
## 47          1: 41 (0.8%); 2: 316 (5.8%); 3: 1399 (25.6%); 4: 2161 (39.6%); 5: 1216 (22.3%); 6: 299 (5.5%); 7: 25 (0.5%)
## 48            1: 27 (0.5%); 2: 283 (5.2%); 3: 1164 (21.3%); 4: 2120 (38.8%); 5: 1441 (26.4%); 6: 382 (7%); 7: 40 (0.7%)
## 49            1: 19 (0.3%); 2: 227 (4.2%); 3: 1156 (21.2%); 4: 2241 (41.1%); 5: 1461 (26.8%); 6: 330 (6%); 7: 23 (0.4%)
## 50            1: 14 (0.3%); 2: 251 (4.6%); 3: 1241 (22.7%); 4: 2183 (40%); 5: 1403 (25.7%); 6: 333 (6.1%); 7: 32 (0.6%)
## 51            1: 23 (0.4%); 2: 257 (4.7%); 3: 1301 (23.8%); 4: 2168 (39.7%); 5: 1364 (25%); 6: 323 (5.9%); 7: 21 (0.4%)
## 52          1: 17 (0.3%); 2: 238 (4.4%); 3: 1178 (21.6%); 4: 2159 (39.6%); 5: 1458 (26.7%); 6: 364 (6.7%); 7: 43 (0.8%)
## 53              1: 22 (0.4%); 2: 216 (4%); 3: 1093 (20%); 4: 2053 (37.6%); 5: 1599 (29.3%); 6: 430 (7.9%); 7: 44 (0.8%)
## 54          1: 21 (0.4%); 2: 260 (4.8%); 3: 1167 (21.4%); 4: 2172 (39.8%); 5: 1468 (26.9%); 6: 332 (6.1%); 7: 37 (0.7%)
## 55            1: 27 (0.5%); 2: 347 (6.4%); 3: 1358 (24.9%); 4: 2170 (39.8%); 5: 1255 (23%); 6: 282 (5.2%); 7: 18 (0.3%)
## 56              1: 15 (0.3%); 2: 285 (5.2%); 3: 1312 (24%); 4: 2154 (39.5%); 5: 1363 (25%); 6: 306 (5.6%); 7: 22 (0.4%)
## 57          1: 17 (0.3%); 2: 262 (4.8%); 3: 1296 (23.7%); 4: 2189 (40.1%); 5: 1370 (25.1%); 6: 299 (5.5%); 7: 24 (0.4%)
## 58          1: 22 (0.4%); 2: 251 (4.6%); 3: 1238 (22.7%); 4: 2163 (39.6%); 5: 1416 (25.9%); 6: 345 (6.3%); 7: 22 (0.4%)
## 59          1: 35 (0.6%); 2: 302 (5.5%); 3: 1422 (26.1%); 4: 2095 (38.4%); 5: 1274 (23.3%); 6: 298 (5.5%); 7: 31 (0.6%)
## 60            1: 25 (0.5%); 2: 315 (5.8%); 3: 1360 (24.9%); 4: 2184 (40%); 5: 1280 (23.5%); 6: 268 (4.9%); 7: 25 (0.5%)
## 61          1: 18 (0.3%); 2: 255 (4.7%); 3: 1318 (24.2%); 4: 2173 (39.8%); 5: 1343 (24.6%); 6: 323 (5.9%); 7: 27 (0.5%)
## 62          1: 30 (0.5%); 2: 269 (4.9%); 3: 1226 (22.5%); 4: 2189 (40.1%); 5: 1358 (24.9%); 6: 348 (6.4%); 7: 37 (0.7%)
## 63          1: 18 (0.3%); 2: 263 (4.8%); 3: 1252 (22.9%); 4: 2163 (39.6%); 5: 1408 (25.8%); 6: 324 (5.9%); 7: 29 (0.5%)
## 64            1: 21 (0.4%); 2: 274 (5%); 3: 1208 (22.1%); 4: 2064 (37.8%); 5: 1455 (26.7%); 6: 398 (7.3%); 7: 37 (0.7%)
## 65          1: 16 (0.3%); 2: 264 (4.8%); 3: 1183 (21.7%); 4: 2198 (40.3%); 5: 1400 (25.7%); 6: 358 (6.6%); 7: 38 (0.7%)
## 66            1: 23 (0.4%); 2: 261 (4.8%); 3: 1283 (23.5%); 4: 2213 (40.6%); 5: 1323 (24.2%); 6: 325 (6%); 7: 29 (0.5%)
## 67          1: 13 (0.2%); 2: 268 (4.9%); 3: 1185 (21.7%); 4: 2212 (40.5%); 5: 1411 (25.9%); 6: 340 (6.2%); 7: 28 (0.5%)
## 68                1: 236 (4.3%); 2: 198 (3.6%); 3: 213 (3.9%); 4: 217 (4%); 5: 206 (3.8%); 6: 4169 (76.4%); 7: 218 (4%)
## 69          1: 22 (0.4%); 2: 189 (3.5%); 3: 1044 (19.1%); 4: 2106 (38.6%); 5: 1622 (29.7%); 6: 427 (7.8%); 7: 47 (0.9%)
## 70          1: 22 (0.4%); 2: 252 (4.6%); 3: 1267 (23.2%); 4: 2168 (39.7%); 5: 1382 (25.3%); 6: 336 (6.2%); 7: 30 (0.5%)
## 71          1: 22 (0.4%); 2: 246 (4.5%); 3: 1261 (23.1%); 4: 2154 (39.5%); 5: 1407 (25.8%); 6: 333 (6.1%); 7: 34 (0.6%)
## 72            1: 16 (0.3%); 2: 199 (3.6%); 3: 1058 (19.4%); 4: 2188 (40.1%); 5: 1516 (27.8%); 6: 426 (7.8%); 7: 54 (1%)
## 73            1: 21 (0.4%); 2: 201 (3.7%); 3: 1047 (19.2%); 4: 2141 (39.2%); 5: 1549 (28.4%); 6: 443 (8.1%); 7: 55 (1%)
## 74          1: 25 (0.5%); 2: 210 (3.8%); 3: 1156 (21.2%); 4: 2188 (40.1%); 5: 1490 (27.3%); 6: 356 (6.5%); 7: 32 (0.6%)
## 75            1: 32 (0.6%); 2: 335 (6.1%); 3: 1334 (24.4%); 4: 2144 (39.3%); 5: 1310 (24%); 6: 279 (5.1%); 7: 23 (0.4%)
## 76              1: 20 (0.4%); 2: 296 (5.4%); 3: 1310 (24%); 4: 2152 (39.4%); 5: 1363 (25%); 6: 278 (5.1%); 7: 38 (0.7%)
## 77          1: 13 (0.2%); 2: 243 (4.5%); 3: 1021 (18.7%); 4: 2163 (39.6%); 5: 1544 (28.3%); 6: 431 (7.9%); 7: 42 (0.8%)
## 78          1: 18 (0.3%); 2: 267 (4.9%); 3: 1178 (21.6%); 4: 2120 (38.8%); 5: 1496 (27.4%); 6: 345 (6.3%); 7: 33 (0.6%)
## 79                                                   0: 1632 (29.9%); 1: 1618 (29.6%); 2: 1075 (19.7%); 3: 1132 (20.7%)
## 80                                                                                     0: 3332 (61.1%); 1: 2125 (38.9%)
## 81                                                                                     0: 2786 (51.1%); 1: 2671 (48.9%)
## 82                                                    0: 2210 (40.5%); 1: 1662 (30.5%); 2: 1028 (18.8%); 3: 557 (10.2%)
## 83                                                                                     0: 3799 (69.6%); 1: 1658 (30.4%)
## 84                                                                                     0: 4385 (80.4%); 1: 1072 (19.6%)
## 85                                                                    0: 3012 (55.2%); 1: 1374 (25.2%); 2: 1071 (19.6%)
## 86                                                                                     0: 3317 (60.8%); 1: 2140 (39.2%)
## 87                                                                    0: 2973 (54.5%); 1: 1368 (25.1%); 2: 1116 (20.5%)
## 88                                                                      0: 3033 (55.6%); 1: 1363 (25%); 2: 1061 (19.4%)
## 89                                                       0: 2185 (40%); 1: 1604 (29.4%); 2: 1127 (20.7%); 3: 541 (9.9%)
## 90                                                                                     0: 4327 (79.3%); 1: 1130 (20.7%)
## 91                                                      0: 2745 (50.3%); 1: 1634 (29.9%); 2: 824 (15.1%); 3: 254 (4.7%)
## 92                                                                                     0: 4379 (80.2%); 1: 1078 (19.8%)
## 93                                                                                     0: 3788 (69.4%); 1: 1669 (30.6%)
## 94                                                        0: 3298 (60.4%); 1: 1316 (24.1%); 2: 569 (10.4%); 3: 274 (5%)
## 95                                                                                      0: 4901 (89.8%); 1: 556 (10.2%)
## 96                                                                                      0: 4620 (84.7%); 1: 837 (15.3%)
## 97                                                                                                     Yes: 5457 (100%)
## 98                                                                                 Median: 188.0 (Q1: 188.0, Q3: 188.0)
#Return behavioral scales into numeric variables for analysis
data_cleaned[, scale_cols] <- lapply(data_cleaned[, scale_cols], function(x) {
  as.numeric(as.character(x))
})

#Calculate the item-item correlation matrix for the WISDM-37 and write into an excel file
wisdm37 <- setdiff(44:81, 71)
wisdm37_cor <- as.data.frame(cor(data_cleaned[,wisdm37], 
                                 method = "spearman")
                             )
write_xlsx(wisdm37_cor, 
           "WISDM-37 item-item correlation matrix.xlsx"
           )

#Calculate the item-item correlation matrix for the RFQ and write into an excel file
rfq <- setdiff(22:42, 35)
rfq_cor <- as.data.frame(cor(data_cleaned[,rfq], 
                             method = "spearman")
                         )
write_xlsx(rfq_cor, 
           "RFQ item-item correlation matrix.xlsx"
           )
#Confirmatory factor analysis for the WISDM-37 questionnaire:

#Based on continuous variables:

#Model 1: 1-factor solution
cont_mod1 <-'f =~ auto1 + auto2 + auto3 + auto4 + 
                  loc1 + loc2 + loc3 + loc4 + 
                  tol1 + tol2 + tol3 + tol4 + 
                  craving1 + craving2 + craving3 + craving4 +
                  taste1 + taste2 + taste3 +
                  cog_e1 + cog_e2 + cog_e3 +
                  w_control1 + w_control2 + w_control3 +
                  cue1 + cue2 + cue3 + 
                  affect1 + affect2 + affect3 + 
                  attach1 + attach2 + attach3 +
                  social1 + social2 +social3
                  '
cont_mod1_fit <- cfa(cont_mod1, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(cont_mod1_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        74
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              10301.810   10342.332
##   Degrees of freedom                                629         629
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   0.996
##     Yuan-Bentler correction (Mplus variant)                        
## 
## Model Test Baseline Model:
## 
##   Test statistic                             25978.585   25963.681
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.618       0.616
##   Tucker-Lewis Index (TLI)                       0.595       0.593
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.618
##   Robust Tucker-Lewis Index (TLI)                            0.595
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -279425.984 -279425.984
##   Scaling correction factor                                  1.029
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -274275.079 -274275.079
##   Scaling correction factor                                  1.000
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              558999.969  558999.969
##   Bayesian (BIC)                            559488.713  559488.713
##   Sample-size adjusted Bayesian (SABIC)     559253.564  559253.564
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053       0.053
##   90 Percent confidence interval - lower         0.052       0.052
##   90 Percent confidence interval - upper         0.054       0.054
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.053
##   90 Percent confidence interval - lower                     0.052
##   90 Percent confidence interval - upper                     0.054
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.057       0.057
## 
## 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
##   f =~                                                                  
##     auto1             1.000                               0.346    0.347
##     auto2             0.940    0.048   19.405    0.000    0.325    0.328
##     auto3             0.993    0.050   19.719    0.000    0.343    0.343
##     auto4             1.016    0.049   20.640    0.000    0.352    0.350
##     loc1              1.003    0.057   17.475    0.000    0.347    0.343
##     loc2              0.930    0.054   17.077    0.000    0.322    0.324
##     loc3              0.955    0.057   16.795    0.000    0.330    0.333
##     loc4              0.978    0.058   16.895    0.000    0.338    0.337
##     tol1              1.019    0.057   17.883    0.000    0.352    0.348
##     tol2              0.991    0.056   17.794    0.000    0.343    0.341
##     tol3              1.032    0.058   17.746    0.000    0.357    0.355
##     tol4              1.015    0.058   17.643    0.000    0.351    0.347
##     craving1          0.969    0.056   17.264    0.000    0.335    0.335
##     craving2          1.038    0.059   17.711    0.000    0.359    0.365
##     craving3          1.000    0.057   17.689    0.000    0.346    0.347
##     craving4          0.928    0.055   16.945    0.000    0.321    0.321
##     taste1            1.034    0.071   14.566    0.000    0.358    0.351
##     taste2            1.047    0.072   14.518    0.000    0.362    0.360
##     taste3            1.010    0.070   14.494    0.000    0.349    0.351
##     cog_e1            1.004    0.070   14.413    0.000    0.347    0.350
##     cog_e2            0.997    0.071   13.993    0.000    0.345    0.338
##     cog_e3            1.009    0.072   14.028    0.000    0.349    0.343
##     w_control1        1.007    0.071   14.242    0.000    0.348    0.342
##     w_control2        1.076    0.073   14.744    0.000    0.372    0.365
##     w_control3        0.980    0.070   13.984    0.000    0.339    0.335
##     cue1              1.074    0.073   14.619    0.000    0.371    0.360
##     cue2              1.020    0.069   14.734    0.000    0.353    0.351
##     cue3              1.110    0.076   14.519    0.000    0.384    0.372
##     affect1           0.947    0.065   14.589    0.000    0.328    0.336
##     affect2           0.973    0.068   14.306    0.000    0.336    0.340
##     affect3           0.916    0.066   13.937    0.000    0.317    0.315
##     attach1           0.955    0.066   14.491    0.000    0.330    0.333
##     attach2           1.046    0.071   14.682    0.000    0.362    0.356
##     attach3           0.923    0.068   13.638    0.000    0.319    0.321
##     social1           1.005    0.070   14.394    0.000    0.348    0.349
##     social2           1.002    0.069   14.585    0.000    0.347    0.350
##     social3           0.972    0.068   14.210    0.000    0.336    0.336
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.875    0.017   50.799    0.000    0.875    0.880
##    .auto2             0.878    0.017   50.966    0.000    0.878    0.893
##    .auto3             0.886    0.018   49.572    0.000    0.886    0.883
##    .auto4             0.887    0.018   50.343    0.000    0.887    0.878
##    .loc1              0.904    0.018   51.009    0.000    0.904    0.883
##    .loc2              0.881    0.017   52.041    0.000    0.881    0.895
##    .loc3              0.875    0.017   50.165    0.000    0.875    0.889
##    .loc4              0.892    0.018   50.160    0.000    0.892    0.886
##    .tol1              0.901    0.018   49.275    0.000    0.901    0.879
##    .tol2              0.894    0.018   49.539    0.000    0.894    0.884
##    .tol3              0.883    0.018   49.919    0.000    0.883    0.874
##    .tol4              0.899    0.018   49.946    0.000    0.899    0.879
##    .craving1          0.889    0.017   51.398    0.000    0.889    0.888
##    .craving2          0.838    0.016   51.419    0.000    0.838    0.867
##    .craving3          0.872    0.018   49.627    0.000    0.872    0.879
##    .craving4          0.896    0.018   50.877    0.000    0.896    0.897
##    .taste1            0.911    0.018   49.716    0.000    0.911    0.877
##    .taste2            0.881    0.017   51.837    0.000    0.881    0.871
##    .taste3            0.871    0.017   50.356    0.000    0.871    0.877
##    .cog_e1            0.863    0.017   51.078    0.000    0.863    0.877
##    .cog_e2            0.923    0.019   49.766    0.000    0.923    0.886
##    .cog_e3            0.912    0.018   49.297    0.000    0.912    0.882
##    .w_control1        0.915    0.019   49.163    0.000    0.915    0.883
##    .w_control2        0.903    0.018   50.924    0.000    0.903    0.867
##    .w_control3        0.910    0.018   50.874    0.000    0.910    0.888
##    .cue1              0.929    0.019   49.275    0.000    0.929    0.871
##    .cue2              0.886    0.018   49.970    0.000    0.886    0.877
##    .cue3              0.919    0.018   50.605    0.000    0.919    0.862
##    .affect1           0.841    0.017   50.726    0.000    0.841    0.887
##    .affect2           0.867    0.017   50.226    0.000    0.867    0.885
##    .affect3           0.913    0.018   50.844    0.000    0.913    0.901
##    .attach1           0.876    0.017   51.333    0.000    0.876    0.889
##    .attach2           0.902    0.018   49.527    0.000    0.902    0.873
##    .attach3           0.890    0.017   50.877    0.000    0.890    0.897
##    .social1           0.870    0.017   50.953    0.000    0.870    0.878
##    .social2           0.863    0.017   51.217    0.000    0.863    0.878
##    .social3           0.888    0.017   50.872    0.000    0.888    0.887
##     f                 0.120    0.011   10.586    0.000    1.000    1.000
#Model 2: 11-factor solution
cont_mod2 <-'#Primary dependence motives
             auto      =~ auto1 + auto2 + auto3 + auto4
             loc       =~ loc1 + loc2 + loc3 + loc4
             tol       =~ tol1 + tol2 + tol3 + tol4
             craving   =~ craving1 + craving2 + craving3 + craving4
             
             #Secondary dependence motives
             taste     =~ taste1 + taste2 + taste3
             cog_e     =~ cog_e1 + cog_e2 + cog_e3
             w_control =~ w_control1 + w_control2 + w_control3
             cue       =~ cue1 + cue2 + cue3
             affect    =~ affect1 + affect2 + affect3
             attach    =~ attach1 + attach2 + attach3
             social    =~ social1 + social2 +social3
             '
cont_mod2_fit <- cfa(cont_mod2, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(cont_mod2_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 84 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                       129
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               531.570     531.350
##   Degrees of freedom                               574         574
##   P-value (Chi-square)                           0.897       0.898
##   Scaling correction factor                                  1.000
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             25978.585   25963.681
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.002       1.002
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.002
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -274540.864 -274540.864
##   Scaling correction factor                                  0.996
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -274275.079 -274275.079
##   Scaling correction factor                                  1.000
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              549339.728  549339.728
##   Bayesian (BIC)                            550191.729  550191.729
##   Sample-size adjusted Bayesian (SABIC)     549781.807  549781.807
## 
## 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.002       0.002
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.002
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.010       0.010
## 
## 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
##   auto =~                                                               
##     auto1             1.000                               0.547    0.548
##     auto2             0.968    0.038   25.183    0.000    0.529    0.534
##     auto3             0.969    0.038   25.180    0.000    0.529    0.528
##     auto4             0.971    0.040   24.516    0.000    0.531    0.528
##   loc =~                                                                
##     loc1              1.000                               0.542    0.536
##     loc2              0.941    0.038   24.702    0.000    0.510    0.514
##     loc3              0.978    0.039   25.257    0.000    0.530    0.534
##     loc4              0.965    0.039   24.553    0.000    0.523    0.521
##   tol =~                                                                
##     tol1              1.000                               0.548    0.542
##     tol2              0.952    0.038   24.973    0.000    0.522    0.519
##     tol3              1.004    0.040   25.205    0.000    0.550    0.548
##     tol4              1.011    0.040   25.429    0.000    0.554    0.548
##   craving =~                                                            
##     craving1          1.000                               0.506    0.506
##     craving2          1.031    0.042   24.267    0.000    0.522    0.531
##     craving3          1.069    0.044   24.077    0.000    0.541    0.544
##     craving4          0.987    0.043   23.175    0.000    0.500    0.500
##   taste =~                                                              
##     taste1            1.000                               0.546    0.536
##     taste2            1.017    0.044   23.117    0.000    0.556    0.552
##     taste3            0.975    0.041   23.616    0.000    0.533    0.535
##   cog_e =~                                                              
##     cog_e1            1.000                               0.532    0.537
##     cog_e2            1.018    0.043   23.560    0.000    0.542    0.531
##     cog_e3            1.006    0.045   22.164    0.000    0.535    0.527
##   w_control =~                                                          
##     w_control1        1.000                               0.555    0.545
##     w_control2        1.046    0.044   23.753    0.000    0.581    0.569
##     w_control3        0.968    0.040   23.913    0.000    0.537    0.531
##   cue =~                                                                
##     cue1              1.000                               0.580    0.562
##     cue2              0.940    0.037   25.735    0.000    0.545    0.542
##     cue3              1.004    0.042   24.048    0.000    0.582    0.564
##   affect =~                                                             
##     affect1           1.000                               0.495    0.508
##     affect2           1.073    0.051   21.011    0.000    0.531    0.536
##     affect3           1.011    0.047   21.665    0.000    0.500    0.497
##   attach =~                                                             
##     attach1           1.000                               0.516    0.519
##     attach2           1.095    0.048   22.759    0.000    0.564    0.555
##     attach3           0.995    0.045   22.005    0.000    0.513    0.515
##   social =~                                                             
##     social1           1.000                               0.517    0.519
##     social2           1.008    0.046   21.672    0.000    0.521    0.525
##     social3           0.987    0.045   21.803    0.000    0.511    0.510
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   auto ~~                                                               
##     loc               0.160    0.009   18.224    0.000    0.539    0.539
##     tol               0.160    0.009   18.086    0.000    0.534    0.534
##     craving           0.154    0.009   17.802    0.000    0.557    0.557
##     taste             0.078    0.008   10.235    0.000    0.260    0.260
##     cog_e             0.067    0.007    9.231    0.000    0.230    0.230
##     w_control         0.074    0.008    9.851    0.000    0.245    0.245
##     cue               0.089    0.008   10.818    0.000    0.281    0.281
##     affect            0.070    0.007    9.500    0.000    0.260    0.260
##     attach            0.073    0.007    9.823    0.000    0.258    0.258
##     social            0.076    0.007   10.323    0.000    0.269    0.269
##   loc ~~                                                                
##     tol               0.170    0.009   18.689    0.000    0.573    0.573
##     craving           0.158    0.009   17.910    0.000    0.577    0.577
##     taste             0.070    0.007    9.525    0.000    0.235    0.235
##     cog_e             0.074    0.007   10.104    0.000    0.255    0.255
##     w_control         0.067    0.007    9.280    0.000    0.224    0.224
##     cue               0.076    0.008    9.738    0.000    0.241    0.241
##     affect            0.067    0.007    9.365    0.000    0.251    0.251
##     attach            0.070    0.007    9.805    0.000    0.250    0.250
##     social            0.072    0.007    9.867    0.000    0.256    0.256
##   tol ~~                                                                
##     craving           0.162    0.009   18.525    0.000    0.583    0.583
##     taste             0.075    0.008    9.825    0.000    0.250    0.250
##     cog_e             0.074    0.007    9.925    0.000    0.253    0.253
##     w_control         0.078    0.008   10.314    0.000    0.255    0.255
##     cue               0.072    0.008    9.330    0.000    0.225    0.225
##     affect            0.067    0.007    9.324    0.000    0.246    0.246
##     attach            0.069    0.007    9.725    0.000    0.244    0.244
##     social            0.082    0.007   11.160    0.000    0.288    0.288
##   craving ~~                                                            
##     taste             0.075    0.007   10.144    0.000    0.270    0.270
##     cog_e             0.069    0.007    9.724    0.000    0.258    0.258
##     w_control         0.070    0.007    9.912    0.000    0.249    0.249
##     cue               0.076    0.008   10.098    0.000    0.259    0.259
##     affect            0.063    0.007    9.373    0.000    0.254    0.254
##     attach            0.070    0.007   10.061    0.000    0.269    0.269
##     social            0.073    0.007   10.232    0.000    0.279    0.279
##   taste ~~                                                              
##     cog_e             0.151    0.009   16.442    0.000    0.519    0.519
##     w_control         0.146    0.009   15.876    0.000    0.481    0.481
##     cue               0.159    0.009   17.291    0.000    0.502    0.502
##     affect            0.137    0.009   15.592    0.000    0.506    0.506
##     attach            0.135    0.009   15.778    0.000    0.480    0.480
##     social            0.148    0.009   15.802    0.000    0.523    0.523
##   cog_e ~~                                                              
##     w_control         0.147    0.009   16.239    0.000    0.497    0.497
##     cue               0.151    0.009   16.148    0.000    0.490    0.490
##     affect            0.131    0.009   15.265    0.000    0.496    0.496
##     attach            0.135    0.009   15.281    0.000    0.491    0.491
##     social            0.140    0.009   15.772    0.000    0.510    0.510
##   w_control ~~                                                          
##     cue               0.156    0.009   16.763    0.000    0.483    0.483
##     affect            0.138    0.009   15.413    0.000    0.502    0.502
##     attach            0.139    0.009   15.946    0.000    0.486    0.486
##     social            0.135    0.009   15.031    0.000    0.470    0.470
##   cue ~~                                                                
##     affect            0.146    0.009   15.936    0.000    0.509    0.509
##     attach            0.142    0.009   15.366    0.000    0.475    0.475
##     social            0.154    0.010   16.156    0.000    0.514    0.514
##   affect ~~                                                             
##     attach            0.117    0.008   14.551    0.000    0.459    0.459
##     social            0.129    0.009   14.806    0.000    0.503    0.503
##   attach ~~                                                             
##     social            0.133    0.009   15.340    0.000    0.499    0.499
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.696    0.016   42.270    0.000    0.696    0.700
##    .auto2             0.704    0.016   42.687    0.000    0.704    0.715
##    .auto3             0.724    0.017   41.533    0.000    0.724    0.721
##    .auto4             0.729    0.018   41.395    0.000    0.729    0.722
##    .loc1              0.730    0.017   42.836    0.000    0.730    0.713
##    .loc2              0.724    0.017   43.443    0.000    0.724    0.735
##    .loc3              0.703    0.017   42.150    0.000    0.703    0.714
##    .loc4              0.733    0.017   43.098    0.000    0.733    0.728
##    .tol1              0.725    0.017   42.656    0.000    0.725    0.707
##    .tol2              0.738    0.017   43.698    0.000    0.738    0.730
##    .tol3              0.707    0.017   41.787    0.000    0.707    0.700
##    .tol4              0.715    0.017   42.646    0.000    0.715    0.699
##    .craving1          0.745    0.017   43.770    0.000    0.745    0.744
##    .craving2          0.694    0.016   43.050    0.000    0.694    0.718
##    .craving3          0.699    0.017   42.031    0.000    0.699    0.705
##    .craving4          0.749    0.017   44.774    0.000    0.749    0.750
##    .taste1            0.741    0.018   40.262    0.000    0.741    0.713
##    .taste2            0.703    0.018   38.949    0.000    0.703    0.695
##    .taste3            0.709    0.017   40.726    0.000    0.709    0.714
##    .cog_e1            0.700    0.018   39.701    0.000    0.700    0.712
##    .cog_e2            0.749    0.019   39.891    0.000    0.749    0.718
##    .cog_e3            0.747    0.019   40.224    0.000    0.747    0.723
##    .w_control1        0.729    0.019   38.881    0.000    0.729    0.703
##    .w_control2        0.705    0.018   38.443    0.000    0.705    0.676
##    .w_control3        0.736    0.018   40.336    0.000    0.736    0.719
##    .cue1              0.730    0.019   38.860    0.000    0.730    0.684
##    .cue2              0.714    0.018   39.720    0.000    0.714    0.706
##    .cue3              0.727    0.019   39.220    0.000    0.727    0.682
##    .affect1           0.703    0.018   39.681    0.000    0.703    0.742
##    .affect2           0.698    0.018   38.442    0.000    0.698    0.712
##    .affect3           0.763    0.018   41.460    0.000    0.763    0.753
##    .attach1           0.719    0.018   40.914    0.000    0.719    0.730
##    .attach2           0.715    0.019   37.869    0.000    0.715    0.692
##    .attach3           0.729    0.018   40.218    0.000    0.729    0.735
##    .social1           0.724    0.018   40.489    0.000    0.724    0.730
##    .social2           0.712    0.018   39.457    0.000    0.712    0.724
##    .social3           0.741    0.018   41.441    0.000    0.741    0.740
##     auto              0.299    0.017   17.258    0.000    1.000    1.000
##     loc               0.294    0.017   17.159    0.000    1.000    1.000
##     tol               0.301    0.017   17.284    0.000    1.000    1.000
##     craving           0.256    0.016   16.069    0.000    1.000    1.000
##     taste             0.298    0.018   16.324    0.000    1.000    1.000
##     cog_e             0.283    0.017   16.367    0.000    1.000    1.000
##     w_control         0.308    0.019   16.575    0.000    1.000    1.000
##     cue               0.336    0.019   17.502    0.000    1.000    1.000
##     affect            0.245    0.016   14.984    0.000    1.000    1.000
##     attach            0.266    0.017   15.469    0.000    1.000    1.000
##     social            0.267    0.017   15.580    0.000    1.000    1.000
#Model 3: 2-factor solution
cont_mod3 <- 'pdm =~ auto1 + auto2 + auto3 + auto4 + 
                     loc1 + loc2 + loc3 + loc4 + 
                     tol1 + tol2 + tol3 + tol4 + 
                     craving1 + craving2 + craving3 + craving4
                     
              sdm =~ taste1 + taste2 + taste3 +
                     cog_e1 + cog_e2 + cog_e3 +
                     w_control1 + w_control2 + w_control3 +
                     cue1 + cue2 + cue3 + 
                     affect1 + affect2 + affect3 + 
                     attach1 + attach2 + attach3 +
                     social1 + social2 +social3
                     '
cont_mod3_fit <- cfa(cont_mod3, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(cont_mod3_fit, 
        standardized = TRUE,
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 43 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        75
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              5270.999    5275.290
##   Degrees of freedom                               628         628
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.999
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             25978.585   25963.681
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.817       0.816
##   Tucker-Lewis Index (TLI)                       0.805       0.805
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.817
##   Robust Tucker-Lewis Index (TLI)                            0.805
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -276910.579 -276910.579
##   Scaling correction factor                                  1.003
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -274275.079 -274275.079
##   Scaling correction factor                                  1.000
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              553971.158  553971.158
##   Bayesian (BIC)                            554466.507  554466.507
##   Sample-size adjusted Bayesian (SABIC)     554228.180  554228.180
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.037       0.037
##   90 Percent confidence interval - lower         0.036       0.036
##   90 Percent confidence interval - upper         0.038       0.038
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.037
##   90 Percent confidence interval - lower                     0.036
##   90 Percent confidence interval - upper                     0.038
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.033       0.033
## 
## 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
##   pdm =~                                                                
##     auto1             1.000                               0.421    0.422
##     auto2             0.984    0.041   23.985    0.000    0.414    0.418
##     auto3             0.996    0.042   23.469    0.000    0.420    0.419
##     auto4             1.010    0.042   23.922    0.000    0.425    0.423
##     loc1              1.036    0.052   20.066    0.000    0.436    0.431
##     loc2              0.977    0.049   19.936    0.000    0.412    0.415
##     loc3              0.999    0.051   19.671    0.000    0.421    0.424
##     loc4              1.008    0.052   19.409    0.000    0.424    0.423
##     tol1              1.052    0.052   20.417    0.000    0.443    0.438
##     tol2              1.016    0.051   19.761    0.000    0.428    0.426
##     tol3              1.060    0.053   19.818    0.000    0.446    0.444
##     tol4              1.078    0.053   20.406    0.000    0.454    0.449
##     craving1          0.986    0.050   19.915    0.000    0.415    0.415
##     craving2          1.007    0.050   20.059    0.000    0.424    0.431
##     craving3          1.050    0.051   20.662    0.000    0.442    0.444
##     craving4          0.966    0.049   19.651    0.000    0.407    0.407
##   sdm =~                                                                
##     taste1            1.000                               0.412    0.404
##     taste2            1.005    0.043   23.159    0.000    0.414    0.412
##     taste3            0.968    0.041   23.434    0.000    0.399    0.401
##     cog_e1            0.962    0.049   19.807    0.000    0.397    0.400
##     cog_e2            0.962    0.049   19.682    0.000    0.397    0.389
##     cog_e3            0.981    0.049   19.829    0.000    0.404    0.398
##     w_control1        0.977    0.051   19.264    0.000    0.403    0.396
##     w_control2        1.037    0.051   20.461    0.000    0.428    0.419
##     w_control3        0.945    0.050   18.742    0.000    0.390    0.385
##     cue1              1.039    0.053   19.727    0.000    0.428    0.415
##     cue2              0.970    0.050   19.465    0.000    0.400    0.398
##     cue3              1.081    0.054   20.141    0.000    0.446    0.432
##     affect1           0.885    0.047   18.928    0.000    0.365    0.375
##     affect2           0.951    0.050   18.997    0.000    0.392    0.396
##     affect3           0.874    0.048   18.237    0.000    0.361    0.358
##     attach1           0.895    0.047   18.872    0.000    0.369    0.372
##     attach2           0.980    0.050   19.721    0.000    0.404    0.397
##     attach3           0.900    0.048   18.610    0.000    0.371    0.373
##     social1           0.950    0.048   19.694    0.000    0.392    0.393
##     social2           0.939    0.049   19.249    0.000    0.387    0.391
##     social3           0.917    0.046   19.730    0.000    0.378    0.378
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   pdm ~~                                                                
##     sdm               0.074    0.005   15.080    0.000    0.427    0.427
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.818    0.016   50.585    0.000    0.818    0.822
##    .auto2             0.812    0.016   49.543    0.000    0.812    0.825
##    .auto3             0.828    0.018   47.328    0.000    0.828    0.825
##    .auto4             0.830    0.017   48.357    0.000    0.830    0.821
##    .loc1              0.834    0.017   49.547    0.000    0.834    0.814
##    .loc2              0.815    0.016   50.015    0.000    0.815    0.828
##    .loc3              0.807    0.016   49.385    0.000    0.807    0.820
##    .loc4              0.826    0.017   49.072    0.000    0.826    0.821
##    .tol1              0.829    0.017   48.631    0.000    0.829    0.808
##    .tol2              0.828    0.017   48.984    0.000    0.828    0.819
##    .tol3              0.811    0.017   48.278    0.000    0.811    0.803
##    .tol4              0.816    0.017   48.889    0.000    0.816    0.798
##    .craving1          0.829    0.016   50.479    0.000    0.829    0.828
##    .craving2          0.787    0.016   50.314    0.000    0.787    0.814
##    .craving3          0.796    0.016   48.622    0.000    0.796    0.803
##    .craving4          0.834    0.017   50.268    0.000    0.834    0.834
##    .taste1            0.869    0.018   49.533    0.000    0.869    0.836
##    .taste2            0.840    0.016   50.959    0.000    0.840    0.830
##    .taste3            0.833    0.017   49.800    0.000    0.833    0.839
##    .cog_e1            0.826    0.016   50.295    0.000    0.826    0.840
##    .cog_e2            0.885    0.018   49.505    0.000    0.885    0.849
##    .cog_e3            0.870    0.018   48.929    0.000    0.870    0.842
##    .w_control1        0.874    0.018   48.740    0.000    0.874    0.844
##    .w_control2        0.859    0.017   50.551    0.000    0.859    0.824
##    .w_control3        0.872    0.017   49.865    0.000    0.872    0.852
##    .cue1              0.883    0.018   48.979    0.000    0.883    0.828
##    .cue2              0.851    0.017   49.880    0.000    0.851    0.842
##    .cue3              0.868    0.017   50.071    0.000    0.868    0.814
##    .affect1           0.815    0.016   49.921    0.000    0.815    0.860
##    .affect2           0.826    0.017   49.736    0.000    0.826    0.843
##    .affect3           0.884    0.017   50.823    0.000    0.884    0.872
##    .attach1           0.849    0.017   50.864    0.000    0.849    0.862
##    .attach2           0.870    0.018   49.081    0.000    0.870    0.842
##    .attach3           0.854    0.017   50.160    0.000    0.854    0.861
##    .social1           0.838    0.017   50.235    0.000    0.838    0.845
##    .social2           0.833    0.017   49.815    0.000    0.833    0.847
##    .social3           0.859    0.017   50.585    0.000    0.859    0.857
##     pdm               0.177    0.013   13.801    0.000    1.000    1.000
##     sdm               0.170    0.012   13.769    0.000    1.000    1.000
#Model 4: 2-order solution
cont_mod4 <- '#1st order
             auto      =~ auto1 + auto2 + auto3 + auto4
             loc       =~ loc1 + loc2 + loc3 + loc4
             tol       =~ tol1 + tol2 + tol3 + tol4
             craving   =~ craving1 + craving2 + craving3 + craving4
             taste     =~ taste1 + taste2 + taste3
             cog_e     =~ cog_e1 + cog_e2 + cog_e3
             w_control =~ w_control1 + w_control2 + w_control3
             cue       =~ cue1 + cue2 + cue3
             affect    =~ affect1 + affect2 + affect3
             attach    =~ attach1 + attach2 + attach3
             social    =~ social1 + social2 +social3
             
             #2nd order
             pdm =~ auto + loc + tol + craving
             sdm =~ taste + cog_e + w_control + cue + affect + attach + social
             '
cont_mod4_fit <- cfa(cont_mod4, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(cont_mod4_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 63 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        86
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               557.072     556.735
##   Degrees of freedom                               617         617
##   P-value (Chi-square)                           0.960       0.960
##   Scaling correction factor                                  1.001
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             25978.585   25963.681
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.001
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.003       1.003
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.003
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -274553.615 -274553.615
##   Scaling correction factor                                  0.992
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -274275.079 -274275.079
##   Scaling correction factor                                  1.000
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              549279.231  549279.231
##   Bayesian (BIC)                            549847.231  549847.231
##   Sample-size adjusted Bayesian (SABIC)     549573.950  549573.950
## 
## 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.000       0.000
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.000
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.011       0.011
## 
## 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
##   auto =~                                                               
##     auto1             1.000                               0.547    0.548
##     auto2             0.969    0.038   25.205    0.000    0.530    0.534
##     auto3             0.969    0.038   25.192    0.000    0.530    0.529
##     auto4             0.969    0.039   24.571    0.000    0.530    0.527
##   loc =~                                                                
##     loc1              1.000                               0.542    0.536
##     loc2              0.941    0.038   24.716    0.000    0.510    0.514
##     loc3              0.977    0.039   25.304    0.000    0.530    0.534
##     loc4              0.965    0.039   24.558    0.000    0.523    0.522
##   tol =~                                                                
##     tol1              1.000                               0.549    0.542
##     tol2              0.951    0.038   25.038    0.000    0.522    0.519
##     tol3              1.003    0.040   25.243    0.000    0.550    0.548
##     tol4              1.011    0.040   25.501    0.000    0.554    0.548
##   craving =~                                                            
##     craving1          1.000                               0.506    0.506
##     craving2          1.032    0.042   24.370    0.000    0.522    0.531
##     craving3          1.071    0.044   24.173    0.000    0.542    0.544
##     craving4          0.988    0.042   23.273    0.000    0.500    0.500
##   taste =~                                                              
##     taste1            1.000                               0.546    0.536
##     taste2            1.017    0.044   23.223    0.000    0.555    0.552
##     taste3            0.977    0.041   23.701    0.000    0.534    0.536
##   cog_e =~                                                              
##     cog_e1            1.000                               0.533    0.537
##     cog_e2            1.018    0.043   23.536    0.000    0.542    0.531
##     cog_e3            1.004    0.045   22.245    0.000    0.535    0.526
##   w_control =~                                                          
##     w_control1        1.000                               0.555    0.545
##     w_control2        1.046    0.044   23.818    0.000    0.581    0.569
##     w_control3        0.968    0.040   23.918    0.000    0.537    0.531
##   cue =~                                                                
##     cue1              1.000                               0.579    0.561
##     cue2              0.941    0.036   25.803    0.000    0.545    0.542
##     cue3              1.006    0.042   24.110    0.000    0.583    0.564
##   affect =~                                                             
##     affect1           1.000                               0.495    0.508
##     affect2           1.073    0.051   21.098    0.000    0.531    0.536
##     affect3           1.011    0.047   21.729    0.000    0.500    0.497
##   attach =~                                                             
##     attach1           1.000                               0.515    0.519
##     attach2           1.095    0.048   22.920    0.000    0.564    0.555
##     attach3           0.996    0.045   22.168    0.000    0.513    0.515
##   social =~                                                             
##     social1           1.000                               0.518    0.520
##     social2           1.007    0.046   21.664    0.000    0.521    0.526
##     social3           0.985    0.045   21.815    0.000    0.510    0.509
##   pdm =~                                                                
##     auto              1.000                               0.722    0.722
##     loc               1.028    0.051   20.311    0.000    0.748    0.748
##     tol               1.046    0.050   20.819    0.000    0.752    0.752
##     craving           0.991    0.050   19.951    0.000    0.773    0.773
##   sdm =~                                                                
##     taste             1.000                               0.714    0.714
##     cog_e             0.971    0.050   19.563    0.000    0.711    0.711
##     w_control         0.978    0.051   19.198    0.000    0.687    0.687
##     cue               1.046    0.053   19.606    0.000    0.703    0.703
##     affect            0.895    0.048   18.560    0.000    0.705    0.705
##     attach            0.903    0.048   18.742    0.000    0.683    0.683
##     social            0.958    0.051   18.909    0.000    0.721    0.721
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   pdm ~~                                                                
##     sdm               0.074    0.005   15.044    0.000    0.482    0.482
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.696    0.016   42.310    0.000    0.696    0.700
##    .auto2             0.703    0.016   42.653    0.000    0.703    0.715
##    .auto3             0.724    0.017   41.492    0.000    0.724    0.721
##    .auto4             0.730    0.018   41.509    0.000    0.730    0.722
##    .loc1              0.730    0.017   42.859    0.000    0.730    0.713
##    .loc2              0.724    0.017   43.490    0.000    0.724    0.736
##    .loc3              0.704    0.017   42.136    0.000    0.704    0.715
##    .loc4              0.732    0.017   43.079    0.000    0.732    0.728
##    .tol1              0.724    0.017   42.699    0.000    0.724    0.707
##    .tol2              0.739    0.017   43.699    0.000    0.739    0.731
##    .tol3              0.707    0.017   41.720    0.000    0.707    0.700
##    .tol4              0.715    0.017   42.646    0.000    0.715    0.699
##    .craving1          0.745    0.017   43.901    0.000    0.745    0.744
##    .craving2          0.694    0.016   43.112    0.000    0.694    0.718
##    .craving3          0.699    0.017   42.085    0.000    0.699    0.704
##    .craving4          0.749    0.017   44.787    0.000    0.749    0.750
##    .taste1            0.741    0.018   40.350    0.000    0.741    0.713
##    .taste2            0.704    0.018   39.096    0.000    0.704    0.696
##    .taste3            0.708    0.017   40.790    0.000    0.708    0.713
##    .cog_e1            0.700    0.018   39.692    0.000    0.700    0.712
##    .cog_e2            0.748    0.019   39.822    0.000    0.748    0.718
##    .cog_e3            0.747    0.019   40.305    0.000    0.747    0.723
##    .w_control1        0.729    0.019   38.938    0.000    0.729    0.703
##    .w_control2        0.705    0.018   38.469    0.000    0.705    0.676
##    .w_control3        0.736    0.018   40.306    0.000    0.736    0.718
##    .cue1              0.731    0.019   38.991    0.000    0.731    0.685
##    .cue2              0.714    0.018   39.806    0.000    0.714    0.706
##    .cue3              0.727    0.019   39.263    0.000    0.727    0.681
##    .affect1           0.703    0.018   39.750    0.000    0.703    0.742
##    .affect2           0.698    0.018   38.479    0.000    0.698    0.712
##    .affect3           0.763    0.018   41.496    0.000    0.763    0.753
##    .attach1           0.719    0.018   41.041    0.000    0.719    0.730
##    .attach2           0.714    0.019   37.889    0.000    0.714    0.692
##    .attach3           0.729    0.018   40.272    0.000    0.729    0.735
##    .social1           0.723    0.018   40.428    0.000    0.723    0.730
##    .social2           0.711    0.018   39.444    0.000    0.711    0.724
##    .social3           0.741    0.018   41.423    0.000    0.741    0.740
##    .auto              0.143    0.011   13.026    0.000    0.479    0.479
##    .loc               0.129    0.010   12.490    0.000    0.440    0.440
##    .tol               0.131    0.010   12.521    0.000    0.434    0.434
##    .craving           0.103    0.009   11.340    0.000    0.402    0.402
##    .taste             0.146    0.012   12.514    0.000    0.490    0.490
##    .cog_e             0.140    0.011   12.301    0.000    0.495    0.495
##    .w_control         0.163    0.013   12.966    0.000    0.528    0.528
##    .cue               0.170    0.013   12.931    0.000    0.505    0.505
##    .affect            0.123    0.010   11.857    0.000    0.503    0.503
##    .attach            0.142    0.011   12.513    0.000    0.533    0.533
##    .social            0.129    0.011   11.999    0.000    0.480    0.480
##     pdm               0.156    0.011   14.017    0.000    1.000    1.000
##     sdm               0.152    0.011   13.277    0.000    1.000    1.000
#Based on ordinal variables:
items <- c("auto1", "auto2", "auto3", "auto4",
           "loc1", "loc2", "loc3", "loc4",
           "tol1", "tol2", "tol3", "tol4",
           "craving1", "craving2", "craving3", "craving4",
           "taste1", "taste2", "taste3",
           "cog_e1", "cog_e2", "cog_e3",
           "w_control1", "w_control2", "w_control3",
           "cue1", "cue2", "cue3",
           "affect1", "affect2", "affect3",
           "attach1", "attach2", "attach3",
           "social1", "social2", "social3"
           )

#Model 1: 1-factor solution
ord_mod1 <- 'f =~ auto1 + auto2 + auto3 + auto4 + 
                  loc1 + loc2 + loc3 + loc4 + 
                  tol1 + tol2 + tol3 + tol4 + 
                  craving1 + craving2 + craving3 + craving4 +
                  taste1 + taste2 + taste3 +
                  cog_e1 + cog_e2 + cog_e3 +
                  w_control1 + w_control2 + w_control3 +
                  cue1 + cue2 + cue3 + 
                  affect1 + affect2 + affect3 + 
                  attach1 + attach2 + attach3 +
                  social1 + social2 +social3
                  '
ord_mod1_fit <- cfa(ord_mod1, 
                    data = data_cleaned, 
                    estimator = "WLSMV", 
                    ordered = items
                   )
summary(ord_mod1_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 29 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       259
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              13988.601   14539.247
##   Degrees of freedom                                629         629
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   0.969
##   Shift parameter                                           108.836
##     simple second-order correction                                 
## 
## Model Test Baseline Model:
## 
##   Test statistic                             69804.877   42644.851
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.647
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.807       0.669
##   Tucker-Lewis Index (TLI)                       0.795       0.649
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.605
##   Robust Tucker-Lewis Index (TLI)                            0.582
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.062       0.064
##   90 Percent confidence interval - lower         0.061       0.063
##   90 Percent confidence interval - upper         0.063       0.065
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.058
##   90 Percent confidence interval - lower                     0.057
##   90 Percent confidence interval - upper                     0.059
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.062       0.062
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   f =~                                                                  
##     auto1             1.000                               0.370    0.370
##     auto2             0.948    0.045   21.057    0.000    0.351    0.351
##     auto3             0.987    0.047   21.161    0.000    0.365    0.365
##     auto4             1.009    0.046   22.043    0.000    0.373    0.373
##     loc1              0.993    0.049   20.184    0.000    0.367    0.367
##     loc2              0.942    0.048   19.683    0.000    0.349    0.349
##     loc3              0.965    0.050   19.461    0.000    0.357    0.357
##     loc4              0.974    0.050   19.526    0.000    0.361    0.361
##     tol1              0.998    0.048   20.611    0.000    0.370    0.370
##     tol2              0.975    0.048   20.377    0.000    0.361    0.361
##     tol3              1.020    0.049   20.719    0.000    0.378    0.378
##     tol4              1.000    0.049   20.326    0.000    0.370    0.370
##     craving1          0.957    0.048   19.794    0.000    0.354    0.354
##     craving2          1.043    0.051   20.607    0.000    0.386    0.386
##     craving3          0.994    0.049   20.151    0.000    0.368    0.368
##     craving4          0.919    0.048   19.265    0.000    0.340    0.340
##     taste1            0.989    0.051   19.456    0.000    0.366    0.366
##     taste2            1.019    0.052   19.760    0.000    0.377    0.377
##     taste3            0.993    0.051   19.508    0.000    0.368    0.368
##     cog_e1            0.992    0.051   19.328    0.000    0.367    0.367
##     cog_e2            0.955    0.051   18.675    0.000    0.353    0.353
##     cog_e3            0.969    0.051   18.942    0.000    0.359    0.359
##     w_control1        0.972    0.051   19.232    0.000    0.360    0.360
##     w_control2        1.033    0.051   20.343    0.000    0.382    0.382
##     w_control3        0.949    0.051   18.759    0.000    0.351    0.351
##     cue1              1.024    0.052   19.787    0.000    0.379    0.379
##     cue2              0.998    0.050   19.935    0.000    0.369    0.369
##     cue3              1.055    0.053   20.043    0.000    0.390    0.390
##     affect1           0.951    0.049   19.257    0.000    0.352    0.352
##     affect2           0.958    0.050   19.288    0.000    0.354    0.354
##     affect3           0.885    0.049   18.078    0.000    0.328    0.328
##     attach1           0.939    0.049   19.067    0.000    0.348    0.348
##     attach2           1.009    0.051   19.655    0.000    0.373    0.373
##     attach3           0.909    0.049   18.369    0.000    0.337    0.337
##     social1           0.989    0.052   19.172    0.000    0.366    0.366
##     social2           0.991    0.051   19.367    0.000    0.367    0.367
##     social3           0.951    0.051   18.763    0.000    0.352    0.352
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     auto1|t1         -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     auto1|t2         -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     auto1|t3         -0.629    0.018  -34.456    0.000   -0.629   -0.629
##     auto1|t4          0.433    0.018   24.647    0.000    0.433    0.433
##     auto1|t5          1.456    0.025   57.251    0.000    1.456    1.456
##     auto1|t6          2.634    0.071   37.289    0.000    2.634    2.634
##     auto2|t1         -2.799    0.086  -32.466    0.000   -2.799   -2.799
##     auto2|t2         -1.659    0.029  -57.441    0.000   -1.659   -1.659
##     auto2|t3         -0.595    0.018  -32.855    0.000   -0.595   -0.595
##     auto2|t4          0.457    0.018   25.903    0.000    0.457    0.457
##     auto2|t5          1.499    0.026   57.470    0.000    1.499    1.499
##     auto2|t6          2.520    0.062   40.621    0.000    2.520    2.520
##     auto3|t1         -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     auto3|t2         -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     auto3|t3         -0.627    0.018  -34.378    0.000   -0.627   -0.627
##     auto3|t4          0.422    0.018   24.058    0.000    0.422    0.422
##     auto3|t5          1.494    0.026   57.448    0.000    1.494    1.494
##     auto3|t6          2.469    0.059   42.099    0.000    2.469    2.469
##     auto4|t1         -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     auto4|t2         -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     auto4|t3         -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     auto4|t4          0.442    0.018   25.155    0.000    0.442    0.442
##     auto4|t5          1.457    0.025   57.259    0.000    1.457    1.457
##     auto4|t6          2.459    0.058   42.371    0.000    2.459    2.459
##     loc1|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc1|t2          -1.557    0.027  -57.607    0.000   -1.557   -1.557
##     loc1|t3          -0.532    0.018  -29.790    0.000   -0.532   -0.532
##     loc1|t4           0.488    0.018   27.530    0.000    0.488    0.488
##     loc1|t5           1.531    0.027   57.567    0.000    1.531    1.531
##     loc1|t6           2.531    0.063   40.298    0.000    2.531    2.531
##     loc2|t1          -2.776    0.084  -33.118    0.000   -2.776   -2.776
##     loc2|t2          -1.598    0.028  -57.602    0.000   -1.598   -1.598
##     loc2|t3          -0.538    0.018  -30.055    0.000   -0.538   -0.538
##     loc2|t4           0.496    0.018   27.956    0.000    0.496    0.496
##     loc2|t5           1.554    0.027   57.604    0.000    1.554    1.554
##     loc2|t6           2.649    0.072   36.846    0.000    2.649    2.649
##     loc3|t1          -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     loc3|t2          -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     loc3|t3          -0.549    0.018  -30.611    0.000   -0.549   -0.549
##     loc3|t4           0.495    0.018   27.903    0.000    0.495    0.495
##     loc3|t5           1.521    0.026   57.541    0.000    1.521    1.521
##     loc3|t6           2.579    0.066   38.899    0.000    2.579    2.579
##     loc4|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc4|t2          -1.573    0.027  -57.615    0.000   -1.573   -1.573
##     loc4|t3          -0.530    0.018  -29.684    0.000   -0.530   -0.530
##     loc4|t4           0.502    0.018   28.276    0.000    0.502    0.502
##     loc4|t5           1.573    0.027   57.615    0.000    1.573    1.573
##     loc4|t6           2.459    0.058   42.371    0.000    2.459    2.459
##     tol1|t1          -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     tol1|t2          -1.753    0.031  -56.843    0.000   -1.753   -1.753
##     tol1|t3          -0.701    0.019  -37.734    0.000   -0.701   -0.701
##     tol1|t4           0.321    0.017   18.580    0.000    0.321    0.321
##     tol1|t5           1.371    0.024   56.540    0.000    1.371    1.371
##     tol1|t6           2.317    0.050   46.286    0.000    2.317    2.317
##     tol2|t1          -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     tol2|t2          -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     tol2|t3          -0.739    0.019  -39.381    0.000   -0.739   -0.739
##     tol2|t4           0.295    0.017   17.098    0.000    0.295    0.295
##     tol2|t5           1.360    0.024   56.426    0.000    1.360    1.360
##     tol2|t6           2.382    0.053   44.529    0.000    2.382    2.382
##     tol3|t1          -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     tol3|t2          -1.758    0.031  -56.806    0.000   -1.758   -1.758
##     tol3|t3          -0.728    0.019  -38.919    0.000   -0.728   -0.728
##     tol3|t4           0.343    0.017   19.791    0.000    0.343    0.343
##     tol3|t5           1.353    0.024   56.347    0.000    1.353    1.353
##     tol3|t6           2.330    0.051   45.924    0.000    2.330    2.330
##     tol4|t1          -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     tol4|t2          -1.676    0.029  -57.366    0.000   -1.676   -1.676
##     tol4|t3          -0.726    0.019  -38.816    0.000   -0.726   -0.726
##     tol4|t4           0.333    0.017   19.226    0.000    0.333    0.333
##     tol4|t5           1.362    0.024   56.439    0.000    1.362    1.362
##     tol4|t6           2.423    0.056   43.389    0.000    2.423    2.423
##     craving1|t1      -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     craving1|t2      -1.610    0.028  -57.585    0.000   -1.610   -1.610
##     craving1|t3      -0.569    0.018  -31.616    0.000   -0.569   -0.569
##     craving1|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving1|t5       1.509    0.026   57.506    0.000    1.509    1.509
##     craving1|t6       2.699    0.076   35.400    0.000    2.699    2.699
##     craving2|t1      -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     craving2|t2      -1.634    0.028  -57.529    0.000   -1.634   -1.634
##     craving2|t3      -0.557    0.018  -31.034    0.000   -0.557   -0.557
##     craving2|t4       0.495    0.018   27.903    0.000    0.495    0.495
##     craving2|t5       1.562    0.027   57.611    0.000    1.562    1.562
##     craving2|t6       2.620    0.069   37.714    0.000    2.620    2.620
##     craving3|t1      -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     craving3|t2      -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     craving3|t3      -0.580    0.018  -32.144    0.000   -0.580   -0.580
##     craving3|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving3|t5       1.517    0.026   57.529    0.000    1.517    1.517
##     craving3|t6       2.555    0.064   39.622    0.000    2.555    2.555
##     craving4|t1      -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     craving4|t2      -1.643    0.029  -57.501    0.000   -1.643   -1.643
##     craving4|t3      -0.576    0.018  -31.933    0.000   -0.576   -0.576
##     craving4|t4       0.467    0.018   26.437    0.000    0.467    0.467
##     craving4|t5       1.498    0.026   57.465    0.000    1.498    1.498
##     craving4|t6       2.543    0.064   39.965    0.000    2.543    2.543
##     taste1|t1        -2.469    0.059  -42.099    0.000   -2.469   -2.469
##     taste1|t2        -1.501    0.026  -57.476    0.000   -1.501   -1.501
##     taste1|t3        -0.459    0.018  -26.010    0.000   -0.459   -0.459
##     taste1|t4         0.572    0.018   31.748    0.000    0.572    0.572
##     taste1|t5         1.554    0.027   57.604    0.000    1.554    1.554
##     taste1|t6         2.649    0.072   36.846    0.000    2.649    2.649
##     taste2|t1        -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     taste2|t2        -1.487    0.026  -57.417    0.000   -1.487   -1.487
##     taste2|t3        -0.475    0.018  -26.864    0.000   -0.475   -0.475
##     taste2|t4         0.568    0.018   31.563    0.000    0.568    0.568
##     taste2|t5         1.598    0.028   57.602    0.000    1.598    1.598
##     taste2|t6         2.717    0.078   34.872    0.000    2.717    2.717
##     taste3|t1        -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     taste3|t2        -1.536    0.027  -57.576    0.000   -1.536   -1.536
##     taste3|t3        -0.492    0.018  -27.717    0.000   -0.492   -0.492
##     taste3|t4         0.558    0.018   31.087    0.000    0.558    0.558
##     taste3|t5         1.610    0.028   57.585    0.000    1.610    1.610
##     taste3|t6         2.606    0.068   38.124    0.000    2.606    2.606
##     cog_e1|t1        -3.062    0.122  -25.068    0.000   -3.062   -3.062
##     cog_e1|t2        -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     cog_e1|t3        -0.742    0.019  -39.509    0.000   -0.742   -0.742
##     cog_e1|t4         0.297    0.017   17.233    0.000    0.297    0.297
##     cog_e1|t5         1.371    0.024   56.540    0.000    1.371    1.371
##     cog_e1|t6         2.441    0.057   42.893    0.000    2.441    2.441
##     cog_e2|t1        -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     cog_e2|t2        -1.710    0.030  -57.168    0.000   -1.710   -1.710
##     cog_e2|t3        -0.694    0.019  -37.424    0.000   -0.694   -0.694
##     cog_e2|t4         0.306    0.017   17.718    0.000    0.306    0.306
##     cog_e2|t5         1.360    0.024   56.426    0.000    1.360    1.360
##     cog_e2|t6         2.406    0.055   43.861    0.000    2.406    2.406
##     cog_e3|t1        -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cog_e3|t2        -1.743    0.031  -56.931    0.000   -1.743   -1.743
##     cog_e3|t3        -0.730    0.019  -39.022    0.000   -0.730   -0.730
##     cog_e3|t4         0.318    0.017   18.418    0.000    0.318    0.318
##     cog_e3|t5         1.333    0.024   56.100    0.000    1.333    1.333
##     cog_e3|t6         2.323    0.050   46.107    0.000    2.323    2.323
##     w_control1|t1    -2.432    0.056  -43.144    0.000   -2.432   -2.432
##     w_control1|t2    -1.511    0.026  -57.511    0.000   -1.511   -1.511
##     w_control1|t3    -0.463    0.018  -26.224    0.000   -0.463   -0.463
##     w_control1|t4     0.576    0.018   31.959    0.000    0.576    0.576
##     w_control1|t5     1.560    0.027   57.610    0.000    1.560    1.560
##     w_control1|t6     2.606    0.068   38.124    0.000    2.606    2.606
##     w_control2|t1    -2.489    0.060  -41.533    0.000   -2.489   -2.489
##     w_control2|t2    -1.540    0.027  -57.585    0.000   -1.540   -1.540
##     w_control2|t3    -0.461    0.018  -26.143    0.000   -0.461   -0.461
##     w_control2|t4     0.542    0.018   30.293    0.000    0.542    0.542
##     w_control2|t5     1.552    0.027   57.602    0.000    1.552    1.552
##     w_control2|t6     2.531    0.063   40.298    0.000    2.531    2.531
##     w_control3|t1    -2.520    0.062  -40.621    0.000   -2.520   -2.520
##     w_control3|t2    -1.497    0.026  -57.459    0.000   -1.497   -1.497
##     w_control3|t3    -0.491    0.018  -27.690    0.000   -0.491   -0.491
##     w_control3|t4     0.538    0.018   30.055    0.000    0.538    0.538
##     w_control3|t5     1.595    0.028   57.605    0.000    1.595    1.595
##     w_control3|t6     2.634    0.071   37.289    0.000    2.634    2.634
##     cue1|t1          -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     cue1|t2          -1.582    0.027  -57.614    0.000   -1.582   -1.582
##     cue1|t3          -0.612    0.018  -33.696    0.000   -0.612   -0.612
##     cue1|t4           0.409    0.017   23.361    0.000    0.409    0.409
##     cue1|t5           1.423    0.025   57.025    0.000    1.423    1.423
##     cue1|t6           2.441    0.057   42.893    0.000    2.441    2.441
##     cue2|t1          -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     cue2|t2          -1.677    0.029  -57.357    0.000   -1.677   -1.677
##     cue2|t3          -0.635    0.018  -34.770    0.000   -0.635   -0.635
##     cue2|t4           0.408    0.017   23.308    0.000    0.408    0.408
##     cue2|t5           1.442    0.025   57.166    0.000    1.442    1.442
##     cue2|t6           2.414    0.055   43.628    0.000    2.414    2.414
##     cue3|t1          -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cue3|t2          -1.607    0.028  -57.590    0.000   -1.607   -1.607
##     cue3|t3          -0.596    0.018  -32.934    0.000   -0.596   -0.596
##     cue3|t4           0.395    0.017   22.638    0.000    0.395    0.395
##     cue3|t5           1.407    0.025   56.890    0.000    1.407    1.407
##     cue3|t6           2.469    0.059   42.099    0.000    2.469    2.469
##     affect1|t1       -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     affect1|t2       -1.695    0.030  -57.265    0.000   -1.695   -1.695
##     affect1|t3       -0.653    0.018  -35.580    0.000   -0.653   -0.653
##     affect1|t4        0.433    0.018   24.673    0.000    0.433    0.433
##     affect1|t5        1.517    0.026   57.529    0.000    1.517    1.517
##     affect1|t6        2.634    0.071   37.289    0.000    2.634    2.634
##     affect2|t1       -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     affect2|t2       -1.716    0.030  -57.128    0.000   -1.716   -1.716
##     affect2|t3       -0.659    0.018  -35.867    0.000   -0.659   -0.659
##     affect2|t4        0.401    0.017   22.959    0.000    0.401    0.401
##     affect2|t5        1.468    0.026   57.321    0.000    1.468    1.468
##     affect2|t6        2.520    0.062   40.621    0.000    2.520    2.520
##     affect3|t1       -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     affect3|t2       -1.624    0.028  -57.557    0.000   -1.624   -1.624
##     affect3|t3       -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     affect3|t4        0.403    0.017   23.067    0.000    0.403    0.403
##     affect3|t5        1.481    0.026   57.392    0.000    1.481    1.481
##     affect3|t6        2.509    0.061   40.934    0.000    2.509    2.509
##     attach1|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach1|t2       -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     attach1|t3       -0.554    0.018  -30.876    0.000   -0.554   -0.554
##     attach1|t4        0.487    0.018   27.504    0.000    0.487    0.487
##     attach1|t5        1.530    0.027   57.564    0.000    1.530    1.530
##     attach1|t6        2.665    0.073   36.385    0.000    2.665    2.665
##     attach2|t1       -2.543    0.064  -39.965    0.000   -2.543   -2.543
##     attach2|t2       -1.600    0.028  -57.600    0.000   -1.600   -1.600
##     attach2|t3       -0.584    0.018  -32.355    0.000   -0.584   -0.584
##     attach2|t4        0.469    0.018   26.571    0.000    0.469    0.469
##     attach2|t5        1.472    0.026   57.343    0.000    1.472    1.472
##     attach2|t6        2.469    0.059   42.099    0.000    2.469    2.469
##     attach3|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach3|t2       -1.625    0.028  -57.552    0.000   -1.625   -1.625
##     attach3|t3       -0.562    0.018  -31.246    0.000   -0.562   -0.562
##     attach3|t4        0.503    0.018   28.329    0.000    0.503    0.503
##     attach3|t5        1.515    0.026   57.524    0.000    1.515    1.515
##     attach3|t6        2.555    0.064   39.622    0.000    2.555    2.555
##     social1|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social1|t2       -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     social1|t3       -0.592    0.018  -32.723    0.000   -0.592   -0.592
##     social1|t4        0.449    0.018   25.502    0.000    0.449    0.449
##     social1|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social1|t6        2.649    0.072   36.846    0.000    2.649    2.649
##     social2|t1       -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     social2|t2       -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     social2|t3       -0.617    0.018  -33.906    0.000   -0.617   -0.617
##     social2|t4        0.451    0.018   25.609    0.000    0.451    0.451
##     social2|t5        1.495    0.026   57.453    0.000    1.495    1.495
##     social2|t6        2.567    0.065   39.266    0.000    2.567    2.567
##     social3|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social3|t2       -1.654    0.029  -57.463    0.000   -1.654   -1.654
##     social3|t3       -0.582    0.018  -32.249    0.000   -0.582   -0.582
##     social3|t4        0.454    0.018   25.743    0.000    0.454    0.454
##     social3|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social3|t6        2.499    0.061   41.238    0.000    2.499    2.499
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.863                               0.863    0.863
##    .auto2             0.877                               0.877    0.877
##    .auto3             0.866                               0.866    0.866
##    .auto4             0.861                               0.861    0.861
##    .loc1              0.865                               0.865    0.865
##    .loc2              0.878                               0.878    0.878
##    .loc3              0.872                               0.872    0.872
##    .loc4              0.870                               0.870    0.870
##    .tol1              0.863                               0.863    0.863
##    .tol2              0.870                               0.870    0.870
##    .tol3              0.857                               0.857    0.857
##    .tol4              0.863                               0.863    0.863
##    .craving1          0.875                               0.875    0.875
##    .craving2          0.851                               0.851    0.851
##    .craving3          0.865                               0.865    0.865
##    .craving4          0.884                               0.884    0.884
##    .taste1            0.866                               0.866    0.866
##    .taste2            0.858                               0.858    0.858
##    .taste3            0.865                               0.865    0.865
##    .cog_e1            0.865                               0.865    0.865
##    .cog_e2            0.875                               0.875    0.875
##    .cog_e3            0.871                               0.871    0.871
##    .w_control1        0.871                               0.871    0.871
##    .w_control2        0.854                               0.854    0.854
##    .w_control3        0.877                               0.877    0.877
##    .cue1              0.856                               0.856    0.856
##    .cue2              0.863                               0.863    0.863
##    .cue3              0.848                               0.848    0.848
##    .affect1           0.876                               0.876    0.876
##    .affect2           0.874                               0.874    0.874
##    .affect3           0.893                               0.893    0.893
##    .attach1           0.879                               0.879    0.879
##    .attach2           0.861                               0.861    0.861
##    .attach3           0.887                               0.887    0.887
##    .social1           0.866                               0.866    0.866
##    .social2           0.866                               0.866    0.866
##    .social3           0.876                               0.876    0.876
##     f                 0.137    0.010   13.586    0.000    1.000    1.000
#Model 2: 11-factor solution
ord_mod2 <- '#Primary dependence motives
             auto      =~ auto1 + auto2 + auto3 + auto4
             loc       =~ loc1 + loc2 + loc3 + loc4
             tol       =~ tol1 + tol2 + tol3 + tol4
             craving   =~ craving1 + craving2 + craving3 + craving4
             
             #Secondary dependence motives
             taste     =~ taste1 + taste2 + taste3
             cog_e     =~ cog_e1 + cog_e2 + cog_e3
             w_control =~ w_control1 + w_control2 + w_control3
             cue       =~ cue1 + cue2 + cue3
             affect    =~ affect1 + affect2 + affect3
             attach    =~ attach1 + attach2 + attach3
             social    =~ social1 + social2 +social3
             '
ord_mod2_fit <- cfa(ord_mod2, 
                    data = data_cleaned, 
                    estimator = "WLSMV", 
                    ordered = items
                    )
summary(ord_mod2_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 57 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       314
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               391.724     535.940
##   Degrees of freedom                               574         574
##   P-value (Chi-square)                           1.000       0.871
##   Scaling correction factor                                  0.856
##   Shift parameter                                           78.553
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             69804.877   42644.851
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.647
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.003       1.001
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.002
## 
## 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.000       0.002
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.003
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.011       0.011
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   auto =~                                                               
##     auto1             1.000                               0.568    0.568
##     auto2             0.964    0.038   25.600    0.000    0.547    0.547
##     auto3             0.979    0.039   25.113    0.000    0.556    0.556
##     auto4             0.989    0.038   25.920    0.000    0.562    0.562
##   loc =~                                                                
##     loc1              1.000                               0.561    0.561
##     loc2              0.956    0.038   25.209    0.000    0.536    0.536
##     loc3              0.985    0.038   26.048    0.000    0.553    0.553
##     loc4              0.980    0.038   25.548    0.000    0.550    0.550
##   tol =~                                                                
##     tol1              1.000                               0.563    0.563
##     tol2              0.970    0.038   25.537    0.000    0.546    0.546
##     tol3              1.017    0.039   26.282    0.000    0.573    0.573
##     tol4              1.012    0.039   25.952    0.000    0.570    0.570
##   craving =~                                                            
##     craving1          1.000                               0.530    0.530
##     craving2          1.071    0.042   25.477    0.000    0.567    0.567
##     craving3          1.061    0.043   24.946    0.000    0.562    0.562
##     craving4          0.973    0.040   24.031    0.000    0.515    0.515
##   taste =~                                                              
##     taste1            1.000                               0.560    0.560
##     taste2            1.028    0.043   24.090    0.000    0.576    0.576
##     taste3            0.998    0.041   24.213    0.000    0.559    0.559
##   cog_e =~                                                              
##     cog_e1            1.000                               0.564    0.564
##     cog_e2            0.968    0.042   23.285    0.000    0.546    0.546
##     cog_e3            0.982    0.042   23.228    0.000    0.554    0.554
##   w_control =~                                                          
##     w_control1        1.000                               0.565    0.565
##     w_control2        1.063    0.044   24.350    0.000    0.600    0.600
##     w_control3        0.975    0.041   23.488    0.000    0.550    0.550
##   cue =~                                                                
##     cue1              1.000                               0.580    0.580
##     cue2              0.968    0.038   25.422    0.000    0.561    0.561
##     cue3              1.031    0.041   25.260    0.000    0.598    0.598
##   affect =~                                                             
##     affect1           1.000                               0.541    0.541
##     affect2           1.034    0.046   22.570    0.000    0.559    0.559
##     affect3           0.945    0.043   21.753    0.000    0.511    0.511
##   attach =~                                                             
##     attach1           1.000                               0.544    0.544
##     attach2           1.073    0.047   22.990    0.000    0.584    0.584
##     attach3           0.981    0.044   22.079    0.000    0.533    0.533
##   social =~                                                             
##     social1           1.000                               0.548    0.548
##     social2           1.001    0.044   22.909    0.000    0.548    0.548
##     social3           0.965    0.042   22.801    0.000    0.528    0.528
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   auto ~~                                                               
##     loc               0.172    0.009   19.435    0.000    0.541    0.541
##     tol               0.171    0.009   19.285    0.000    0.534    0.534
##     craving           0.168    0.009   19.139    0.000    0.559    0.559
##     taste             0.083    0.008   10.551    0.000    0.261    0.261
##     cog_e             0.074    0.008    9.452    0.000    0.230    0.230
##     w_control         0.079    0.008   10.088    0.000    0.245    0.245
##     cue               0.092    0.008   11.110    0.000    0.280    0.280
##     affect            0.080    0.008   10.245    0.000    0.260    0.260
##     attach            0.080    0.008   10.332    0.000    0.258    0.258
##     social            0.084    0.008   10.763    0.000    0.270    0.270
##   loc ~~                                                                
##     tol               0.181    0.009   20.135    0.000    0.573    0.573
##     craving           0.172    0.009   19.511    0.000    0.578    0.578
##     taste             0.074    0.008    9.703    0.000    0.235    0.235
##     cog_e             0.081    0.008   10.236    0.000    0.256    0.256
##     w_control         0.071    0.008    9.399    0.000    0.225    0.225
##     cue               0.079    0.008    9.894    0.000    0.242    0.242
##     affect            0.076    0.008   10.121    0.000    0.252    0.252
##     attach            0.076    0.008    9.948    0.000    0.249    0.249
##     social            0.079    0.008   10.072    0.000    0.256    0.256
##   tol ~~                                                                
##     craving           0.174    0.009   19.905    0.000    0.583    0.583
##     taste             0.079    0.008   10.160    0.000    0.251    0.251
##     cog_e             0.080    0.008   10.373    0.000    0.252    0.252
##     w_control         0.081    0.008   10.625    0.000    0.255    0.255
##     cue               0.074    0.008    9.525    0.000    0.225    0.225
##     affect            0.075    0.008    9.863    0.000    0.246    0.246
##     attach            0.075    0.008    9.904    0.000    0.245    0.245
##     social            0.089    0.008   11.288    0.000    0.289    0.289
##   craving ~~                                                            
##     taste             0.080    0.007   10.806    0.000    0.271    0.271
##     cog_e             0.077    0.008   10.198    0.000    0.258    0.258
##     w_control         0.074    0.007   10.054    0.000    0.248    0.248
##     cue               0.080    0.008   10.331    0.000    0.260    0.260
##     affect            0.073    0.007    9.908    0.000    0.254    0.254
##     attach            0.077    0.007   10.490    0.000    0.269    0.269
##     social            0.081    0.008   10.724    0.000    0.280    0.280
##   taste ~~                                                              
##     cog_e             0.164    0.009   17.488    0.000    0.519    0.519
##     w_control         0.152    0.009   16.619    0.000    0.481    0.481
##     cue               0.163    0.009   17.781    0.000    0.502    0.502
##     affect            0.153    0.009   16.658    0.000    0.506    0.506
##     attach            0.146    0.009   16.286    0.000    0.479    0.479
##     social            0.160    0.009   17.014    0.000    0.523    0.523
##   cog_e ~~                                                              
##     w_control         0.158    0.009   17.151    0.000    0.497    0.497
##     cue               0.160    0.009   17.226    0.000    0.490    0.490
##     affect            0.151    0.009   16.223    0.000    0.495    0.495
##     attach            0.151    0.009   16.522    0.000    0.492    0.492
##     social            0.158    0.009   16.895    0.000    0.512    0.512
##   w_control ~~                                                          
##     cue               0.158    0.009   16.947    0.000    0.483    0.483
##     affect            0.153    0.009   16.524    0.000    0.501    0.501
##     attach            0.149    0.009   16.404    0.000    0.486    0.486
##     social            0.145    0.009   15.845    0.000    0.470    0.470
##   cue ~~                                                                
##     affect            0.160    0.009   16.938    0.000    0.509    0.509
##     attach            0.150    0.009   16.299    0.000    0.475    0.475
##     social            0.163    0.009   17.489    0.000    0.514    0.514
##   affect ~~                                                             
##     attach            0.135    0.009   15.447    0.000    0.459    0.459
##     social            0.149    0.009   16.085    0.000    0.503    0.503
##   attach ~~                                                             
##     social            0.149    0.009   16.409    0.000    0.499    0.499
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     auto1|t1         -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     auto1|t2         -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     auto1|t3         -0.629    0.018  -34.456    0.000   -0.629   -0.629
##     auto1|t4          0.433    0.018   24.647    0.000    0.433    0.433
##     auto1|t5          1.456    0.025   57.251    0.000    1.456    1.456
##     auto1|t6          2.634    0.071   37.289    0.000    2.634    2.634
##     auto2|t1         -2.799    0.086  -32.466    0.000   -2.799   -2.799
##     auto2|t2         -1.659    0.029  -57.441    0.000   -1.659   -1.659
##     auto2|t3         -0.595    0.018  -32.855    0.000   -0.595   -0.595
##     auto2|t4          0.457    0.018   25.903    0.000    0.457    0.457
##     auto2|t5          1.499    0.026   57.470    0.000    1.499    1.499
##     auto2|t6          2.520    0.062   40.621    0.000    2.520    2.520
##     auto3|t1         -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     auto3|t2         -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     auto3|t3         -0.627    0.018  -34.378    0.000   -0.627   -0.627
##     auto3|t4          0.422    0.018   24.058    0.000    0.422    0.422
##     auto3|t5          1.494    0.026   57.448    0.000    1.494    1.494
##     auto3|t6          2.469    0.059   42.099    0.000    2.469    2.469
##     auto4|t1         -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     auto4|t2         -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     auto4|t3         -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     auto4|t4          0.442    0.018   25.155    0.000    0.442    0.442
##     auto4|t5          1.457    0.025   57.259    0.000    1.457    1.457
##     auto4|t6          2.459    0.058   42.371    0.000    2.459    2.459
##     loc1|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc1|t2          -1.557    0.027  -57.607    0.000   -1.557   -1.557
##     loc1|t3          -0.532    0.018  -29.790    0.000   -0.532   -0.532
##     loc1|t4           0.488    0.018   27.530    0.000    0.488    0.488
##     loc1|t5           1.531    0.027   57.567    0.000    1.531    1.531
##     loc1|t6           2.531    0.063   40.298    0.000    2.531    2.531
##     loc2|t1          -2.776    0.084  -33.118    0.000   -2.776   -2.776
##     loc2|t2          -1.598    0.028  -57.602    0.000   -1.598   -1.598
##     loc2|t3          -0.538    0.018  -30.055    0.000   -0.538   -0.538
##     loc2|t4           0.496    0.018   27.956    0.000    0.496    0.496
##     loc2|t5           1.554    0.027   57.604    0.000    1.554    1.554
##     loc2|t6           2.649    0.072   36.846    0.000    2.649    2.649
##     loc3|t1          -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     loc3|t2          -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     loc3|t3          -0.549    0.018  -30.611    0.000   -0.549   -0.549
##     loc3|t4           0.495    0.018   27.903    0.000    0.495    0.495
##     loc3|t5           1.521    0.026   57.541    0.000    1.521    1.521
##     loc3|t6           2.579    0.066   38.899    0.000    2.579    2.579
##     loc4|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc4|t2          -1.573    0.027  -57.615    0.000   -1.573   -1.573
##     loc4|t3          -0.530    0.018  -29.684    0.000   -0.530   -0.530
##     loc4|t4           0.502    0.018   28.276    0.000    0.502    0.502
##     loc4|t5           1.573    0.027   57.615    0.000    1.573    1.573
##     loc4|t6           2.459    0.058   42.371    0.000    2.459    2.459
##     tol1|t1          -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     tol1|t2          -1.753    0.031  -56.843    0.000   -1.753   -1.753
##     tol1|t3          -0.701    0.019  -37.734    0.000   -0.701   -0.701
##     tol1|t4           0.321    0.017   18.580    0.000    0.321    0.321
##     tol1|t5           1.371    0.024   56.540    0.000    1.371    1.371
##     tol1|t6           2.317    0.050   46.286    0.000    2.317    2.317
##     tol2|t1          -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     tol2|t2          -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     tol2|t3          -0.739    0.019  -39.381    0.000   -0.739   -0.739
##     tol2|t4           0.295    0.017   17.098    0.000    0.295    0.295
##     tol2|t5           1.360    0.024   56.426    0.000    1.360    1.360
##     tol2|t6           2.382    0.053   44.529    0.000    2.382    2.382
##     tol3|t1          -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     tol3|t2          -1.758    0.031  -56.806    0.000   -1.758   -1.758
##     tol3|t3          -0.728    0.019  -38.919    0.000   -0.728   -0.728
##     tol3|t4           0.343    0.017   19.791    0.000    0.343    0.343
##     tol3|t5           1.353    0.024   56.347    0.000    1.353    1.353
##     tol3|t6           2.330    0.051   45.924    0.000    2.330    2.330
##     tol4|t1          -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     tol4|t2          -1.676    0.029  -57.366    0.000   -1.676   -1.676
##     tol4|t3          -0.726    0.019  -38.816    0.000   -0.726   -0.726
##     tol4|t4           0.333    0.017   19.226    0.000    0.333    0.333
##     tol4|t5           1.362    0.024   56.439    0.000    1.362    1.362
##     tol4|t6           2.423    0.056   43.389    0.000    2.423    2.423
##     craving1|t1      -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     craving1|t2      -1.610    0.028  -57.585    0.000   -1.610   -1.610
##     craving1|t3      -0.569    0.018  -31.616    0.000   -0.569   -0.569
##     craving1|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving1|t5       1.509    0.026   57.506    0.000    1.509    1.509
##     craving1|t6       2.699    0.076   35.400    0.000    2.699    2.699
##     craving2|t1      -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     craving2|t2      -1.634    0.028  -57.529    0.000   -1.634   -1.634
##     craving2|t3      -0.557    0.018  -31.034    0.000   -0.557   -0.557
##     craving2|t4       0.495    0.018   27.903    0.000    0.495    0.495
##     craving2|t5       1.562    0.027   57.611    0.000    1.562    1.562
##     craving2|t6       2.620    0.069   37.714    0.000    2.620    2.620
##     craving3|t1      -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     craving3|t2      -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     craving3|t3      -0.580    0.018  -32.144    0.000   -0.580   -0.580
##     craving3|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving3|t5       1.517    0.026   57.529    0.000    1.517    1.517
##     craving3|t6       2.555    0.064   39.622    0.000    2.555    2.555
##     craving4|t1      -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     craving4|t2      -1.643    0.029  -57.501    0.000   -1.643   -1.643
##     craving4|t3      -0.576    0.018  -31.933    0.000   -0.576   -0.576
##     craving4|t4       0.467    0.018   26.437    0.000    0.467    0.467
##     craving4|t5       1.498    0.026   57.465    0.000    1.498    1.498
##     craving4|t6       2.543    0.064   39.965    0.000    2.543    2.543
##     taste1|t1        -2.469    0.059  -42.099    0.000   -2.469   -2.469
##     taste1|t2        -1.501    0.026  -57.476    0.000   -1.501   -1.501
##     taste1|t3        -0.459    0.018  -26.010    0.000   -0.459   -0.459
##     taste1|t4         0.572    0.018   31.748    0.000    0.572    0.572
##     taste1|t5         1.554    0.027   57.604    0.000    1.554    1.554
##     taste1|t6         2.649    0.072   36.846    0.000    2.649    2.649
##     taste2|t1        -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     taste2|t2        -1.487    0.026  -57.417    0.000   -1.487   -1.487
##     taste2|t3        -0.475    0.018  -26.864    0.000   -0.475   -0.475
##     taste2|t4         0.568    0.018   31.563    0.000    0.568    0.568
##     taste2|t5         1.598    0.028   57.602    0.000    1.598    1.598
##     taste2|t6         2.717    0.078   34.872    0.000    2.717    2.717
##     taste3|t1        -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     taste3|t2        -1.536    0.027  -57.576    0.000   -1.536   -1.536
##     taste3|t3        -0.492    0.018  -27.717    0.000   -0.492   -0.492
##     taste3|t4         0.558    0.018   31.087    0.000    0.558    0.558
##     taste3|t5         1.610    0.028   57.585    0.000    1.610    1.610
##     taste3|t6         2.606    0.068   38.124    0.000    2.606    2.606
##     cog_e1|t1        -3.062    0.122  -25.068    0.000   -3.062   -3.062
##     cog_e1|t2        -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     cog_e1|t3        -0.742    0.019  -39.509    0.000   -0.742   -0.742
##     cog_e1|t4         0.297    0.017   17.233    0.000    0.297    0.297
##     cog_e1|t5         1.371    0.024   56.540    0.000    1.371    1.371
##     cog_e1|t6         2.441    0.057   42.893    0.000    2.441    2.441
##     cog_e2|t1        -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     cog_e2|t2        -1.710    0.030  -57.168    0.000   -1.710   -1.710
##     cog_e2|t3        -0.694    0.019  -37.424    0.000   -0.694   -0.694
##     cog_e2|t4         0.306    0.017   17.718    0.000    0.306    0.306
##     cog_e2|t5         1.360    0.024   56.426    0.000    1.360    1.360
##     cog_e2|t6         2.406    0.055   43.861    0.000    2.406    2.406
##     cog_e3|t1        -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cog_e3|t2        -1.743    0.031  -56.931    0.000   -1.743   -1.743
##     cog_e3|t3        -0.730    0.019  -39.022    0.000   -0.730   -0.730
##     cog_e3|t4         0.318    0.017   18.418    0.000    0.318    0.318
##     cog_e3|t5         1.333    0.024   56.100    0.000    1.333    1.333
##     cog_e3|t6         2.323    0.050   46.107    0.000    2.323    2.323
##     w_control1|t1    -2.432    0.056  -43.144    0.000   -2.432   -2.432
##     w_control1|t2    -1.511    0.026  -57.511    0.000   -1.511   -1.511
##     w_control1|t3    -0.463    0.018  -26.224    0.000   -0.463   -0.463
##     w_control1|t4     0.576    0.018   31.959    0.000    0.576    0.576
##     w_control1|t5     1.560    0.027   57.610    0.000    1.560    1.560
##     w_control1|t6     2.606    0.068   38.124    0.000    2.606    2.606
##     w_control2|t1    -2.489    0.060  -41.533    0.000   -2.489   -2.489
##     w_control2|t2    -1.540    0.027  -57.585    0.000   -1.540   -1.540
##     w_control2|t3    -0.461    0.018  -26.143    0.000   -0.461   -0.461
##     w_control2|t4     0.542    0.018   30.293    0.000    0.542    0.542
##     w_control2|t5     1.552    0.027   57.602    0.000    1.552    1.552
##     w_control2|t6     2.531    0.063   40.298    0.000    2.531    2.531
##     w_control3|t1    -2.520    0.062  -40.621    0.000   -2.520   -2.520
##     w_control3|t2    -1.497    0.026  -57.459    0.000   -1.497   -1.497
##     w_control3|t3    -0.491    0.018  -27.690    0.000   -0.491   -0.491
##     w_control3|t4     0.538    0.018   30.055    0.000    0.538    0.538
##     w_control3|t5     1.595    0.028   57.605    0.000    1.595    1.595
##     w_control3|t6     2.634    0.071   37.289    0.000    2.634    2.634
##     cue1|t1          -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     cue1|t2          -1.582    0.027  -57.614    0.000   -1.582   -1.582
##     cue1|t3          -0.612    0.018  -33.696    0.000   -0.612   -0.612
##     cue1|t4           0.409    0.017   23.361    0.000    0.409    0.409
##     cue1|t5           1.423    0.025   57.025    0.000    1.423    1.423
##     cue1|t6           2.441    0.057   42.893    0.000    2.441    2.441
##     cue2|t1          -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     cue2|t2          -1.677    0.029  -57.357    0.000   -1.677   -1.677
##     cue2|t3          -0.635    0.018  -34.770    0.000   -0.635   -0.635
##     cue2|t4           0.408    0.017   23.308    0.000    0.408    0.408
##     cue2|t5           1.442    0.025   57.166    0.000    1.442    1.442
##     cue2|t6           2.414    0.055   43.628    0.000    2.414    2.414
##     cue3|t1          -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cue3|t2          -1.607    0.028  -57.590    0.000   -1.607   -1.607
##     cue3|t3          -0.596    0.018  -32.934    0.000   -0.596   -0.596
##     cue3|t4           0.395    0.017   22.638    0.000    0.395    0.395
##     cue3|t5           1.407    0.025   56.890    0.000    1.407    1.407
##     cue3|t6           2.469    0.059   42.099    0.000    2.469    2.469
##     affect1|t1       -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     affect1|t2       -1.695    0.030  -57.265    0.000   -1.695   -1.695
##     affect1|t3       -0.653    0.018  -35.580    0.000   -0.653   -0.653
##     affect1|t4        0.433    0.018   24.673    0.000    0.433    0.433
##     affect1|t5        1.517    0.026   57.529    0.000    1.517    1.517
##     affect1|t6        2.634    0.071   37.289    0.000    2.634    2.634
##     affect2|t1       -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     affect2|t2       -1.716    0.030  -57.128    0.000   -1.716   -1.716
##     affect2|t3       -0.659    0.018  -35.867    0.000   -0.659   -0.659
##     affect2|t4        0.401    0.017   22.959    0.000    0.401    0.401
##     affect2|t5        1.468    0.026   57.321    0.000    1.468    1.468
##     affect2|t6        2.520    0.062   40.621    0.000    2.520    2.520
##     affect3|t1       -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     affect3|t2       -1.624    0.028  -57.557    0.000   -1.624   -1.624
##     affect3|t3       -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     affect3|t4        0.403    0.017   23.067    0.000    0.403    0.403
##     affect3|t5        1.481    0.026   57.392    0.000    1.481    1.481
##     affect3|t6        2.509    0.061   40.934    0.000    2.509    2.509
##     attach1|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach1|t2       -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     attach1|t3       -0.554    0.018  -30.876    0.000   -0.554   -0.554
##     attach1|t4        0.487    0.018   27.504    0.000    0.487    0.487
##     attach1|t5        1.530    0.027   57.564    0.000    1.530    1.530
##     attach1|t6        2.665    0.073   36.385    0.000    2.665    2.665
##     attach2|t1       -2.543    0.064  -39.965    0.000   -2.543   -2.543
##     attach2|t2       -1.600    0.028  -57.600    0.000   -1.600   -1.600
##     attach2|t3       -0.584    0.018  -32.355    0.000   -0.584   -0.584
##     attach2|t4        0.469    0.018   26.571    0.000    0.469    0.469
##     attach2|t5        1.472    0.026   57.343    0.000    1.472    1.472
##     attach2|t6        2.469    0.059   42.099    0.000    2.469    2.469
##     attach3|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach3|t2       -1.625    0.028  -57.552    0.000   -1.625   -1.625
##     attach3|t3       -0.562    0.018  -31.246    0.000   -0.562   -0.562
##     attach3|t4        0.503    0.018   28.329    0.000    0.503    0.503
##     attach3|t5        1.515    0.026   57.524    0.000    1.515    1.515
##     attach3|t6        2.555    0.064   39.622    0.000    2.555    2.555
##     social1|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social1|t2       -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     social1|t3       -0.592    0.018  -32.723    0.000   -0.592   -0.592
##     social1|t4        0.449    0.018   25.502    0.000    0.449    0.449
##     social1|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social1|t6        2.649    0.072   36.846    0.000    2.649    2.649
##     social2|t1       -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     social2|t2       -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     social2|t3       -0.617    0.018  -33.906    0.000   -0.617   -0.617
##     social2|t4        0.451    0.018   25.609    0.000    0.451    0.451
##     social2|t5        1.495    0.026   57.453    0.000    1.495    1.495
##     social2|t6        2.567    0.065   39.266    0.000    2.567    2.567
##     social3|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social3|t2       -1.654    0.029  -57.463    0.000   -1.654   -1.654
##     social3|t3       -0.582    0.018  -32.249    0.000   -0.582   -0.582
##     social3|t4        0.454    0.018   25.743    0.000    0.454    0.454
##     social3|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social3|t6        2.499    0.061   41.238    0.000    2.499    2.499
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.678                               0.678    0.678
##    .auto2             0.700                               0.700    0.700
##    .auto3             0.691                               0.691    0.691
##    .auto4             0.685                               0.685    0.685
##    .loc1              0.685                               0.685    0.685
##    .loc2              0.713                               0.713    0.713
##    .loc3              0.695                               0.695    0.695
##    .loc4              0.698                               0.698    0.698
##    .tol1              0.683                               0.683    0.683
##    .tol2              0.702                               0.702    0.702
##    .tol3              0.672                               0.672    0.672
##    .tol4              0.675                               0.675    0.675
##    .craving1          0.720                               0.720    0.720
##    .craving2          0.679                               0.679    0.679
##    .craving3          0.684                               0.684    0.684
##    .craving4          0.735                               0.735    0.735
##    .taste1            0.686                               0.686    0.686
##    .taste2            0.668                               0.668    0.668
##    .taste3            0.687                               0.687    0.687
##    .cog_e1            0.682                               0.682    0.682
##    .cog_e2            0.702                               0.702    0.702
##    .cog_e3            0.693                               0.693    0.693
##    .w_control1        0.681                               0.681    0.681
##    .w_control2        0.640                               0.640    0.640
##    .w_control3        0.697                               0.697    0.697
##    .cue1              0.664                               0.664    0.664
##    .cue2              0.685                               0.685    0.685
##    .cue3              0.642                               0.642    0.642
##    .affect1           0.708                               0.708    0.708
##    .affect2           0.687                               0.687    0.687
##    .affect3           0.739                               0.739    0.739
##    .attach1           0.704                               0.704    0.704
##    .attach2           0.659                               0.659    0.659
##    .attach3           0.716                               0.716    0.716
##    .social1           0.700                               0.700    0.700
##    .social2           0.699                               0.699    0.699
##    .social3           0.721                               0.721    0.721
##     auto              0.322    0.017   18.821    0.000    1.000    1.000
##     loc               0.315    0.017   18.981    0.000    1.000    1.000
##     tol               0.317    0.017   18.781    0.000    1.000    1.000
##     craving           0.280    0.016   17.307    0.000    1.000    1.000
##     taste             0.314    0.018   17.641    0.000    1.000    1.000
##     cog_e             0.318    0.018   17.585    0.000    1.000    1.000
##     w_control         0.319    0.018   17.679    0.000    1.000    1.000
##     cue               0.336    0.018   18.908    0.000    1.000    1.000
##     affect            0.292    0.018   16.476    0.000    1.000    1.000
##     attach            0.296    0.018   16.426    0.000    1.000    1.000
##     social            0.300    0.018   16.949    0.000    1.000    1.000
#Model 3: 2-factor solution
ord_mod3 <- 'pdm =~ auto1 + auto2 + auto3 + auto4 + 
                     loc1 + loc2 + loc3 + loc4 + 
                     tol1 + tol2 + tol3 + tol4 + 
                     craving1 + craving2 + craving3 + craving4
                     
              sdm =~ taste1 + taste2 + taste3 +
                     cog_e1 + cog_e2 + cog_e3 +
                     w_control1 + w_control2 + w_control3 +
                     cue1 + cue2 + cue3 + 
                     affect1 + affect2 + affect3 + 
                     attach1 + attach2 + attach3 +
                     social1 + social2 +social3
                     '
ord_mod3_fit <- cfa(ord_mod3, 
                    data = data_cleaned, 
                    estimator = "WLSMV", 
                    ordered = items
                   )
summary(ord_mod3_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 30 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       260
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              4898.764    5024.751
##   Degrees of freedom                               628         628
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.997
##   Shift parameter                                          113.620
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             69804.877   42644.851
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.647
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.938       0.895
##   Tucker-Lewis Index (TLI)                       0.934       0.889
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.806
##   Robust Tucker-Lewis Index (TLI)                            0.794
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.035       0.036
##   90 Percent confidence interval - lower         0.034       0.035
##   90 Percent confidence interval - upper         0.036       0.037
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.041
##   90 Percent confidence interval - lower                     0.040
##   90 Percent confidence interval - upper                     0.042
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.036       0.036
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   pdm =~                                                                
##     auto1             1.000                               0.453    0.453
##     auto2             0.968    0.039   24.911    0.000    0.439    0.439
##     auto3             0.984    0.040   24.444    0.000    0.446    0.446
##     auto4             0.998    0.039   25.329    0.000    0.452    0.452
##     loc1              1.000    0.042   23.894    0.000    0.454    0.454
##     loc2              0.956    0.041   23.413    0.000    0.434    0.434
##     loc3              0.980    0.042   23.390    0.000    0.445    0.445
##     loc4              0.979    0.042   23.142    0.000    0.444    0.444
##     tol1              1.007    0.041   24.446    0.000    0.457    0.457
##     tol2              0.982    0.041   23.834    0.000    0.445    0.445
##     tol3              1.025    0.042   24.202    0.000    0.465    0.465
##     tol4              1.027    0.042   24.270    0.000    0.465    0.465
##     craving1          0.961    0.041   23.316    0.000    0.436    0.436
##     craving2          1.024    0.042   24.092    0.000    0.464    0.464
##     craving3          1.018    0.042   24.103    0.000    0.461    0.461
##     craving4          0.935    0.041   22.800    0.000    0.424    0.424
##   sdm =~                                                                
##     taste1            1.000                               0.422    0.422
##     taste2            1.024    0.042   24.133    0.000    0.432    0.432
##     taste3            0.998    0.041   24.141    0.000    0.421    0.421
##     cog_e1            0.996    0.045   22.044    0.000    0.420    0.420
##     cog_e2            0.961    0.044   21.805    0.000    0.406    0.406
##     cog_e3            0.979    0.044   22.156    0.000    0.413    0.413
##     w_control1        0.983    0.045   21.733    0.000    0.415    0.415
##     w_control2        1.042    0.045   23.305    0.000    0.440    0.440
##     w_control3        0.957    0.045   21.053    0.000    0.404    0.404
##     cue1              1.031    0.046   22.623    0.000    0.435    0.435
##     cue2              0.999    0.045   22.186    0.000    0.421    0.421
##     cue3              1.065    0.047   22.905    0.000    0.450    0.450
##     affect1           0.946    0.044   21.624    0.000    0.399    0.399
##     affect2           0.977    0.045   21.719    0.000    0.412    0.412
##     affect3           0.891    0.044   20.360    0.000    0.376    0.376
##     attach1           0.935    0.043   21.585    0.000    0.394    0.394
##     attach2           1.000    0.044   22.604    0.000    0.422    0.422
##     attach3           0.920    0.044   20.950    0.000    0.388    0.388
##     social1           0.984    0.045   22.072    0.000    0.415    0.415
##     social2           0.981    0.045   21.688    0.000    0.414    0.414
##     social3           0.945    0.043   21.996    0.000    0.399    0.399
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   pdm ~~                                                                
##     sdm               0.081    0.005   16.786    0.000    0.422    0.422
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     auto1|t1         -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     auto1|t2         -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     auto1|t3         -0.629    0.018  -34.456    0.000   -0.629   -0.629
##     auto1|t4          0.433    0.018   24.647    0.000    0.433    0.433
##     auto1|t5          1.456    0.025   57.251    0.000    1.456    1.456
##     auto1|t6          2.634    0.071   37.289    0.000    2.634    2.634
##     auto2|t1         -2.799    0.086  -32.466    0.000   -2.799   -2.799
##     auto2|t2         -1.659    0.029  -57.441    0.000   -1.659   -1.659
##     auto2|t3         -0.595    0.018  -32.855    0.000   -0.595   -0.595
##     auto2|t4          0.457    0.018   25.903    0.000    0.457    0.457
##     auto2|t5          1.499    0.026   57.470    0.000    1.499    1.499
##     auto2|t6          2.520    0.062   40.621    0.000    2.520    2.520
##     auto3|t1         -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     auto3|t2         -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     auto3|t3         -0.627    0.018  -34.378    0.000   -0.627   -0.627
##     auto3|t4          0.422    0.018   24.058    0.000    0.422    0.422
##     auto3|t5          1.494    0.026   57.448    0.000    1.494    1.494
##     auto3|t6          2.469    0.059   42.099    0.000    2.469    2.469
##     auto4|t1         -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     auto4|t2         -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     auto4|t3         -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     auto4|t4          0.442    0.018   25.155    0.000    0.442    0.442
##     auto4|t5          1.457    0.025   57.259    0.000    1.457    1.457
##     auto4|t6          2.459    0.058   42.371    0.000    2.459    2.459
##     loc1|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc1|t2          -1.557    0.027  -57.607    0.000   -1.557   -1.557
##     loc1|t3          -0.532    0.018  -29.790    0.000   -0.532   -0.532
##     loc1|t4           0.488    0.018   27.530    0.000    0.488    0.488
##     loc1|t5           1.531    0.027   57.567    0.000    1.531    1.531
##     loc1|t6           2.531    0.063   40.298    0.000    2.531    2.531
##     loc2|t1          -2.776    0.084  -33.118    0.000   -2.776   -2.776
##     loc2|t2          -1.598    0.028  -57.602    0.000   -1.598   -1.598
##     loc2|t3          -0.538    0.018  -30.055    0.000   -0.538   -0.538
##     loc2|t4           0.496    0.018   27.956    0.000    0.496    0.496
##     loc2|t5           1.554    0.027   57.604    0.000    1.554    1.554
##     loc2|t6           2.649    0.072   36.846    0.000    2.649    2.649
##     loc3|t1          -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     loc3|t2          -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     loc3|t3          -0.549    0.018  -30.611    0.000   -0.549   -0.549
##     loc3|t4           0.495    0.018   27.903    0.000    0.495    0.495
##     loc3|t5           1.521    0.026   57.541    0.000    1.521    1.521
##     loc3|t6           2.579    0.066   38.899    0.000    2.579    2.579
##     loc4|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc4|t2          -1.573    0.027  -57.615    0.000   -1.573   -1.573
##     loc4|t3          -0.530    0.018  -29.684    0.000   -0.530   -0.530
##     loc4|t4           0.502    0.018   28.276    0.000    0.502    0.502
##     loc4|t5           1.573    0.027   57.615    0.000    1.573    1.573
##     loc4|t6           2.459    0.058   42.371    0.000    2.459    2.459
##     tol1|t1          -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     tol1|t2          -1.753    0.031  -56.843    0.000   -1.753   -1.753
##     tol1|t3          -0.701    0.019  -37.734    0.000   -0.701   -0.701
##     tol1|t4           0.321    0.017   18.580    0.000    0.321    0.321
##     tol1|t5           1.371    0.024   56.540    0.000    1.371    1.371
##     tol1|t6           2.317    0.050   46.286    0.000    2.317    2.317
##     tol2|t1          -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     tol2|t2          -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     tol2|t3          -0.739    0.019  -39.381    0.000   -0.739   -0.739
##     tol2|t4           0.295    0.017   17.098    0.000    0.295    0.295
##     tol2|t5           1.360    0.024   56.426    0.000    1.360    1.360
##     tol2|t6           2.382    0.053   44.529    0.000    2.382    2.382
##     tol3|t1          -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     tol3|t2          -1.758    0.031  -56.806    0.000   -1.758   -1.758
##     tol3|t3          -0.728    0.019  -38.919    0.000   -0.728   -0.728
##     tol3|t4           0.343    0.017   19.791    0.000    0.343    0.343
##     tol3|t5           1.353    0.024   56.347    0.000    1.353    1.353
##     tol3|t6           2.330    0.051   45.924    0.000    2.330    2.330
##     tol4|t1          -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     tol4|t2          -1.676    0.029  -57.366    0.000   -1.676   -1.676
##     tol4|t3          -0.726    0.019  -38.816    0.000   -0.726   -0.726
##     tol4|t4           0.333    0.017   19.226    0.000    0.333    0.333
##     tol4|t5           1.362    0.024   56.439    0.000    1.362    1.362
##     tol4|t6           2.423    0.056   43.389    0.000    2.423    2.423
##     craving1|t1      -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     craving1|t2      -1.610    0.028  -57.585    0.000   -1.610   -1.610
##     craving1|t3      -0.569    0.018  -31.616    0.000   -0.569   -0.569
##     craving1|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving1|t5       1.509    0.026   57.506    0.000    1.509    1.509
##     craving1|t6       2.699    0.076   35.400    0.000    2.699    2.699
##     craving2|t1      -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     craving2|t2      -1.634    0.028  -57.529    0.000   -1.634   -1.634
##     craving2|t3      -0.557    0.018  -31.034    0.000   -0.557   -0.557
##     craving2|t4       0.495    0.018   27.903    0.000    0.495    0.495
##     craving2|t5       1.562    0.027   57.611    0.000    1.562    1.562
##     craving2|t6       2.620    0.069   37.714    0.000    2.620    2.620
##     craving3|t1      -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     craving3|t2      -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     craving3|t3      -0.580    0.018  -32.144    0.000   -0.580   -0.580
##     craving3|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving3|t5       1.517    0.026   57.529    0.000    1.517    1.517
##     craving3|t6       2.555    0.064   39.622    0.000    2.555    2.555
##     craving4|t1      -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     craving4|t2      -1.643    0.029  -57.501    0.000   -1.643   -1.643
##     craving4|t3      -0.576    0.018  -31.933    0.000   -0.576   -0.576
##     craving4|t4       0.467    0.018   26.437    0.000    0.467    0.467
##     craving4|t5       1.498    0.026   57.465    0.000    1.498    1.498
##     craving4|t6       2.543    0.064   39.965    0.000    2.543    2.543
##     taste1|t1        -2.469    0.059  -42.099    0.000   -2.469   -2.469
##     taste1|t2        -1.501    0.026  -57.476    0.000   -1.501   -1.501
##     taste1|t3        -0.459    0.018  -26.010    0.000   -0.459   -0.459
##     taste1|t4         0.572    0.018   31.748    0.000    0.572    0.572
##     taste1|t5         1.554    0.027   57.604    0.000    1.554    1.554
##     taste1|t6         2.649    0.072   36.846    0.000    2.649    2.649
##     taste2|t1        -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     taste2|t2        -1.487    0.026  -57.417    0.000   -1.487   -1.487
##     taste2|t3        -0.475    0.018  -26.864    0.000   -0.475   -0.475
##     taste2|t4         0.568    0.018   31.563    0.000    0.568    0.568
##     taste2|t5         1.598    0.028   57.602    0.000    1.598    1.598
##     taste2|t6         2.717    0.078   34.872    0.000    2.717    2.717
##     taste3|t1        -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     taste3|t2        -1.536    0.027  -57.576    0.000   -1.536   -1.536
##     taste3|t3        -0.492    0.018  -27.717    0.000   -0.492   -0.492
##     taste3|t4         0.558    0.018   31.087    0.000    0.558    0.558
##     taste3|t5         1.610    0.028   57.585    0.000    1.610    1.610
##     taste3|t6         2.606    0.068   38.124    0.000    2.606    2.606
##     cog_e1|t1        -3.062    0.122  -25.068    0.000   -3.062   -3.062
##     cog_e1|t2        -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     cog_e1|t3        -0.742    0.019  -39.509    0.000   -0.742   -0.742
##     cog_e1|t4         0.297    0.017   17.233    0.000    0.297    0.297
##     cog_e1|t5         1.371    0.024   56.540    0.000    1.371    1.371
##     cog_e1|t6         2.441    0.057   42.893    0.000    2.441    2.441
##     cog_e2|t1        -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     cog_e2|t2        -1.710    0.030  -57.168    0.000   -1.710   -1.710
##     cog_e2|t3        -0.694    0.019  -37.424    0.000   -0.694   -0.694
##     cog_e2|t4         0.306    0.017   17.718    0.000    0.306    0.306
##     cog_e2|t5         1.360    0.024   56.426    0.000    1.360    1.360
##     cog_e2|t6         2.406    0.055   43.861    0.000    2.406    2.406
##     cog_e3|t1        -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cog_e3|t2        -1.743    0.031  -56.931    0.000   -1.743   -1.743
##     cog_e3|t3        -0.730    0.019  -39.022    0.000   -0.730   -0.730
##     cog_e3|t4         0.318    0.017   18.418    0.000    0.318    0.318
##     cog_e3|t5         1.333    0.024   56.100    0.000    1.333    1.333
##     cog_e3|t6         2.323    0.050   46.107    0.000    2.323    2.323
##     w_control1|t1    -2.432    0.056  -43.144    0.000   -2.432   -2.432
##     w_control1|t2    -1.511    0.026  -57.511    0.000   -1.511   -1.511
##     w_control1|t3    -0.463    0.018  -26.224    0.000   -0.463   -0.463
##     w_control1|t4     0.576    0.018   31.959    0.000    0.576    0.576
##     w_control1|t5     1.560    0.027   57.610    0.000    1.560    1.560
##     w_control1|t6     2.606    0.068   38.124    0.000    2.606    2.606
##     w_control2|t1    -2.489    0.060  -41.533    0.000   -2.489   -2.489
##     w_control2|t2    -1.540    0.027  -57.585    0.000   -1.540   -1.540
##     w_control2|t3    -0.461    0.018  -26.143    0.000   -0.461   -0.461
##     w_control2|t4     0.542    0.018   30.293    0.000    0.542    0.542
##     w_control2|t5     1.552    0.027   57.602    0.000    1.552    1.552
##     w_control2|t6     2.531    0.063   40.298    0.000    2.531    2.531
##     w_control3|t1    -2.520    0.062  -40.621    0.000   -2.520   -2.520
##     w_control3|t2    -1.497    0.026  -57.459    0.000   -1.497   -1.497
##     w_control3|t3    -0.491    0.018  -27.690    0.000   -0.491   -0.491
##     w_control3|t4     0.538    0.018   30.055    0.000    0.538    0.538
##     w_control3|t5     1.595    0.028   57.605    0.000    1.595    1.595
##     w_control3|t6     2.634    0.071   37.289    0.000    2.634    2.634
##     cue1|t1          -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     cue1|t2          -1.582    0.027  -57.614    0.000   -1.582   -1.582
##     cue1|t3          -0.612    0.018  -33.696    0.000   -0.612   -0.612
##     cue1|t4           0.409    0.017   23.361    0.000    0.409    0.409
##     cue1|t5           1.423    0.025   57.025    0.000    1.423    1.423
##     cue1|t6           2.441    0.057   42.893    0.000    2.441    2.441
##     cue2|t1          -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     cue2|t2          -1.677    0.029  -57.357    0.000   -1.677   -1.677
##     cue2|t3          -0.635    0.018  -34.770    0.000   -0.635   -0.635
##     cue2|t4           0.408    0.017   23.308    0.000    0.408    0.408
##     cue2|t5           1.442    0.025   57.166    0.000    1.442    1.442
##     cue2|t6           2.414    0.055   43.628    0.000    2.414    2.414
##     cue3|t1          -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cue3|t2          -1.607    0.028  -57.590    0.000   -1.607   -1.607
##     cue3|t3          -0.596    0.018  -32.934    0.000   -0.596   -0.596
##     cue3|t4           0.395    0.017   22.638    0.000    0.395    0.395
##     cue3|t5           1.407    0.025   56.890    0.000    1.407    1.407
##     cue3|t6           2.469    0.059   42.099    0.000    2.469    2.469
##     affect1|t1       -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     affect1|t2       -1.695    0.030  -57.265    0.000   -1.695   -1.695
##     affect1|t3       -0.653    0.018  -35.580    0.000   -0.653   -0.653
##     affect1|t4        0.433    0.018   24.673    0.000    0.433    0.433
##     affect1|t5        1.517    0.026   57.529    0.000    1.517    1.517
##     affect1|t6        2.634    0.071   37.289    0.000    2.634    2.634
##     affect2|t1       -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     affect2|t2       -1.716    0.030  -57.128    0.000   -1.716   -1.716
##     affect2|t3       -0.659    0.018  -35.867    0.000   -0.659   -0.659
##     affect2|t4        0.401    0.017   22.959    0.000    0.401    0.401
##     affect2|t5        1.468    0.026   57.321    0.000    1.468    1.468
##     affect2|t6        2.520    0.062   40.621    0.000    2.520    2.520
##     affect3|t1       -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     affect3|t2       -1.624    0.028  -57.557    0.000   -1.624   -1.624
##     affect3|t3       -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     affect3|t4        0.403    0.017   23.067    0.000    0.403    0.403
##     affect3|t5        1.481    0.026   57.392    0.000    1.481    1.481
##     affect3|t6        2.509    0.061   40.934    0.000    2.509    2.509
##     attach1|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach1|t2       -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     attach1|t3       -0.554    0.018  -30.876    0.000   -0.554   -0.554
##     attach1|t4        0.487    0.018   27.504    0.000    0.487    0.487
##     attach1|t5        1.530    0.027   57.564    0.000    1.530    1.530
##     attach1|t6        2.665    0.073   36.385    0.000    2.665    2.665
##     attach2|t1       -2.543    0.064  -39.965    0.000   -2.543   -2.543
##     attach2|t2       -1.600    0.028  -57.600    0.000   -1.600   -1.600
##     attach2|t3       -0.584    0.018  -32.355    0.000   -0.584   -0.584
##     attach2|t4        0.469    0.018   26.571    0.000    0.469    0.469
##     attach2|t5        1.472    0.026   57.343    0.000    1.472    1.472
##     attach2|t6        2.469    0.059   42.099    0.000    2.469    2.469
##     attach3|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach3|t2       -1.625    0.028  -57.552    0.000   -1.625   -1.625
##     attach3|t3       -0.562    0.018  -31.246    0.000   -0.562   -0.562
##     attach3|t4        0.503    0.018   28.329    0.000    0.503    0.503
##     attach3|t5        1.515    0.026   57.524    0.000    1.515    1.515
##     attach3|t6        2.555    0.064   39.622    0.000    2.555    2.555
##     social1|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social1|t2       -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     social1|t3       -0.592    0.018  -32.723    0.000   -0.592   -0.592
##     social1|t4        0.449    0.018   25.502    0.000    0.449    0.449
##     social1|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social1|t6        2.649    0.072   36.846    0.000    2.649    2.649
##     social2|t1       -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     social2|t2       -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     social2|t3       -0.617    0.018  -33.906    0.000   -0.617   -0.617
##     social2|t4        0.451    0.018   25.609    0.000    0.451    0.451
##     social2|t5        1.495    0.026   57.453    0.000    1.495    1.495
##     social2|t6        2.567    0.065   39.266    0.000    2.567    2.567
##     social3|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social3|t2       -1.654    0.029  -57.463    0.000   -1.654   -1.654
##     social3|t3       -0.582    0.018  -32.249    0.000   -0.582   -0.582
##     social3|t4        0.454    0.018   25.743    0.000    0.454    0.454
##     social3|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social3|t6        2.499    0.061   41.238    0.000    2.499    2.499
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.794                               0.794    0.794
##    .auto2             0.807                               0.807    0.807
##    .auto3             0.801                               0.801    0.801
##    .auto4             0.795                               0.795    0.795
##    .loc1              0.794                               0.794    0.794
##    .loc2              0.812                               0.812    0.812
##    .loc3              0.802                               0.802    0.802
##    .loc4              0.803                               0.803    0.803
##    .tol1              0.791                               0.791    0.791
##    .tol2              0.802                               0.802    0.802
##    .tol3              0.784                               0.784    0.784
##    .tol4              0.783                               0.783    0.783
##    .craving1          0.810                               0.810    0.810
##    .craving2          0.785                               0.785    0.785
##    .craving3          0.787                               0.787    0.787
##    .craving4          0.820                               0.820    0.820
##    .taste1            0.822                               0.822    0.822
##    .taste2            0.813                               0.813    0.813
##    .taste3            0.823                               0.823    0.823
##    .cog_e1            0.823                               0.823    0.823
##    .cog_e2            0.835                               0.835    0.835
##    .cog_e3            0.829                               0.829    0.829
##    .w_control1        0.828                               0.828    0.828
##    .w_control2        0.807                               0.807    0.807
##    .w_control3        0.837                               0.837    0.837
##    .cue1              0.811                               0.811    0.811
##    .cue2              0.822                               0.822    0.822
##    .cue3              0.798                               0.798    0.798
##    .affect1           0.841                               0.841    0.841
##    .affect2           0.830                               0.830    0.830
##    .affect3           0.858                               0.858    0.858
##    .attach1           0.844                               0.844    0.844
##    .attach2           0.822                               0.822    0.822
##    .attach3           0.849                               0.849    0.849
##    .social1           0.828                               0.828    0.828
##    .social2           0.829                               0.829    0.829
##    .social3           0.841                               0.841    0.841
##     pdm               0.206    0.012   16.506    0.000    1.000    1.000
##     sdm               0.178    0.012   15.369    0.000    1.000    1.000
#Model 4: 2-order solution
ord_mod4 <- '#1st order
             auto      =~ auto1 + auto2 + auto3 + auto4
             loc       =~ loc1 + loc2 + loc3 + loc4
             tol       =~ tol1 + tol2 + tol3 + tol4
             craving   =~ craving1 + craving2 + craving3 + craving4
             taste     =~ taste1 + taste2 + taste3
             cog_e     =~ cog_e1 + cog_e2 + cog_e3
             w_control =~ w_control1 + w_control2 + w_control3
             cue       =~ cue1 + cue2 + cue3
             affect    =~ affect1 + affect2 + affect3
             attach    =~ attach1 + attach2 + attach3
             social    =~ social1 + social2 +social3
             
             #2nd order
             pdm =~ auto + loc + tol + craving
             sdm =~ taste + cog_e + w_control + cue + affect + attach + social
             '
ord_mod4_fit <- cfa(ord_mod4, 
                    data = data_cleaned, 
                    estimator = "WLSMV",
                    ordered = items
                    )
summary(ord_mod4_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 49 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       271
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               437.075     552.564
##   Degrees of freedom                               617         617
##   P-value (Chi-square)                           1.000       0.970
##   Scaling correction factor                                  0.981
##   Shift parameter                                          107.024
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             69804.877   42644.851
##   Degrees of freedom                               666         666
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.647
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.003       1.002
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.002
## 
## 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.000       0.000
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.000
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.002
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.011       0.011
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   auto =~                                                               
##     auto1             1.000                               0.568    0.568
##     auto2             0.965    0.038   25.686    0.000    0.548    0.548
##     auto3             0.979    0.039   25.189    0.000    0.556    0.556
##     auto4             0.988    0.038   25.996    0.000    0.561    0.561
##   loc =~                                                                
##     loc1              1.000                               0.561    0.561
##     loc2              0.955    0.038   25.116    0.000    0.536    0.536
##     loc3              0.985    0.038   25.944    0.000    0.552    0.552
##     loc4              0.981    0.039   25.446    0.000    0.550    0.550
##   tol =~                                                                
##     tol1              1.000                               0.563    0.563
##     tol2              0.970    0.038   25.499    0.000    0.546    0.546
##     tol3              1.017    0.039   26.237    0.000    0.573    0.573
##     tol4              1.012    0.039   25.924    0.000    0.570    0.570
##   craving =~                                                            
##     craving1          1.000                               0.529    0.529
##     craving2          1.071    0.042   25.471    0.000    0.567    0.567
##     craving3          1.062    0.043   24.942    0.000    0.562    0.562
##     craving4          0.973    0.041   24.034    0.000    0.515    0.515
##   taste =~                                                              
##     taste1            1.000                               0.560    0.560
##     taste2            1.028    0.043   24.052    0.000    0.576    0.576
##     taste3            0.999    0.041   24.178    0.000    0.559    0.559
##   cog_e =~                                                              
##     cog_e1            1.000                               0.564    0.564
##     cog_e2            0.968    0.042   23.217    0.000    0.546    0.546
##     cog_e3            0.981    0.042   23.162    0.000    0.554    0.554
##   w_control =~                                                          
##     w_control1        1.000                               0.565    0.565
##     w_control2        1.063    0.044   24.296    0.000    0.600    0.600
##     w_control3        0.975    0.042   23.429    0.000    0.550    0.550
##   cue =~                                                                
##     cue1              1.000                               0.580    0.580
##     cue2              0.968    0.038   25.362    0.000    0.561    0.561
##     cue3              1.032    0.041   25.199    0.000    0.598    0.598
##   affect =~                                                             
##     affect1           1.000                               0.541    0.541
##     affect2           1.034    0.046   22.541    0.000    0.559    0.559
##     affect3           0.945    0.043   21.728    0.000    0.511    0.511
##   attach =~                                                             
##     attach1           1.000                               0.543    0.543
##     attach2           1.074    0.047   23.026    0.000    0.584    0.584
##     attach3           0.981    0.044   22.111    0.000    0.533    0.533
##   social =~                                                             
##     social1           1.000                               0.548    0.548
##     social2           1.001    0.044   22.961    0.000    0.548    0.548
##     social3           0.964    0.042   22.852    0.000    0.528    0.528
##   pdm =~                                                                
##     auto              1.000                               0.731    0.731
##     loc               1.005    0.048   20.862    0.000    0.743    0.743
##     tol               1.016    0.048   21.312    0.000    0.749    0.749
##     craving           0.986    0.048   20.359    0.000    0.773    0.773
##   sdm =~                                                                
##     taste             1.000                               0.713    0.713
##     cog_e             1.002    0.050   20.133    0.000    0.708    0.708
##     w_control         0.970    0.049   19.647    0.000    0.686    0.686
##     cue               1.020    0.050   20.340    0.000    0.702    0.702
##     affect            0.955    0.048   19.795    0.000    0.704    0.704
##     attach            0.935    0.047   19.704    0.000    0.687    0.687
##     social            0.997    0.050   20.003    0.000    0.727    0.727
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   pdm ~~                                                                
##     sdm               0.080    0.005   15.844    0.000    0.482    0.482
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     auto1|t1         -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     auto1|t2         -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     auto1|t3         -0.629    0.018  -34.456    0.000   -0.629   -0.629
##     auto1|t4          0.433    0.018   24.647    0.000    0.433    0.433
##     auto1|t5          1.456    0.025   57.251    0.000    1.456    1.456
##     auto1|t6          2.634    0.071   37.289    0.000    2.634    2.634
##     auto2|t1         -2.799    0.086  -32.466    0.000   -2.799   -2.799
##     auto2|t2         -1.659    0.029  -57.441    0.000   -1.659   -1.659
##     auto2|t3         -0.595    0.018  -32.855    0.000   -0.595   -0.595
##     auto2|t4          0.457    0.018   25.903    0.000    0.457    0.457
##     auto2|t5          1.499    0.026   57.470    0.000    1.499    1.499
##     auto2|t6          2.520    0.062   40.621    0.000    2.520    2.520
##     auto3|t1         -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     auto3|t2         -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     auto3|t3         -0.627    0.018  -34.378    0.000   -0.627   -0.627
##     auto3|t4          0.422    0.018   24.058    0.000    0.422    0.422
##     auto3|t5          1.494    0.026   57.448    0.000    1.494    1.494
##     auto3|t6          2.469    0.059   42.099    0.000    2.469    2.469
##     auto4|t1         -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     auto4|t2         -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     auto4|t3         -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     auto4|t4          0.442    0.018   25.155    0.000    0.442    0.442
##     auto4|t5          1.457    0.025   57.259    0.000    1.457    1.457
##     auto4|t6          2.459    0.058   42.371    0.000    2.459    2.459
##     loc1|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc1|t2          -1.557    0.027  -57.607    0.000   -1.557   -1.557
##     loc1|t3          -0.532    0.018  -29.790    0.000   -0.532   -0.532
##     loc1|t4           0.488    0.018   27.530    0.000    0.488    0.488
##     loc1|t5           1.531    0.027   57.567    0.000    1.531    1.531
##     loc1|t6           2.531    0.063   40.298    0.000    2.531    2.531
##     loc2|t1          -2.776    0.084  -33.118    0.000   -2.776   -2.776
##     loc2|t2          -1.598    0.028  -57.602    0.000   -1.598   -1.598
##     loc2|t3          -0.538    0.018  -30.055    0.000   -0.538   -0.538
##     loc2|t4           0.496    0.018   27.956    0.000    0.496    0.496
##     loc2|t5           1.554    0.027   57.604    0.000    1.554    1.554
##     loc2|t6           2.649    0.072   36.846    0.000    2.649    2.649
##     loc3|t1          -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     loc3|t2          -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     loc3|t3          -0.549    0.018  -30.611    0.000   -0.549   -0.549
##     loc3|t4           0.495    0.018   27.903    0.000    0.495    0.495
##     loc3|t5           1.521    0.026   57.541    0.000    1.521    1.521
##     loc3|t6           2.579    0.066   38.899    0.000    2.579    2.579
##     loc4|t1          -2.681    0.075  -35.903    0.000   -2.681   -2.681
##     loc4|t2          -1.573    0.027  -57.615    0.000   -1.573   -1.573
##     loc4|t3          -0.530    0.018  -29.684    0.000   -0.530   -0.530
##     loc4|t4           0.502    0.018   28.276    0.000    0.502    0.502
##     loc4|t5           1.573    0.027   57.615    0.000    1.573    1.573
##     loc4|t6           2.459    0.058   42.371    0.000    2.459    2.459
##     tol1|t1          -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     tol1|t2          -1.753    0.031  -56.843    0.000   -1.753   -1.753
##     tol1|t3          -0.701    0.019  -37.734    0.000   -0.701   -0.701
##     tol1|t4           0.321    0.017   18.580    0.000    0.321    0.321
##     tol1|t5           1.371    0.024   56.540    0.000    1.371    1.371
##     tol1|t6           2.317    0.050   46.286    0.000    2.317    2.317
##     tol2|t1          -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     tol2|t2          -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     tol2|t3          -0.739    0.019  -39.381    0.000   -0.739   -0.739
##     tol2|t4           0.295    0.017   17.098    0.000    0.295    0.295
##     tol2|t5           1.360    0.024   56.426    0.000    1.360    1.360
##     tol2|t6           2.382    0.053   44.529    0.000    2.382    2.382
##     tol3|t1          -2.755    0.082  -33.734    0.000   -2.755   -2.755
##     tol3|t2          -1.758    0.031  -56.806    0.000   -1.758   -1.758
##     tol3|t3          -0.728    0.019  -38.919    0.000   -0.728   -0.728
##     tol3|t4           0.343    0.017   19.791    0.000    0.343    0.343
##     tol3|t5           1.353    0.024   56.347    0.000    1.353    1.353
##     tol3|t6           2.330    0.051   45.924    0.000    2.330    2.330
##     tol4|t1          -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     tol4|t2          -1.676    0.029  -57.366    0.000   -1.676   -1.676
##     tol4|t3          -0.726    0.019  -38.816    0.000   -0.726   -0.726
##     tol4|t4           0.333    0.017   19.226    0.000    0.333    0.333
##     tol4|t5           1.362    0.024   56.439    0.000    1.362    1.362
##     tol4|t6           2.423    0.056   43.389    0.000    2.423    2.423
##     craving1|t1      -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     craving1|t2      -1.610    0.028  -57.585    0.000   -1.610   -1.610
##     craving1|t3      -0.569    0.018  -31.616    0.000   -0.569   -0.569
##     craving1|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving1|t5       1.509    0.026   57.506    0.000    1.509    1.509
##     craving1|t6       2.699    0.076   35.400    0.000    2.699    2.699
##     craving2|t1      -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     craving2|t2      -1.634    0.028  -57.529    0.000   -1.634   -1.634
##     craving2|t3      -0.557    0.018  -31.034    0.000   -0.557   -0.557
##     craving2|t4       0.495    0.018   27.903    0.000    0.495    0.495
##     craving2|t5       1.562    0.027   57.611    0.000    1.562    1.562
##     craving2|t6       2.620    0.069   37.714    0.000    2.620    2.620
##     craving3|t1      -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     craving3|t2      -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     craving3|t3      -0.580    0.018  -32.144    0.000   -0.580   -0.580
##     craving3|t4       0.460    0.018   26.090    0.000    0.460    0.460
##     craving3|t5       1.517    0.026   57.529    0.000    1.517    1.517
##     craving3|t6       2.555    0.064   39.622    0.000    2.555    2.555
##     craving4|t1      -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     craving4|t2      -1.643    0.029  -57.501    0.000   -1.643   -1.643
##     craving4|t3      -0.576    0.018  -31.933    0.000   -0.576   -0.576
##     craving4|t4       0.467    0.018   26.437    0.000    0.467    0.467
##     craving4|t5       1.498    0.026   57.465    0.000    1.498    1.498
##     craving4|t6       2.543    0.064   39.965    0.000    2.543    2.543
##     taste1|t1        -2.469    0.059  -42.099    0.000   -2.469   -2.469
##     taste1|t2        -1.501    0.026  -57.476    0.000   -1.501   -1.501
##     taste1|t3        -0.459    0.018  -26.010    0.000   -0.459   -0.459
##     taste1|t4         0.572    0.018   31.748    0.000    0.572    0.572
##     taste1|t5         1.554    0.027   57.604    0.000    1.554    1.554
##     taste1|t6         2.649    0.072   36.846    0.000    2.649    2.649
##     taste2|t1        -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     taste2|t2        -1.487    0.026  -57.417    0.000   -1.487   -1.487
##     taste2|t3        -0.475    0.018  -26.864    0.000   -0.475   -0.475
##     taste2|t4         0.568    0.018   31.563    0.000    0.568    0.568
##     taste2|t5         1.598    0.028   57.602    0.000    1.598    1.598
##     taste2|t6         2.717    0.078   34.872    0.000    2.717    2.717
##     taste3|t1        -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     taste3|t2        -1.536    0.027  -57.576    0.000   -1.536   -1.536
##     taste3|t3        -0.492    0.018  -27.717    0.000   -0.492   -0.492
##     taste3|t4         0.558    0.018   31.087    0.000    0.558    0.558
##     taste3|t5         1.610    0.028   57.585    0.000    1.610    1.610
##     taste3|t6         2.606    0.068   38.124    0.000    2.606    2.606
##     cog_e1|t1        -3.062    0.122  -25.068    0.000   -3.062   -3.062
##     cog_e1|t2        -1.766    0.031  -56.729    0.000   -1.766   -1.766
##     cog_e1|t3        -0.742    0.019  -39.509    0.000   -0.742   -0.742
##     cog_e1|t4         0.297    0.017   17.233    0.000    0.297    0.297
##     cog_e1|t5         1.371    0.024   56.540    0.000    1.371    1.371
##     cog_e1|t6         2.441    0.057   42.893    0.000    2.441    2.441
##     cog_e2|t1        -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     cog_e2|t2        -1.710    0.030  -57.168    0.000   -1.710   -1.710
##     cog_e2|t3        -0.694    0.019  -37.424    0.000   -0.694   -0.694
##     cog_e2|t4         0.306    0.017   17.718    0.000    0.306    0.306
##     cog_e2|t5         1.360    0.024   56.426    0.000    1.360    1.360
##     cog_e2|t6         2.406    0.055   43.861    0.000    2.406    2.406
##     cog_e3|t1        -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cog_e3|t2        -1.743    0.031  -56.931    0.000   -1.743   -1.743
##     cog_e3|t3        -0.730    0.019  -39.022    0.000   -0.730   -0.730
##     cog_e3|t4         0.318    0.017   18.418    0.000    0.318    0.318
##     cog_e3|t5         1.333    0.024   56.100    0.000    1.333    1.333
##     cog_e3|t6         2.323    0.050   46.107    0.000    2.323    2.323
##     w_control1|t1    -2.432    0.056  -43.144    0.000   -2.432   -2.432
##     w_control1|t2    -1.511    0.026  -57.511    0.000   -1.511   -1.511
##     w_control1|t3    -0.463    0.018  -26.224    0.000   -0.463   -0.463
##     w_control1|t4     0.576    0.018   31.959    0.000    0.576    0.576
##     w_control1|t5     1.560    0.027   57.610    0.000    1.560    1.560
##     w_control1|t6     2.606    0.068   38.124    0.000    2.606    2.606
##     w_control2|t1    -2.489    0.060  -41.533    0.000   -2.489   -2.489
##     w_control2|t2    -1.540    0.027  -57.585    0.000   -1.540   -1.540
##     w_control2|t3    -0.461    0.018  -26.143    0.000   -0.461   -0.461
##     w_control2|t4     0.542    0.018   30.293    0.000    0.542    0.542
##     w_control2|t5     1.552    0.027   57.602    0.000    1.552    1.552
##     w_control2|t6     2.531    0.063   40.298    0.000    2.531    2.531
##     w_control3|t1    -2.520    0.062  -40.621    0.000   -2.520   -2.520
##     w_control3|t2    -1.497    0.026  -57.459    0.000   -1.497   -1.497
##     w_control3|t3    -0.491    0.018  -27.690    0.000   -0.491   -0.491
##     w_control3|t4     0.538    0.018   30.055    0.000    0.538    0.538
##     w_control3|t5     1.595    0.028   57.605    0.000    1.595    1.595
##     w_control3|t6     2.634    0.071   37.289    0.000    2.634    2.634
##     cue1|t1          -2.579    0.066  -38.899    0.000   -2.579   -2.579
##     cue1|t2          -1.582    0.027  -57.614    0.000   -1.582   -1.582
##     cue1|t3          -0.612    0.018  -33.696    0.000   -0.612   -0.612
##     cue1|t4           0.409    0.017   23.361    0.000    0.409    0.409
##     cue1|t5           1.423    0.025   57.025    0.000    1.423    1.423
##     cue1|t6           2.441    0.057   42.893    0.000    2.441    2.441
##     cue2|t1          -2.735    0.080  -34.318    0.000   -2.735   -2.735
##     cue2|t2          -1.677    0.029  -57.357    0.000   -1.677   -1.677
##     cue2|t3          -0.635    0.018  -34.770    0.000   -0.635   -0.635
##     cue2|t4           0.408    0.017   23.308    0.000    0.408    0.408
##     cue2|t5           1.442    0.025   57.166    0.000    1.442    1.442
##     cue2|t6           2.414    0.055   43.628    0.000    2.414    2.414
##     cue3|t1          -2.665    0.073  -36.385    0.000   -2.665   -2.665
##     cue3|t2          -1.607    0.028  -57.590    0.000   -1.607   -1.607
##     cue3|t3          -0.596    0.018  -32.934    0.000   -0.596   -0.596
##     cue3|t4           0.395    0.017   22.638    0.000    0.395    0.395
##     cue3|t5           1.407    0.025   56.890    0.000    1.407    1.407
##     cue3|t6           2.469    0.059   42.099    0.000    2.469    2.469
##     affect1|t1       -2.699    0.076  -35.400    0.000   -2.699   -2.699
##     affect1|t2       -1.695    0.030  -57.265    0.000   -1.695   -1.695
##     affect1|t3       -0.653    0.018  -35.580    0.000   -0.653   -0.653
##     affect1|t4        0.433    0.018   24.673    0.000    0.433    0.433
##     affect1|t5        1.517    0.026   57.529    0.000    1.517    1.517
##     affect1|t6        2.634    0.071   37.289    0.000    2.634    2.634
##     affect2|t1       -2.606    0.068  -38.124    0.000   -2.606   -2.606
##     affect2|t2       -1.716    0.030  -57.128    0.000   -1.716   -1.716
##     affect2|t3       -0.659    0.018  -35.867    0.000   -0.659   -0.659
##     affect2|t4        0.401    0.017   22.959    0.000    0.401    0.401
##     affect2|t5        1.468    0.026   57.321    0.000    1.468    1.468
##     affect2|t6        2.520    0.062   40.621    0.000    2.520    2.520
##     affect3|t1       -2.717    0.078  -34.872    0.000   -2.717   -2.717
##     affect3|t2       -1.624    0.028  -57.557    0.000   -1.624   -1.624
##     affect3|t3       -0.619    0.018  -33.985    0.000   -0.619   -0.619
##     affect3|t4        0.403    0.017   23.067    0.000    0.403    0.403
##     affect3|t5        1.481    0.026   57.392    0.000    1.481    1.481
##     affect3|t6        2.509    0.061   40.934    0.000    2.509    2.509
##     attach1|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach1|t2       -1.632    0.028  -57.534    0.000   -1.632   -1.632
##     attach1|t3       -0.554    0.018  -30.876    0.000   -0.554   -0.554
##     attach1|t4        0.487    0.018   27.504    0.000    0.487    0.487
##     attach1|t5        1.530    0.027   57.564    0.000    1.530    1.530
##     attach1|t6        2.665    0.073   36.385    0.000    2.665    2.665
##     attach2|t1       -2.543    0.064  -39.965    0.000   -2.543   -2.543
##     attach2|t2       -1.600    0.028  -57.600    0.000   -1.600   -1.600
##     attach2|t3       -0.584    0.018  -32.355    0.000   -0.584   -0.584
##     attach2|t4        0.469    0.018   26.571    0.000    0.469    0.469
##     attach2|t5        1.472    0.026   57.343    0.000    1.472    1.472
##     attach2|t6        2.469    0.059   42.099    0.000    2.469    2.469
##     attach3|t1       -2.634    0.071  -37.289    0.000   -2.634   -2.634
##     attach3|t2       -1.625    0.028  -57.552    0.000   -1.625   -1.625
##     attach3|t3       -0.562    0.018  -31.246    0.000   -0.562   -0.562
##     attach3|t4        0.503    0.018   28.329    0.000    0.503    0.503
##     attach3|t5        1.515    0.026   57.524    0.000    1.515    1.515
##     attach3|t6        2.555    0.064   39.622    0.000    2.555    2.555
##     social1|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social1|t2       -1.645    0.029  -57.495    0.000   -1.645   -1.645
##     social1|t3       -0.592    0.018  -32.723    0.000   -0.592   -0.592
##     social1|t4        0.449    0.018   25.502    0.000    0.449    0.449
##     social1|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social1|t6        2.649    0.072   36.846    0.000    2.649    2.649
##     social2|t1       -2.823    0.089  -31.773    0.000   -2.823   -2.823
##     social2|t2       -1.631    0.028  -57.539    0.000   -1.631   -1.631
##     social2|t3       -0.617    0.018  -33.906    0.000   -0.617   -0.617
##     social2|t4        0.451    0.018   25.609    0.000    0.451    0.451
##     social2|t5        1.495    0.026   57.453    0.000    1.495    1.495
##     social2|t6        2.567    0.065   39.266    0.000    2.567    2.567
##     social3|t1       -2.649    0.072  -36.846    0.000   -2.649   -2.649
##     social3|t2       -1.654    0.029  -57.463    0.000   -1.654   -1.654
##     social3|t3       -0.582    0.018  -32.249    0.000   -0.582   -0.582
##     social3|t4        0.454    0.018   25.743    0.000    0.454    0.454
##     social3|t5        1.497    0.026   57.459    0.000    1.497    1.497
##     social3|t6        2.499    0.061   41.238    0.000    2.499    2.499
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .auto1             0.678                               0.678    0.678
##    .auto2             0.700                               0.700    0.700
##    .auto3             0.691                               0.691    0.691
##    .auto4             0.685                               0.685    0.685
##    .loc1              0.685                               0.685    0.685
##    .loc2              0.713                               0.713    0.713
##    .loc3              0.695                               0.695    0.695
##    .loc4              0.697                               0.697    0.697
##    .tol1              0.683                               0.683    0.683
##    .tol2              0.702                               0.702    0.702
##    .tol3              0.672                               0.672    0.672
##    .tol4              0.675                               0.675    0.675
##    .craving1          0.720                               0.720    0.720
##    .craving2          0.679                               0.679    0.679
##    .craving3          0.684                               0.684    0.684
##    .craving4          0.734                               0.734    0.734
##    .taste1            0.686                               0.686    0.686
##    .taste2            0.669                               0.669    0.669
##    .taste3            0.687                               0.687    0.687
##    .cog_e1            0.681                               0.681    0.681
##    .cog_e2            0.702                               0.702    0.702
##    .cog_e3            0.693                               0.693    0.693
##    .w_control1        0.681                               0.681    0.681
##    .w_control2        0.640                               0.640    0.640
##    .w_control3        0.697                               0.697    0.697
##    .cue1              0.664                               0.664    0.664
##    .cue2              0.685                               0.685    0.685
##    .cue3              0.642                               0.642    0.642
##    .affect1           0.708                               0.708    0.708
##    .affect2           0.687                               0.687    0.687
##    .affect3           0.739                               0.739    0.739
##    .attach1           0.705                               0.705    0.705
##    .attach2           0.659                               0.659    0.659
##    .attach3           0.715                               0.715    0.715
##    .social1           0.700                               0.700    0.700
##    .social2           0.699                               0.699    0.699
##    .social3           0.721                               0.721    0.721
##    .auto              0.150    0.011   13.487    0.000    0.466    0.466
##    .loc               0.141    0.011   12.841    0.000    0.447    0.447
##    .tol               0.139    0.011   12.800    0.000    0.439    0.439
##    .craving           0.113    0.010   11.122    0.000    0.402    0.402
##    .taste             0.154    0.012   12.814    0.000    0.492    0.492
##    .cog_e             0.159    0.013   12.566    0.000    0.498    0.498
##    .w_control         0.169    0.012   13.536    0.000    0.530    0.530
##    .cue               0.170    0.013   13.520    0.000    0.507    0.507
##    .affect            0.147    0.012   12.080    0.000    0.504    0.504
##    .attach            0.156    0.012   12.735    0.000    0.529    0.529
##    .social            0.142    0.012   11.968    0.000    0.472    0.472
##     pdm               0.172    0.012   14.541    0.000    1.000    1.000
##     sdm               0.159    0.011   13.957    0.000    1.000    1.000
#Perform the chi-square DiffTest to assess the relative fitness:

#Relative fitness between the multidimensional solutions and the unidimensional solution
anova(ord_mod1_fit, ord_mod2_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##               Df AIC BIC    Chisq Chisq diff Df diff Pr(>Chisq)    
## ord_mod2_fit 574           391.72                                  
## ord_mod1_fit 629         13988.60     7185.2      55  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(ord_mod1_fit, ord_mod3_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##               Df AIC BIC   Chisq Chisq diff Df diff Pr(>Chisq)    
## ord_mod3_fit 628          4898.8                                  
## ord_mod1_fit 629         13988.6       1435       1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(ord_mod1_fit, ord_mod4_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##               Df AIC BIC    Chisq Chisq diff Df diff Pr(>Chisq)    
## ord_mod4_fit 617           437.07                                  
## ord_mod1_fit 629         13988.60     6098.8      12  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Select the most plausible continuous and ordinal WISDM-37 models
cont_select_fit <- 
ord_select_fit <- 

#Explore the modification indices of the selected WISMD-37 structural model 
wisdm_mi <- modificationIndices(...)

#Reconstruct the selected models following hypothesis-consistent modifications
cont_modified <- 
ord_modified <- 
#Calculate composite reliability for the selected continuous and ordinal WISDM-37 model
cont_rel <- compRelSEM(...)
print(cont_rel, digits = 3)

ord_rel <- compRelSEM(...)
print(ord_rel, digits = 3)
#Calculate the corrected item-total correlation for the selected WISDM-37 model

#Store items of each factors
#Calculate the Fagerström Test for Nicotine Dependence scores for each method of smoking
data_cleaned$cigg_f = rowSums(data_cleaned[,82:87])
data_cleaned$ecigg_f = rowSums(data_cleaned[,88:93])
data_cleaned$h_f = rowSums(data_cleaned[,94:99])

#Calculate the mean score for each WISDM-37 factor
data_cleaned$auto = rowMeans(data_cleaned[,c(44, 53, 57, 68)])
data_cleaned$loc = rowMeans(data_cleaned[,c(45, 59, 64, 79)])
data_cleaned$tol = rowMeans(data_cleaned[,c(46, 72, 75, 80)])
data_cleaned$craving = rowMeans(data_cleaned[,c(47, 60, 66, 73)])
data_cleaned$taste = rowMeans(data_cleaned[,c(48, 58, 63)])
data_cleaned$cog_e = rowMeans(data_cleaned[,c(49, 56, 76)])
data_cleaned$w_control = rowMeans(data_cleaned[,c(50, 62, 78)])
data_cleaned$cue = rowMeans(data_cleaned[,c(51, 55, 67)])
data_cleaned$affect = rowMeans(data_cleaned[,c(52, 77, 81)])
data_cleaned$attach = rowMeans(data_cleaned[,c(54, 65, 69)])
data_cleaned$social = rowMeans(data_cleaned[,c(61, 70, 74)])
data_cleaned$pdm = rowMeans(data_cleaned[,105:108])
data_cleaned$sdm = rowMeans(data_cleaned[,109:115])


#Robust multiple linear regression analysis:

#WISDM-37 factors -> dependence on cigarettes
wisdm37_cigg <- lmrob(cigg_f ~ auto + loc + tol + craving + taste + cog_e + w_control + cue + affect + attach + social, 
                      data = data_cleaned,
                      k.max = 1000
                      )
cor.wisdm37.cigg <- (cor(data_cleaned[c(105:115, 102)], 
                         method = "spearman")^2
                     )*100
pcor.wisdm37.cigg <- (pcor(data_cleaned[c(105:115, 102)], 
                           method = "spearman")$estimate^2
                      )*100
summary(wisdm37_cigg)
## 
## Call:
## lmrob(formula = cigg_f ~ auto + loc + tol + craving + taste + cog_e + w_control + 
##     cue + affect + attach + social, data = data_cleaned, k.max = 1000)
##  \--> method = "MM"
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.8390 -1.5427  0.2549  1.3393  6.4192 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.727979   0.273533  13.629   <2e-16 ***
## auto         0.018916   0.040712   0.465   0.6422    
## loc          0.010344   0.041247   0.251   0.8020    
## tol         -0.042284   0.040749  -1.038   0.2995    
## craving      0.049164   0.042407   1.159   0.2464    
## taste        0.009821   0.038548   0.255   0.7989    
## cog_e       -0.018704   0.038935  -0.480   0.6310    
## w_control    0.051698   0.037366   1.384   0.1665    
## cue         -0.068716   0.036770  -1.869   0.0617 .  
## affect       0.031023   0.040076   0.774   0.4389    
## attach      -0.017658   0.038373  -0.460   0.6454    
## social      -0.041091   0.038702  -1.062   0.2884    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Robust residual standard error: 1.84 
## Multiple R-squared:  0.001839,   Adjusted R-squared:  -0.0001775 
## Convergence in 9 IRWLS iterations
## 
## Robustness weights: 
##  28 weights are ~= 1. The remaining 5429 ones are summarized as
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1986  0.8637  0.9505  0.9202  0.9908  0.9990 
## Algorithmic parameters: 
##        tuning.chi                bb        tuning.psi        refine.tol 
##         1.548e+00         5.000e-01         4.685e+00         1.000e-07 
##           rel.tol         scale.tol         solve.tol          zero.tol 
##         1.000e-07         1.000e-10         1.000e-07         1.000e-10 
##       eps.outlier             eps.x warn.limit.reject warn.limit.meanrw 
##         1.833e-05         1.213e-11         5.000e-01         5.000e-01 
##      nResample         max.it         groups        n.group       best.r.s 
##            500             50              5            400              2 
##       k.fast.s          k.max    maxit.scale      trace.lev            mts 
##              1           1000            200              0           1000 
##     compute.rd fast.s.large.n 
##              0           2000 
##                   psi           subsampling                   cov 
##            "bisquare"         "nonsingular"         ".vcov.avar1" 
## compute.outlier.stats 
##                  "SM" 
## seed : int(0)
print(cor.wisdm37.cigg)
##                   auto          loc          tol      craving        taste
## auto      1.000000e+02 9.872299e+00   9.77208988  10.48697587 2.044612e+00
## loc       9.872299e+00 1.000000e+02  11.21686338  11.16199459 1.708174e+00
## tol       9.772090e+00 1.121686e+01 100.00000000  11.49644288 2.036112e+00
## craving   1.048698e+01 1.116199e+01  11.49644288 100.00000000 2.200149e+00
## taste     2.044612e+00 1.708174e+00   2.03611248   2.20014868 1.000000e+02
## cog_e     1.559625e+00 2.027995e+00   1.98006231   1.94266223 7.691140e+00
## w_control 1.789944e+00 1.690201e+00   2.07520550   1.94072199 6.295567e+00
## cue       2.198697e+00 1.712706e+00   1.49259913   2.12405616 7.430507e+00
## affect    1.605646e+00 1.730705e+00   1.73828821   1.64514537 6.572715e+00
## attach    1.876114e+00 1.833911e+00   1.86008329   2.14871229 6.313243e+00
## social    1.927375e+00 2.048385e+00   2.32494424   2.13391912 7.196366e+00
## cigg_f    3.178403e-05 9.472948e-04   0.01330205   0.01537463 1.632977e-03
##                  cog_e    w_control          cue       affect       attach
## auto      1.559625e+00   1.78994421   2.19869674 1.605646e+00 1.876114e+00
## loc       2.027995e+00   1.69020100   1.71270646 1.730705e+00 1.833911e+00
## tol       1.980062e+00   2.07520550   1.49259913 1.738288e+00 1.860083e+00
## craving   1.942662e+00   1.94072199   2.12405616 1.645145e+00 2.148712e+00
## taste     7.691140e+00   6.29556668   7.43050667 6.572715e+00 6.313243e+00
## cog_e     1.000000e+02   6.96089490   7.13009517 6.603245e+00 6.408226e+00
## w_control 6.960895e+00 100.00000000   6.75730045 6.602734e+00 6.872604e+00
## cue       7.130095e+00   6.75730045 100.00000000 6.857935e+00 6.284347e+00
## affect    6.603245e+00   6.60273437   6.85793476 1.000000e+02 5.153372e+00
## attach    6.408226e+00   6.87260430   6.28434730 5.153372e+00 1.000000e+02
## social    6.826808e+00   6.13453474   7.05203310 6.444894e+00 6.011915e+00
## cigg_f    5.605809e-03   0.02488712   0.04522647 3.009714e-03 3.683273e-03
##                 social       cigg_f
## auto        1.92737502 3.178403e-05
## loc         2.04838476 9.472948e-04
## tol         2.32494424 1.330205e-02
## craving     2.13391912 1.537463e-02
## taste       7.19636602 1.632977e-03
## cog_e       6.82680840 5.605809e-03
## w_control   6.13453474 2.488712e-02
## cue         7.05203310 4.522647e-02
## affect      6.44489412 3.009714e-03
## attach      6.01191490 3.683273e-03
## social    100.00000000 2.610947e-02
## cigg_f      0.02610947 1.000000e+02
print(pcor.wisdm37.cigg)
##                   auto          loc          tol      craving        taste
## auto      1.000000e+02 2.947550e+00 2.780742e+00   3.28926245 1.012891e-01
## loc       2.947550e+00 1.000000e+02 3.784523e+00   3.58761783 1.326891e-02
## tol       2.780742e+00 3.784523e+00 1.000000e+02   3.84666756 7.440109e-02
## craving   3.289262e+00 3.587618e+00 3.846668e+00 100.00000000 1.021976e-01
## taste     1.012891e-01 1.326891e-02 7.440109e-02   0.10219760 1.000000e+02
## cog_e     4.534375e-03 1.236099e-01 7.605839e-02   0.04606846 1.574737e+00
## w_control 5.171281e-02 2.607061e-02 1.261694e-01   0.05109352 8.431175e-01
## cue       1.963960e-01 2.861515e-02 4.936060e-04   0.10909190 1.392809e+00
## affect    3.711994e-02 7.440560e-02 5.589869e-02   0.01856168 1.114761e+00
## attach    7.557930e-02 6.264434e-02 4.835599e-02   0.11999545 1.014334e+00
## social    5.103383e-02 8.411690e-02 1.600514e-01   0.06543171 1.347774e+00
## cigg_f    4.670581e-04 7.291670e-04 2.167265e-02   0.03368838 4.968880e-06
##                  cog_e    w_control          cue       affect       attach
## auto      4.534375e-03   0.05171281 1.963960e-01   0.03711994 7.557930e-02
## loc       1.236099e-01   0.02607061 2.861515e-02   0.07440560 6.264434e-02
## tol       7.605839e-02   0.12616944 4.936060e-04   0.05589869 4.835599e-02
## craving   4.606846e-02   0.05109352 1.090919e-01   0.01856168 1.199954e-01
## taste     1.574737e+00   0.84311751 1.392809e+00   1.11476132 1.014334e+00
## cog_e     1.000000e+02   1.24844093 1.217241e+00   1.13322594 1.071867e+00
## w_control 1.248441e+00 100.00000000 1.140309e+00   1.27197877 1.506291e+00
## cue       1.217241e+00   1.14030924 1.000000e+02   1.30994551 1.002752e+00
## affect    1.133226e+00   1.27197877 1.309946e+00 100.00000000 5.829042e-01
## attach    1.071867e+00   1.50629074 1.002752e+00   0.58290419 1.000000e+02
## social    1.120622e+00   0.85571405 1.271819e+00   1.13973770 9.306308e-01
## cigg_f    2.468033e-03   0.05389534 5.042369e-02   0.01148714 1.580967e-03
##                 social       cigg_f
## auto        0.05103383 4.670581e-04
## loc         0.08411690 7.291670e-04
## tol         0.16005137 2.167265e-02
## craving     0.06543171 3.368838e-02
## taste       1.34777440 4.968880e-06
## cog_e       1.12062239 2.468033e-03
## w_control   0.85571405 5.389534e-02
## cue         1.27181932 5.042369e-02
## affect      1.13973770 1.148714e-02
## attach      0.93063075 1.580967e-03
## social    100.00000000 2.290894e-02
## cigg_f      0.02290894 1.000000e+02
#WISDM-37 factors -> dependence on e-cigarettes
wisdm37_ecigg <- lmrob(ecigg_f ~ auto + loc + tol + craving + taste + cog_e + w_control + cue + affect + attach + social, 
                       data = data_cleaned,
                       k.max = 1000
                       )
cor.wisdm37.ecigg <- (cor(data_cleaned[c(105:115, 103)], 
                         method = "spearman")^2
                      )*100
pcor.wisdm37.ecigg <- (pcor(data_cleaned[c(105:115, 103)], 
                           method = "spearman")$estimate^2
                       )*100
summary(wisdm37_ecigg)
## 
## Call:
## lmrob(formula = ecigg_f ~ auto + loc + tol + craving + taste + cog_e + w_control + 
##     cue + affect + attach + social, data = data_cleaned, k.max = 1000)
##  \--> method = "MM"
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7177 -1.4498 -0.3829  1.4558  7.4889 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.7751235  0.2763993  13.658   <2e-16 ***
## auto         0.0591177  0.0405857   1.457    0.145    
## loc          0.0126242  0.0429812   0.294    0.769    
## tol          0.0008161  0.0414909   0.020    0.984    
## craving     -0.0219715  0.0425889  -0.516    0.606    
## taste       -0.0081781  0.0395349  -0.207    0.836    
## cog_e       -0.0662966  0.0396999  -1.670    0.095 .  
## w_control   -0.0119813  0.0384973  -0.311    0.756    
## cue          0.0075851  0.0375557   0.202    0.840    
## affect      -0.0436664  0.0403954  -1.081    0.280    
## attach      -0.0292278  0.0389644  -0.750    0.453    
## social       0.0345590  0.0391024   0.884    0.377    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Robust residual standard error: 1.873 
## Multiple R-squared:  0.00177,    Adjusted R-squared:  -0.0002466 
## Convergence in 10 IRWLS iterations
## 
## Robustness weights: 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.07391 0.85280 0.94600 0.91890 0.99300 0.99840 
## Algorithmic parameters: 
##        tuning.chi                bb        tuning.psi        refine.tol 
##         1.548e+00         5.000e-01         4.685e+00         1.000e-07 
##           rel.tol         scale.tol         solve.tol          zero.tol 
##         1.000e-07         1.000e-10         1.000e-07         1.000e-10 
##       eps.outlier             eps.x warn.limit.reject warn.limit.meanrw 
##         1.833e-05         1.213e-11         5.000e-01         5.000e-01 
##      nResample         max.it         groups        n.group       best.r.s 
##            500             50              5            400              2 
##       k.fast.s          k.max    maxit.scale      trace.lev            mts 
##              1           1000            200              0           1000 
##     compute.rd fast.s.large.n 
##              0           2000 
##                   psi           subsampling                   cov 
##            "bisquare"         "nonsingular"         ".vcov.avar1" 
## compute.outlier.stats 
##                  "SM" 
## seed : int(0)
print(cor.wisdm37.ecigg)
##                   auto          loc          tol      craving        taste
## auto      1.000000e+02 9.872299e+00 9.772090e+00 1.048698e+01   2.04461247
## loc       9.872299e+00 1.000000e+02 1.121686e+01 1.116199e+01   1.70817400
## tol       9.772090e+00 1.121686e+01 1.000000e+02 1.149644e+01   2.03611248
## craving   1.048698e+01 1.116199e+01 1.149644e+01 1.000000e+02   2.20014868
## taste     2.044612e+00 1.708174e+00 2.036112e+00 2.200149e+00 100.00000000
## cog_e     1.559625e+00 2.027995e+00 1.980062e+00 1.942662e+00   7.69114011
## w_control 1.789944e+00 1.690201e+00 2.075206e+00 1.940722e+00   6.29556668
## cue       2.198697e+00 1.712706e+00 1.492599e+00 2.124056e+00   7.43050667
## affect    1.605646e+00 1.730705e+00 1.738288e+00 1.645145e+00   6.57271530
## attach    1.876114e+00 1.833911e+00 1.860083e+00 2.148712e+00   6.31324337
## social    1.927375e+00 2.048385e+00 2.324944e+00 2.133919e+00   7.19636602
## ecigg_f   9.134188e-03 2.297808e-03 2.432842e-03 2.348026e-03   0.01559358
##                  cog_e    w_control          cue       affect       attach
## auto        1.55962500   1.78994421 2.198697e+00   1.60564604   1.87611439
## loc         2.02799516   1.69020100 1.712706e+00   1.73070483   1.83391068
## tol         1.98006231   2.07520550 1.492599e+00   1.73828821   1.86008329
## craving     1.94266223   1.94072199 2.124056e+00   1.64514537   2.14871229
## taste       7.69114011   6.29556668 7.430507e+00   6.57271530   6.31324337
## cog_e     100.00000000   6.96089490 7.130095e+00   6.60324527   6.40822578
## w_control   6.96089490 100.00000000 6.757300e+00   6.60273437   6.87260430
## cue         7.13009517   6.75730045 1.000000e+02   6.85793476   6.28434730
## affect      6.60324527   6.60273437 6.857935e+00 100.00000000   5.15337163
## attach      6.40822578   6.87260430 6.284347e+00   5.15337163 100.00000000
## social      6.82680840   6.13453474 7.052033e+00   6.44489412   6.01191490
## ecigg_f     0.08422186   0.03176931 7.455958e-03   0.03965147   0.02739291
##                 social      ecigg_f
## auto      1.927375e+00 9.134188e-03
## loc       2.048385e+00 2.297808e-03
## tol       2.324944e+00 2.432842e-03
## craving   2.133919e+00 2.348026e-03
## taste     7.196366e+00 1.559358e-02
## cog_e     6.826808e+00 8.422186e-02
## w_control 6.134535e+00 3.176931e-02
## cue       7.052033e+00 7.455958e-03
## affect    6.444894e+00 3.965147e-02
## attach    6.011915e+00 2.739291e-02
## social    1.000000e+02 1.086602e-03
## ecigg_f   1.086602e-03 1.000000e+02
print(pcor.wisdm37.ecigg)
##                   auto          loc          tol      craving        taste
## auto      1.000000e+02   2.94409650 2.776956e+00 3.294124e+00 1.014821e-01
## loc       2.944097e+00 100.00000000 3.784883e+00 3.588275e+00 1.330982e-02
## tol       2.776956e+00   3.78488289 1.000000e+02 3.839610e+00 7.453138e-02
## craving   3.294124e+00   3.58827537 3.839610e+00 1.000000e+02 1.020871e-01
## taste     1.014821e-01   0.01330982 7.453138e-02 1.020871e-01 1.000000e+02
## cog_e     4.904099e-03   0.12467742 7.730119e-02 4.502628e-02 1.572413e+00
## w_control 5.247190e-02   0.02606924 1.242689e-01 5.280075e-02 8.429467e-01
## cue       1.958108e-01   0.02878908 3.632045e-04 1.065593e-01 1.393745e+00
## affect    3.778861e-02   0.07467445 5.555599e-02 1.888348e-02 1.113961e+00
## attach    7.608477e-02   0.06296288 4.887103e-02 1.191381e-01 1.013833e+00
## social    5.045045e-02   0.08407098 1.614628e-01 6.431042e-02 1.348562e+00
## ecigg_f   1.515208e-02   0.00414200 4.624897e-03 4.329402e-03 7.292634e-04
##                  cog_e    w_control          cue       affect       attach
## auto      4.904099e-03 5.247190e-02 1.958108e-01   0.03778861 7.608477e-02
## loc       1.246774e-01 2.606924e-02 2.878908e-02   0.07467445 6.296288e-02
## tol       7.730119e-02 1.242689e-01 3.632045e-04   0.05555599 4.887103e-02
## craving   4.502628e-02 5.280075e-02 1.065593e-01   0.01888348 1.191381e-01
## taste     1.572413e+00 8.429467e-01 1.393745e+00   1.11396125 1.013833e+00
## cog_e     1.000000e+02 1.241134e+00 1.220746e+00   1.12549863 1.067710e+00
## w_control 1.241134e+00 1.000000e+02 1.130683e+00   1.27559074 1.502749e+00
## cue       1.220746e+00 1.130683e+00 1.000000e+02   1.30562622 1.005335e+00
## affect    1.125499e+00 1.275591e+00 1.305626e+00 100.00000000 5.806296e-01
## attach    1.067710e+00 1.502749e+00 1.005335e+00   0.58062964 1.000000e+02
## social    1.125669e+00 8.510839e-01 1.279983e+00   1.13849212 9.331725e-01
## ecigg_f   5.250725e-02 8.368717e-03 4.244783e-04   0.01511988 7.020368e-03
##                 social      ecigg_f
## auto      5.045045e-02 1.515208e-02
## loc       8.407098e-02 4.142000e-03
## tol       1.614628e-01 4.624897e-03
## craving   6.431042e-02 4.329402e-03
## taste     1.348562e+00 7.292634e-04
## cog_e     1.125669e+00 5.250725e-02
## w_control 8.510839e-01 8.368717e-03
## cue       1.279983e+00 4.244783e-04
## affect    1.138492e+00 1.511988e-02
## attach    9.331725e-01 7.020368e-03
## social    1.000000e+02 6.210693e-03
## ecigg_f   6.210693e-03 1.000000e+02
#WISDM-37 factors -> dependence on hookah

wisdm37_h <- lmrob(h_f ~ auto + loc + tol + craving + taste + cog_e + w_control + cue + affect + attach + social,
                   data = data_cleaned,
                   k.max = 1000
                   )
cor.wisdm37.h <- (cor(data_cleaned[c(105:115, 104)], 
                         method = "spearman")^2
                 )*100
pcor.wisdm37.h <- (pcor(data_cleaned[c(105:115, 104)], 
                           method = "spearman")$estimate^2
                   )*100
summary(wisdm37_h)
## 
## Call:
## lmrob(formula = h_f ~ auto + loc + tol + craving + taste + cog_e + w_control + 
##     cue + affect + attach + social, data = data_cleaned, k.max = 1000)
##  \--> method = "MM"
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.20364 -1.01122 -0.02085  0.98922  7.01385 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.306366   0.219113  10.526   <2e-16 ***
## auto        -0.009782   0.034512  -0.283    0.777    
## loc         -0.011976   0.033643  -0.356    0.722    
## tol         -0.005931   0.034682  -0.171    0.864    
## craving      0.014757   0.033713   0.438    0.662    
## taste       -0.010101   0.030348  -0.333    0.739    
## cog_e        0.045182   0.030245   1.494    0.135    
## w_control   -0.016010   0.030412  -0.526    0.599    
## cue         -0.044126   0.030478  -1.448    0.148    
## affect      -0.016643   0.031201  -0.533    0.594    
## attach       0.025505   0.031336   0.814    0.416    
## social      -0.043991   0.031104  -1.414    0.157    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Robust residual standard error: 1.448 
## Multiple R-squared:  0.001762,   Adjusted R-squared:  -0.0002551 
## Convergence in 10 IRWLS iterations
## 
## Robustness weights: 
##  2 observations c(1863,2072) are outliers with |weight| = 0 ( < 1.8e-05); 
##  1398 weights are ~= 1. The remaining 4057 ones are summarized as
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 0.04266 0.83410 0.95240 0.88570 0.95860 0.99900 
## Algorithmic parameters: 
##        tuning.chi                bb        tuning.psi        refine.tol 
##         1.548e+00         5.000e-01         4.685e+00         1.000e-07 
##           rel.tol         scale.tol         solve.tol          zero.tol 
##         1.000e-07         1.000e-10         1.000e-07         1.000e-10 
##       eps.outlier             eps.x warn.limit.reject warn.limit.meanrw 
##         1.833e-05         1.213e-11         5.000e-01         5.000e-01 
##      nResample         max.it         groups        n.group       best.r.s 
##            500             50              5            400              2 
##       k.fast.s          k.max    maxit.scale      trace.lev            mts 
##              1           1000            200              0           1000 
##     compute.rd fast.s.large.n 
##              0           2000 
##                   psi           subsampling                   cov 
##            "bisquare"         "nonsingular"         ".vcov.avar1" 
## compute.outlier.stats 
##                  "SM" 
## seed : int(0)
print(cor.wisdm37.h)
##                   auto          loc          tol      craving       taste
## auto      100.00000000   9.87229910 9.772090e+00 1.048698e+01   2.0446125
## loc         9.87229910 100.00000000 1.121686e+01 1.116199e+01   1.7081740
## tol         9.77208988  11.21686338 1.000000e+02 1.149644e+01   2.0361125
## craving    10.48697587  11.16199459 1.149644e+01 1.000000e+02   2.2001487
## taste       2.04461247   1.70817400 2.036112e+00 2.200149e+00 100.0000000
## cog_e       1.55962500   2.02799516 1.980062e+00 1.942662e+00   7.6911401
## w_control   1.78994421   1.69020100 2.075206e+00 1.940722e+00   6.2955667
## cue         2.19869674   1.71270646 1.492599e+00 2.124056e+00   7.4305067
## affect      1.60564604   1.73070483 1.738288e+00 1.645145e+00   6.5727153
## attach      1.87611439   1.83391068 1.860083e+00 2.148712e+00   6.3132434
## social      1.92737502   2.04838476 2.324944e+00 2.133919e+00   7.1963660
## h_f         0.01746395   0.01624268 8.124967e-03 1.687271e-03   0.0163737
##                  cog_e    w_control          cue       affect       attach
## auto      1.559625e+00   1.78994421   2.19869674   1.60564604 1.876114e+00
## loc       2.027995e+00   1.69020100   1.71270646   1.73070483 1.833911e+00
## tol       1.980062e+00   2.07520550   1.49259913   1.73828821 1.860083e+00
## craving   1.942662e+00   1.94072199   2.12405616   1.64514537 2.148712e+00
## taste     7.691140e+00   6.29556668   7.43050667   6.57271530 6.313243e+00
## cog_e     1.000000e+02   6.96089490   7.13009517   6.60324527 6.408226e+00
## w_control 6.960895e+00 100.00000000   6.75730045   6.60273437 6.872604e+00
## cue       7.130095e+00   6.75730045 100.00000000   6.85793476 6.284347e+00
## affect    6.603245e+00   6.60273437   6.85793476 100.00000000 5.153372e+00
## attach    6.408226e+00   6.87260430   6.28434730   5.15337163 1.000000e+02
## social    6.826808e+00   6.13453474   7.05203310   6.44489412 6.011915e+00
## h_f       2.068663e-03   0.02723217   0.07635238   0.02105977 6.265674e-04
##                 social          h_f
## auto        1.92737502 1.746395e-02
## loc         2.04838476 1.624268e-02
## tol         2.32494424 8.124967e-03
## craving     2.13391912 1.687271e-03
## taste       7.19636602 1.637370e-02
## cog_e       6.82680840 2.068663e-03
## w_control   6.13453474 2.723217e-02
## cue         7.05203310 7.635238e-02
## affect      6.44489412 2.105977e-02
## attach      6.01191490 6.265674e-04
## social    100.00000000 5.363631e-02
## h_f         0.05363631 1.000000e+02
print(pcor.wisdm37.h)
##                   auto          loc          tol      craving        taste
## auto      1.000000e+02 2.945568e+00 2.779797e+00 3.292886e+00 1.011322e-01
## loc       2.945568e+00 1.000000e+02 3.786274e+00 3.588120e+00 1.321329e-02
## tol       2.779797e+00 3.786274e+00 1.000000e+02 3.838438e+00 7.440101e-02
## craving   3.292886e+00 3.588120e+00 3.838438e+00 1.000000e+02 1.023257e-01
## taste     1.011322e-01 1.321329e-02 7.440101e-02 1.023257e-01 1.000000e+02
## cog_e     4.678008e-03 1.245310e-01 7.662432e-02 4.526121e-02 1.575879e+00
## w_control 5.170366e-02 2.568771e-02 1.237333e-01 5.329754e-02 8.428352e-01
## cue       1.947130e-01 2.831874e-02 3.717299e-04 1.071931e-01 1.391150e+00
## affect    3.707172e-02 7.404505e-02 5.512769e-02 1.919217e-02 1.114378e+00
## attach    7.582518e-02 6.297859e-02 4.868378e-02 1.192075e-01 1.014880e+00
## social    5.040716e-02 8.370679e-02 1.616493e-01 6.448113e-02 1.346466e+00
## h_f       4.310982e-03 4.728394e-03 2.880851e-04 2.978072e-03 1.266327e-03
##                  cog_e    w_control          cue       affect       attach
## auto      4.678008e-03 5.170366e-02 1.947130e-01 3.707172e-02 7.582518e-02
## loc       1.245310e-01 2.568771e-02 2.831874e-02 7.404505e-02 6.297859e-02
## tol       7.662432e-02 1.237333e-01 3.717299e-04 5.512769e-02 4.868378e-02
## craving   4.526121e-02 5.329754e-02 1.071931e-01 1.919217e-02 1.192075e-01
## taste     1.575879e+00 8.428352e-01 1.391150e+00 1.114378e+00 1.014880e+00
## cog_e     1.000000e+02 1.249551e+00 1.227950e+00 1.133952e+00 1.068821e+00
## w_control 1.249551e+00 1.000000e+02 1.125787e+00 1.277218e+00 1.506414e+00
## cue       1.227950e+00 1.125787e+00 1.000000e+02 1.301890e+00 1.008123e+00
## affect    1.133952e+00 1.277218e+00 1.301890e+00 1.000000e+02 5.829696e-01
## attach    1.068821e+00 1.506414e+00 1.008123e+00 5.829696e-01 1.000000e+02
## social    1.127966e+00 8.470194e-01 1.271660e+00 1.134452e+00 9.342968e-01
## h_f       3.212502e-02 7.544784e-03 4.661221e-02 3.027651e-03 6.898714e-03
##                 social          h_f
## auto        0.05040716 4.310982e-03
## loc         0.08370679 4.728394e-03
## tol         0.16164930 2.880851e-04
## craving     0.06448113 2.978072e-03
## taste       1.34646635 1.266327e-03
## cog_e       1.12796632 3.212502e-02
## w_control   0.84701942 7.544784e-03
## cue         1.27166026 4.661221e-02
## affect      1.13445203 3.027651e-03
## attach      0.93429677 6.898714e-03
## social    100.00000000 2.589130e-02
## h_f         0.02589130 1.000000e+02
#Confirmatory factor analysis for the RFQ:

#Based on continuous variables:

#Model 1: 1-factor solution
rfq_cmod1 <-'f =~ hc1 + hc2 + hc3 + hc4 + hc5 + sc1 + sc2 + sc3 + sc4 + sc5 +
                  ir1 + ir2 + ir3 + ir4 + ir5 + sp1 + sp2 + sp3 + sp4 + sp5
            '
rfq_cmod1_fit <- cfa(rfq_cmod1, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(rfq_cmod1_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 30 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        40
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              20841.261   21839.192
##   Degrees of freedom                                170         170
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   0.954
##     Yuan-Bentler correction (Mplus variant)                        
## 
## Model Test Baseline Model:
## 
##   Test statistic                             47834.419   47433.136
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.008
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.566       0.541
##   Tucker-Lewis Index (TLI)                       0.515       0.487
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.566
##   Robust Tucker-Lewis Index (TLI)                            0.515
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -137360.398 -137360.398
##   Scaling correction factor                                  1.133
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -126939.768 -126939.768
##   Scaling correction factor                                  0.988
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              274800.796  274800.796
##   Bayesian (BIC)                            275064.983  275064.983
##   Sample-size adjusted Bayesian (SABIC)     274937.875  274937.875
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.149       0.153
##   90 Percent confidence interval - lower         0.148       0.151
##   90 Percent confidence interval - upper         0.151       0.155
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    1.000       1.000
##                                                                   
##   Robust RMSEA                                               0.149
##   90 Percent confidence interval - lower                     0.148
##   90 Percent confidence interval - upper                     0.151
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.133       0.133
## 
## 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
##   f =~                                                                  
##     hc1               1.000                               0.495    0.504
##     hc2               1.066    0.025   41.842    0.000    0.528    0.526
##     hc3               0.940    0.024   39.256    0.000    0.465    0.495
##     hc4               0.990    0.024   40.408    0.000    0.490    0.509
##     hc5               1.060    0.025   41.678    0.000    0.525    0.526
##     sc1               1.119    0.037   29.920    0.000    0.554    0.571
##     sc2               1.151    0.038   29.915    0.000    0.570    0.572
##     sc3               1.006    0.035   28.749    0.000    0.498    0.533
##     sc4               1.126    0.038   29.563    0.000    0.557    0.564
##     sc5               1.067    0.037   29.024    0.000    0.528    0.551
##     ir1               1.007    0.073   13.761    0.000    0.498    0.534
##     ir2               1.073    0.076   14.117    0.000    0.531    0.552
##     ir3               1.084    0.078   13.926    0.000    0.536    0.552
##     ir4               0.978    0.071   13.848    0.000    0.484    0.521
##     ir5               1.011    0.074   13.730    0.000    0.500    0.536
##     sp1               1.160    0.078   14.815    0.000    0.574    0.595
##     sp2               1.157    0.078   14.889    0.000    0.572    0.590
##     sp3               1.198    0.081   14.853    0.000    0.593    0.601
##     sp4               1.134    0.077   14.679    0.000    0.561    0.580
##     sp5               1.074    0.074   14.516    0.000    0.531    0.569
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.719    0.020   36.608    0.000    0.719    0.746
##    .hc2               0.727    0.021   34.435    0.000    0.727    0.723
##    .hc3               0.669    0.018   37.916    0.000    0.669    0.755
##    .hc4               0.686    0.019   35.552    0.000    0.686    0.741
##    .hc5               0.720    0.021   34.937    0.000    0.720    0.723
##    .sc1               0.635    0.019   34.246    0.000    0.635    0.674
##    .sc2               0.668    0.019   34.490    0.000    0.668    0.673
##    .sc3               0.626    0.017   37.498    0.000    0.626    0.716
##    .sc4               0.665    0.019   34.247    0.000    0.665    0.682
##    .sc5               0.639    0.017   36.749    0.000    0.639    0.696
##    .ir1               0.624    0.016   38.467    0.000    0.624    0.715
##    .ir2               0.642    0.017   37.706    0.000    0.642    0.695
##    .ir3               0.656    0.018   36.110    0.000    0.656    0.695
##    .ir4               0.629    0.016   39.597    0.000    0.629    0.729
##    .ir5               0.620    0.017   36.666    0.000    0.620    0.712
##    .sp1               0.603    0.018   33.055    0.000    0.603    0.647
##    .sp2               0.613    0.018   33.788    0.000    0.613    0.652
##    .sp3               0.622    0.019   32.090    0.000    0.622    0.639
##    .sp4               0.623    0.018   35.282    0.000    0.623    0.664
##    .sp5               0.590    0.017   35.313    0.000    0.590    0.676
##     f                 0.245    0.021   11.605    0.000    1.000    1.000
#Model 2: 4-factor solution
rfq_cmod2 <-'hc =~ hc1 + hc2 + hc3 + hc4 + hc5
             sc =~ sc1 + sc2 + sc3 + sc4 + sc5
             ir =~ ir1 + ir2 + ir3 + ir4 + ir5
             sp =~ sp1 + sp2 + sp3 + sp4 + sp5
             '
rfq_cmod2_fit <- cfa(rfq_cmod2, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(rfq_cmod2_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 37 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        46
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               186.312     185.408
##   Degrees of freedom                               164         164
##   P-value (Chi-square)                           0.112       0.121
##   Scaling correction factor                                  1.005
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             47834.419   47433.136
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.008
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.999       0.999
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            0.999
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -127032.924 -127032.924
##   Scaling correction factor                                  0.929
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -126939.768 -126939.768
##   Scaling correction factor                                  0.988
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              254157.848  254157.848
##   Bayesian (BIC)                            254461.662  254461.662
##   Sample-size adjusted Bayesian (SABIC)     254315.489  254315.489
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.005       0.005
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.008       0.008
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.005
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.008
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008       0.008
## 
## 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
##   hc =~                                                                 
##     hc1               1.000                               0.726    0.740
##     hc2               1.065    0.019   57.169    0.000    0.773    0.771
##     hc3               0.933    0.017   53.353    0.000    0.677    0.720
##     hc4               0.985    0.018   55.649    0.000    0.715    0.743
##     hc5               1.045    0.018   56.860    0.000    0.759    0.761
##   sc =~                                                                 
##     sc1               1.000                               0.727    0.749
##     sc2               1.032    0.018   55.855    0.000    0.750    0.753
##     sc3               0.910    0.018   51.076    0.000    0.662    0.708
##     sc4               1.026    0.018   56.318    0.000    0.746    0.755
##     sc5               0.949    0.018   52.146    0.000    0.690    0.720
##   ir =~                                                                 
##     ir1               1.000                               0.663    0.709
##     ir2               1.068    0.021   51.884    0.000    0.708    0.736
##     ir3               1.090    0.021   51.448    0.000    0.722    0.744
##     ir4               0.983    0.020   48.938    0.000    0.651    0.701
##     ir5               1.015    0.020   50.558    0.000    0.673    0.721
##   sp =~                                                                 
##     sp1               1.000                               0.719    0.745
##     sp2               0.990    0.019   52.969    0.000    0.712    0.734
##     sp3               1.037    0.019   55.606    0.000    0.746    0.756
##     sp4               0.980    0.018   53.010    0.000    0.705    0.728
##     sp5               0.927    0.018   52.685    0.000    0.667    0.714
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   hc ~~                                                                 
##     sc                0.313    0.010   30.885    0.000    0.593    0.593
##     ir                0.140    0.008   17.528    0.000    0.291    0.291
##     sp                0.172    0.009   19.275    0.000    0.330    0.330
##   sc ~~                                                                 
##     ir                0.172    0.008   20.364    0.000    0.356    0.356
##     sp                0.215    0.009   22.963    0.000    0.410    0.410
##   ir ~~                                                                 
##     sp                0.317    0.010   31.151    0.000    0.664    0.664
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.436    0.010   43.803    0.000    0.436    0.453
##    .hc2               0.408    0.010   40.752    0.000    0.408    0.405
##    .hc3               0.427    0.010   44.402    0.000    0.427    0.482
##    .hc4               0.415    0.010   43.395    0.000    0.415    0.448
##    .hc5               0.419    0.010   42.293    0.000    0.419    0.422
##    .sc1               0.413    0.010   42.732    0.000    0.413    0.438
##    .sc2               0.429    0.010   41.387    0.000    0.429    0.432
##    .sc3               0.436    0.010   45.434    0.000    0.436    0.499
##    .sc4               0.419    0.010   42.037    0.000    0.419    0.429
##    .sc5               0.442    0.010   43.508    0.000    0.442    0.482
##    .ir1               0.433    0.010   43.470    0.000    0.433    0.497
##    .ir2               0.423    0.010   42.589    0.000    0.423    0.458
##    .ir3               0.422    0.010   42.080    0.000    0.422    0.447
##    .ir4               0.439    0.010   44.887    0.000    0.439    0.509
##    .ir5               0.417    0.010   42.450    0.000    0.417    0.480
##    .sp1               0.416    0.010   42.478    0.000    0.416    0.446
##    .sp2               0.434    0.010   44.030    0.000    0.434    0.461
##    .sp3               0.417    0.010   40.740    0.000    0.417    0.429
##    .sp4               0.441    0.010   43.831    0.000    0.441    0.471
##    .sp5               0.428    0.010   44.913    0.000    0.428    0.491
##     hc                0.527    0.016   32.669    0.000    1.000    1.000
##     sc                0.529    0.016   32.799    0.000    1.000    1.000
##     ir                0.439    0.015   29.559    0.000    1.000    1.000
##     sp                0.517    0.016   32.624    0.000    1.000    1.000
#Model 3: 2-factor solution
rfq_cmod3 <-'intrinsic =~ hc1 + hc2 + hc3 + hc4 + hc5 + sc1 + sc2 + sc3 + sc4 + sc5
             extrinsic =~ ir1 + ir2 + ir3 + ir4 + ir5 + sp1 + sp2 + sp3 + sp4 + sp5
             '
rfq_cmod3_fit <- cfa(rfq_cmod3, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(rfq_cmod3_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 32 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        41
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              9051.760    9183.355
##   Degrees of freedom                               169         169
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  0.986
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             47834.419   47433.136
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.008
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.814       0.809
##   Tucker-Lewis Index (TLI)                       0.790       0.785
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.814
##   Robust Tucker-Lewis Index (TLI)                            0.790
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -131465.648 -131465.648
##   Scaling correction factor                                  0.999
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -126939.768 -126939.768
##   Scaling correction factor                                  0.988
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              263013.296  263013.296
##   Bayesian (BIC)                            263284.086  263284.086
##   Sample-size adjusted Bayesian (SABIC)     263153.801  263153.801
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.098       0.099
##   90 Percent confidence interval - lower         0.096       0.097
##   90 Percent confidence interval - upper         0.100       0.101
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    1.000       1.000
##                                                                   
##   Robust RMSEA                                               0.098
##   90 Percent confidence interval - lower                     0.096
##   90 Percent confidence interval - upper                     0.100
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.068       0.068
## 
## 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
##   intrinsic =~                                                          
##     hc1               1.000                               0.643    0.655
##     hc2               1.073    0.020   53.811    0.000    0.690    0.688
##     hc3               0.931    0.019   49.934    0.000    0.599    0.636
##     hc4               0.987    0.019   52.100    0.000    0.635    0.660
##     hc5               1.054    0.019   54.144    0.000    0.678    0.679
##     sc1               0.986    0.039   25.375    0.000    0.634    0.653
##     sc2               1.011    0.040   25.157    0.000    0.650    0.652
##     sc3               0.903    0.036   24.801    0.000    0.580    0.621
##     sc4               1.002    0.040   24.959    0.000    0.644    0.652
##     sc5               0.940    0.038   24.856    0.000    0.604    0.630
##   extrinsic =~                                                          
##     ir1               1.000                               0.593    0.634
##     ir2               1.047    0.021   48.721    0.000    0.621    0.645
##     ir3               1.079    0.022   48.810    0.000    0.639    0.658
##     ir4               0.963    0.021   46.189    0.000    0.571    0.614
##     ir5               1.003    0.021   46.758    0.000    0.594    0.637
##     sp1               1.113    0.033   33.418    0.000    0.660    0.683
##     sp2               1.106    0.034   32.970    0.000    0.655    0.676
##     sp3               1.149    0.035   33.017    0.000    0.681    0.690
##     sp4               1.094    0.034   32.396    0.000    0.648    0.670
##     sp5               1.044    0.032   32.607    0.000    0.618    0.662
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   intrinsic ~~                                                          
##     extrinsic         0.166    0.007   22.927    0.000    0.436    0.436
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.550    0.014   38.210    0.000    0.550    0.571
##    .hc2               0.529    0.015   34.905    0.000    0.529    0.526
##    .hc3               0.527    0.013   39.231    0.000    0.527    0.595
##    .hc4               0.523    0.014   37.210    0.000    0.523    0.565
##    .hc5               0.536    0.015   36.216    0.000    0.536    0.539
##    .sc1               0.539    0.015   36.616    0.000    0.539    0.573
##    .sc2               0.570    0.016   35.912    0.000    0.570    0.575
##    .sc3               0.537    0.013   40.636    0.000    0.537    0.614
##    .sc4               0.560    0.016   35.983    0.000    0.560    0.574
##    .sc5               0.553    0.014   39.168    0.000    0.553    0.603
##    .ir1               0.522    0.012   44.152    0.000    0.522    0.598
##    .ir2               0.539    0.012   43.888    0.000    0.539    0.583
##    .ir3               0.535    0.012   43.557    0.000    0.535    0.567
##    .ir4               0.538    0.012   45.470    0.000    0.538    0.623
##    .ir5               0.516    0.012   43.269    0.000    0.516    0.594
##    .sp1               0.498    0.012   43.156    0.000    0.498    0.533
##    .sp2               0.511    0.012   44.225    0.000    0.511    0.544
##    .sp3               0.510    0.012   41.948    0.000    0.510    0.524
##    .sp4               0.517    0.012   44.835    0.000    0.517    0.552
##    .sp5               0.490    0.011   45.682    0.000    0.490    0.562
##     intrinsic         0.413    0.019   21.353    0.000    1.000    1.000
##     extrinsic         0.351    0.015   22.811    0.000    1.000    1.000
#Model 4: 2-order solution
rfq_cmod4 <-'#1st order
             hc =~ hc1 + hc2 + hc3 + hc4 + hc5
             sc =~ sc1 + sc2 + sc3 + sc4 + sc5
             ir =~ ir1 + ir2 + ir3 + ir4 + ir5
             sp =~ sp1 + sp2 + sp3 + sp4 + sp5
             
             #2nd order
             intrinsic =~ hc + sc
             extrinsic =~ ir + sp
             '
rfq_cmod4_fit <- cfa(rfq_cmod4, 
                     data = data_cleaned, 
                     estimator = "MLR"
                     )
summary(rfq_cmod4_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 39 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        45
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               186.412     185.529
##   Degrees of freedom                               165         165
##   P-value (Chi-square)                           0.121       0.131
##   Scaling correction factor                                  1.005
##     Yuan-Bentler correction (Mplus variant)                       
## 
## Model Test Baseline Model:
## 
##   Test statistic                             47834.419   47433.136
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.008
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       0.999       0.999
##                                                                   
##   Robust Comparative Fit Index (CFI)                         1.000
##   Robust Tucker-Lewis Index (TLI)                            1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)            -127032.974 -127032.974
##   Scaling correction factor                                  0.928
##       for the MLR correction                                      
##   Loglikelihood unrestricted model (H1)    -126939.768 -126939.768
##   Scaling correction factor                                  0.988
##       for the MLR correction                                      
##                                                                   
##   Akaike (AIC)                              254155.948  254155.948
##   Bayesian (BIC)                            254453.158  254453.158
##   Sample-size adjusted Bayesian (SABIC)     254310.162  254310.162
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.005       0.005
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.008       0.008
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.005
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.008
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008       0.008
## 
## 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
##   hc =~                                                                 
##     hc1               1.000                               0.726    0.740
##     hc2               1.065    0.019   57.189    0.000    0.773    0.771
##     hc3               0.933    0.017   53.362    0.000    0.677    0.720
##     hc4               0.985    0.018   55.654    0.000    0.715    0.743
##     hc5               1.045    0.018   56.879    0.000    0.759    0.761
##   sc =~                                                                 
##     sc1               1.000                               0.727    0.749
##     sc2               1.032    0.018   55.857    0.000    0.750    0.753
##     sc3               0.910    0.018   51.084    0.000    0.662    0.708
##     sc4               1.026    0.018   56.321    0.000    0.746    0.755
##     sc5               0.949    0.018   52.159    0.000    0.690    0.720
##   ir =~                                                                 
##     ir1               1.000                               0.663    0.709
##     ir2               1.068    0.021   51.891    0.000    0.708    0.736
##     ir3               1.090    0.021   51.449    0.000    0.722    0.744
##     ir4               0.983    0.020   48.939    0.000    0.651    0.701
##     ir5               1.015    0.020   50.568    0.000    0.673    0.721
##   sp =~                                                                 
##     sp1               1.000                               0.719    0.745
##     sp2               0.990    0.019   52.971    0.000    0.712    0.734
##     sp3               1.037    0.019   55.606    0.000    0.746    0.756
##     sp4               0.980    0.018   53.010    0.000    0.705    0.728
##     sp5               0.927    0.018   52.686    0.000    0.667    0.714
##   intrinsic =~                                                          
##     hc                1.000                               0.693    0.693
##     sc                1.238    0.054   23.047    0.000    0.857    0.857
##   extrinsic =~                                                          
##     ir                1.000                               0.761    0.761
##     sp                1.246    0.050   25.059    0.000    0.873    0.873
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   intrinsic ~~                                                          
##     extrinsic         0.139    0.007   18.536    0.000    0.548    0.548
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.436    0.010   43.806    0.000    0.436    0.453
##    .hc2               0.408    0.010   40.752    0.000    0.408    0.405
##    .hc3               0.427    0.010   44.408    0.000    0.427    0.482
##    .hc4               0.415    0.010   43.395    0.000    0.415    0.448
##    .hc5               0.419    0.010   42.296    0.000    0.419    0.422
##    .sc1               0.413    0.010   42.732    0.000    0.413    0.438
##    .sc2               0.429    0.010   41.394    0.000    0.429    0.432
##    .sc3               0.436    0.010   45.433    0.000    0.436    0.499
##    .sc4               0.419    0.010   42.037    0.000    0.419    0.429
##    .sc5               0.442    0.010   43.517    0.000    0.442    0.482
##    .ir1               0.433    0.010   43.471    0.000    0.433    0.497
##    .ir2               0.423    0.010   42.593    0.000    0.423    0.458
##    .ir3               0.422    0.010   42.078    0.000    0.422    0.447
##    .ir4               0.439    0.010   44.887    0.000    0.439    0.509
##    .ir5               0.417    0.010   42.463    0.000    0.417    0.480
##    .sp1               0.416    0.010   42.478    0.000    0.416    0.446
##    .sp2               0.434    0.010   44.040    0.000    0.434    0.461
##    .sp3               0.417    0.010   40.741    0.000    0.417    0.429
##    .sp4               0.441    0.010   43.830    0.000    0.441    0.471
##    .sp5               0.428    0.010   44.914    0.000    0.428    0.491
##    .hc                0.274    0.013   20.318    0.000    0.520    0.520
##    .sc                0.141    0.016    8.773    0.000    0.266    0.266
##    .ir                0.185    0.011   17.001    0.000    0.421    0.421
##    .sp                0.123    0.015    8.439    0.000    0.237    0.237
##     intrinsic         0.253    0.014   17.634    0.000    1.000    1.000
##     extrinsic         0.254    0.014   18.596    0.000    1.000    1.000
#Based on ordinal variables:
rfq_items <- c("hc1", "hc2", "hc3", "hc4", "hc5",
               "sc1", "sc2", "sc3", "sc4", "sc5",
               "ir1", "ir2", "ir3", "ir4", "ir5",
               "sp1", "sp2", "sp3", "sp4", "sp5"
               )

#Model 1: 1-factor solution
rfq_omod1 <- 'f =~ hc1 + hc2 + hc3 + hc4 + hc5 + sc1 + sc2 + sc3 + sc4 + sc5 +
                   ir1 + ir2 + ir3 + ir4 + ir5 + sp1 + sp2 + sp3 + sp4 + sp5
              '
rfq_omod1_fit <- cfa(rfq_omod1, 
                     data = data_cleaned, 
                     estimator = "WLSMV", 
                     ordered = rfq_items
                     )
summary(rfq_omod1_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 27 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       100
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                                Standard      Scaled
##   Test Statistic                              33513.452   28795.182
##   Degrees of freedom                                170         170
##   P-value (Chi-square)                            0.000       0.000
##   Scaling correction factor                                   1.167
##   Shift parameter                                            76.854
##     simple second-order correction                                 
## 
## Model Test Baseline Model:
## 
##   Test statistic                            204417.968   80216.076
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.552
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.837       0.642
##   Tucker-Lewis Index (TLI)                       0.818       0.600
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.535
##   Robust Tucker-Lewis Index (TLI)                            0.481
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.190       0.176
##   90 Percent confidence interval - lower         0.188       0.174
##   90 Percent confidence interval - upper         0.191       0.177
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    1.000       1.000
##                                                                   
##   Robust RMSEA                                               0.170
##   90 Percent confidence interval - lower                     0.168
##   90 Percent confidence interval - upper                     0.172
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.154       0.154
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   f =~                                                                  
##     hc1               1.000                               0.606    0.606
##     hc2               1.055    0.018   60.278    0.000    0.639    0.639
##     hc3               0.978    0.017   56.579    0.000    0.592    0.592
##     hc4               1.007    0.017   58.021    0.000    0.610    0.610
##     hc5               1.046    0.017   59.993    0.000    0.633    0.633
##     sc1               1.056    0.019   55.019    0.000    0.640    0.640
##     sc2               1.059    0.020   54.291    0.000    0.641    0.641
##     sc3               0.983    0.020   50.016    0.000    0.595    0.595
##     sc4               1.053    0.019   54.793    0.000    0.638    0.638
##     sc5               1.011    0.019   52.200    0.000    0.612    0.612
##     ir1               0.972    0.021   46.586    0.000    0.589    0.589
##     ir2               1.006    0.021   48.173    0.000    0.609    0.609
##     ir3               1.014    0.020   49.784    0.000    0.614    0.614
##     ir4               0.946    0.021   45.638    0.000    0.573    0.573
##     ir5               0.976    0.021   45.862    0.000    0.591    0.591
##     sp1               1.056    0.020   52.557    0.000    0.639    0.639
##     sp2               1.038    0.020   51.967    0.000    0.628    0.628
##     sp3               1.075    0.020   53.027    0.000    0.651    0.651
##     sp4               1.026    0.020   50.971    0.000    0.621    0.621
##     sp5               1.008    0.020   49.235    0.000    0.610    0.610
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     hc1|t1           -1.435    0.025  -57.111    0.000   -1.435   -1.435
##     hc1|t2           -0.403    0.017  -23.040    0.000   -0.403   -0.403
##     hc1|t3            0.617    0.018   33.906    0.000    0.617    0.617
##     hc1|t4            1.695    0.030   57.265    0.000    1.695    1.695
##     hc2|t1           -1.492    0.026  -57.442    0.000   -1.492   -1.492
##     hc2|t2           -0.498    0.018  -28.036    0.000   -0.498   -0.498
##     hc2|t3            0.528    0.018   29.578    0.000    0.528    0.528
##     hc2|t4            1.517    0.026   57.529    0.000    1.517    1.517
##     hc3|t1           -1.336    0.024  -56.142    0.000   -1.336   -1.336
##     hc3|t2           -0.256    0.017  -14.914    0.000   -0.256   -0.256
##     hc3|t3            0.845    0.019   43.644    0.000    0.845    0.845
##     hc3|t4            1.910    0.035   54.984    0.000    1.910    1.910
##     hc4|t1           -1.365    0.024  -56.477    0.000   -1.365   -1.365
##     hc4|t2           -0.314    0.017  -18.149    0.000   -0.314   -0.314
##     hc4|t3            0.750    0.019   39.841    0.000    0.750    0.750
##     hc4|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     hc5|t1           -1.442    0.025  -57.166    0.000   -1.442   -1.442
##     hc5|t2           -0.451    0.018  -25.636    0.000   -0.451   -0.451
##     hc5|t3            0.559    0.018   31.114    0.000    0.559    0.559
##     hc5|t4            1.612    0.028   57.582    0.000    1.612    1.612
##     sc1|t1           -1.531    0.027  -57.567    0.000   -1.531   -1.531
##     sc1|t2           -0.472    0.018  -26.731    0.000   -0.472   -0.472
##     sc1|t3            0.573    0.018   31.801    0.000    0.573    0.573
##     sc1|t4            1.634    0.028   57.529    0.000    1.634    1.634
##     sc2|t1           -1.603    0.028  -57.595    0.000   -1.603   -1.603
##     sc2|t2           -0.586    0.018  -32.434    0.000   -0.586   -0.586
##     sc2|t3            0.413    0.018   23.603    0.000    0.413    0.413
##     sc2|t4            1.460    0.025   57.275    0.000    1.460    1.460
##     sc3|t1           -1.474    0.026  -57.358    0.000   -1.474   -1.474
##     sc3|t2           -0.378    0.017  -21.698    0.000   -0.378   -0.378
##     sc3|t3            0.738    0.019   39.330    0.000    0.738    0.738
##     sc3|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     sc4|t1           -1.581    0.027  -57.615    0.000   -1.581   -1.581
##     sc4|t2           -0.507    0.018  -28.488    0.000   -0.507   -0.507
##     sc4|t3            0.494    0.018   27.850    0.000    0.494    0.494
##     sc4|t4            1.534    0.027   57.573    0.000    1.534    1.534
##     sc5|t1           -1.512    0.026  -57.515    0.000   -1.512   -1.512
##     sc5|t2           -0.438    0.018  -24.941    0.000   -0.438   -0.438
##     sc5|t3            0.626    0.018   34.352    0.000    0.626    0.626
##     sc5|t4            1.700    0.030   57.230    0.000    1.700    1.700
##     ir1|t1           -1.177    0.022  -53.462    0.000   -1.177   -1.177
##     ir1|t2           -0.106    0.017   -6.212    0.000   -0.106   -0.106
##     ir1|t3            1.001    0.020   48.938    0.000    1.001    1.001
##     ir1|t4            2.074    0.040   52.061    0.000    2.074    2.074
##     ir2|t1           -1.230    0.023  -54.504    0.000   -1.230   -1.230
##     ir2|t2           -0.181    0.017  -10.620    0.000   -0.181   -0.181
##     ir2|t3            0.872    0.020   44.631    0.000    0.872    0.872
##     ir2|t4            1.940    0.036   54.528    0.000    1.940    1.940
##     ir3|t1           -1.276    0.023  -55.290    0.000   -1.276   -1.276
##     ir3|t2           -0.250    0.017  -14.563    0.000   -0.250   -0.250
##     ir3|t3            0.812    0.019   42.373    0.000    0.812    0.812
##     ir3|t4            1.839    0.033   55.961    0.000    1.839    1.839
##     ir4|t1           -1.161    0.022  -53.130    0.000   -1.161   -1.161
##     ir4|t2           -0.083    0.017   -4.859    0.000   -0.083   -0.083
##     ir4|t3            1.029    0.021   49.777    0.000    1.029    1.029
##     ir4|t4            2.102    0.041   51.464    0.000    2.102    2.102
##     ir5|t1           -1.227    0.023  -54.451    0.000   -1.227   -1.227
##     ir5|t2           -0.169    0.017   -9.917    0.000   -0.169   -0.169
##     ir5|t3            0.938    0.020   46.952    0.000    0.938    0.938
##     ir5|t4            2.086    0.040   51.812    0.000    2.086    2.086
##     sp1|t1           -1.326    0.024  -56.014    0.000   -1.326   -1.326
##     sp1|t2           -0.263    0.017  -15.319    0.000   -0.263   -0.263
##     sp1|t3            0.780    0.019   41.087    0.000    0.780    0.780
##     sp1|t4            1.841    0.033   55.931    0.000    1.841    1.841
##     sp2|t1           -1.238    0.023  -54.646    0.000   -1.238   -1.238
##     sp2|t2           -0.200    0.017  -11.674    0.000   -0.200   -0.200
##     sp2|t3            0.857    0.019   44.089    0.000    0.857    0.857
##     sp2|t4            1.872    0.034   55.533    0.000    1.872    1.872
##     sp3|t1           -1.338    0.024  -56.156    0.000   -1.338   -1.338
##     sp3|t2           -0.324    0.017  -18.714    0.000   -0.324   -0.324
##     sp3|t3            0.702    0.019   37.786    0.000    0.702    0.702
##     sp3|t4            1.749    0.031   56.879    0.000    1.749    1.749
##     sp4|t1           -1.315    0.024  -55.868    0.000   -1.315   -1.315
##     sp4|t2           -0.238    0.017  -13.889    0.000   -0.238   -0.238
##     sp4|t3            0.789    0.019   41.441    0.000    0.789    0.789
##     sp4|t4            1.844    0.033   55.900    0.000    1.844    1.844
##     sp5|t1           -1.281    0.023  -55.372    0.000   -1.281   -1.281
##     sp5|t2           -0.186    0.017  -10.917    0.000   -0.186   -0.186
##     sp5|t3            0.891    0.020   45.315    0.000    0.891    0.891
##     sp5|t4            2.043    0.039   52.677    0.000    2.043    2.043
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.633                               0.633    0.633
##    .hc2               0.592                               0.592    0.592
##    .hc3               0.649                               0.649    0.649
##    .hc4               0.628                               0.628    0.628
##    .hc5               0.599                               0.599    0.599
##    .sc1               0.591                               0.591    0.591
##    .sc2               0.589                               0.589    0.589
##    .sc3               0.646                               0.646    0.646
##    .sc4               0.594                               0.594    0.594
##    .sc5               0.625                               0.625    0.625
##    .ir1               0.654                               0.654    0.654
##    .ir2               0.629                               0.629    0.629
##    .ir3               0.623                               0.623    0.623
##    .ir4               0.672                               0.672    0.672
##    .ir5               0.651                               0.651    0.651
##    .sp1               0.591                               0.591    0.591
##    .sp2               0.605                               0.605    0.605
##    .sp3               0.577                               0.577    0.577
##    .sp4               0.614                               0.614    0.614
##    .sp5               0.627                               0.627    0.627
##     f                 0.367    0.011   33.891    0.000    1.000    1.000
#Model 2: 4-factor solution
rfq_omod2 <- 'hc =~ hc1 + hc2 + hc3 + hc4 + hc5
              sc =~ sc1 + sc2 + sc3 + sc4 + sc5
              ir =~ ir1 + ir2 + ir3 + ir4 + ir5
              sp =~ sp1 + sp2 + sp3 + sp4 + sp5
              '
rfq_omod2_fit <- cfa(rfq_omod2, 
                     data = data_cleaned, 
                     estimator = "WLSMV", 
                     ordered = rfq_items
                     )
summary(rfq_omod2_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 46 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       106
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                92.040     167.265
##   Degrees of freedom                               164         164
##   P-value (Chi-square)                           1.000       0.415
##   Scaling correction factor                                  0.744
##   Shift parameter                                           43.576
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                            204417.968   80216.076
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.552
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.999
##   Robust Tucker-Lewis Index (TLI)                            0.999
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.002
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.007
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.006
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.010
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.009       0.009
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   hc =~                                                                 
##     hc1               1.000                               0.773    0.773
##     hc2               1.046    0.014   74.555    0.000    0.808    0.808
##     hc3               0.978    0.014   69.515    0.000    0.756    0.756
##     hc4               1.009    0.014   72.239    0.000    0.780    0.780
##     hc5               1.034    0.014   74.438    0.000    0.799    0.799
##   sc =~                                                                 
##     sc1               1.000                               0.789    0.789
##     sc2               1.001    0.014   72.596    0.000    0.790    0.790
##     sc3               0.943    0.014   66.507    0.000    0.744    0.744
##     sc4               0.999    0.013   74.502    0.000    0.788    0.788
##     sc5               0.962    0.014   68.406    0.000    0.759    0.759
##   ir =~                                                                 
##     ir1               1.000                               0.751    0.751
##     ir2               1.031    0.016   66.192    0.000    0.775    0.775
##     ir3               1.039    0.016   66.373    0.000    0.781    0.781
##     ir4               0.979    0.016   62.311    0.000    0.736    0.736
##     ir5               1.011    0.016   62.624    0.000    0.760    0.760
##   sp =~                                                                 
##     sp1               1.000                               0.781    0.781
##     sp2               0.990    0.014   71.727    0.000    0.773    0.773
##     sp3               1.012    0.014   72.817    0.000    0.791    0.791
##     sp4               0.976    0.014   69.671    0.000    0.763    0.763
##     sp5               0.962    0.014   68.461    0.000    0.751    0.751
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   hc ~~                                                                 
##     sc                0.362    0.009   39.614    0.000    0.594    0.594
##     ir                0.169    0.009   18.420    0.000    0.290    0.290
##     sp                0.200    0.009   21.194    0.000    0.331    0.331
##   sc ~~                                                                 
##     ir                0.211    0.009   22.599    0.000    0.357    0.357
##     sp                0.253    0.009   26.675    0.000    0.411    0.411
##   ir ~~                                                                 
##     sp                0.391    0.009   42.538    0.000    0.666    0.666
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     hc1|t1           -1.435    0.025  -57.111    0.000   -1.435   -1.435
##     hc1|t2           -0.403    0.017  -23.040    0.000   -0.403   -0.403
##     hc1|t3            0.617    0.018   33.906    0.000    0.617    0.617
##     hc1|t4            1.695    0.030   57.265    0.000    1.695    1.695
##     hc2|t1           -1.492    0.026  -57.442    0.000   -1.492   -1.492
##     hc2|t2           -0.498    0.018  -28.036    0.000   -0.498   -0.498
##     hc2|t3            0.528    0.018   29.578    0.000    0.528    0.528
##     hc2|t4            1.517    0.026   57.529    0.000    1.517    1.517
##     hc3|t1           -1.336    0.024  -56.142    0.000   -1.336   -1.336
##     hc3|t2           -0.256    0.017  -14.914    0.000   -0.256   -0.256
##     hc3|t3            0.845    0.019   43.644    0.000    0.845    0.845
##     hc3|t4            1.910    0.035   54.984    0.000    1.910    1.910
##     hc4|t1           -1.365    0.024  -56.477    0.000   -1.365   -1.365
##     hc4|t2           -0.314    0.017  -18.149    0.000   -0.314   -0.314
##     hc4|t3            0.750    0.019   39.841    0.000    0.750    0.750
##     hc4|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     hc5|t1           -1.442    0.025  -57.166    0.000   -1.442   -1.442
##     hc5|t2           -0.451    0.018  -25.636    0.000   -0.451   -0.451
##     hc5|t3            0.559    0.018   31.114    0.000    0.559    0.559
##     hc5|t4            1.612    0.028   57.582    0.000    1.612    1.612
##     sc1|t1           -1.531    0.027  -57.567    0.000   -1.531   -1.531
##     sc1|t2           -0.472    0.018  -26.731    0.000   -0.472   -0.472
##     sc1|t3            0.573    0.018   31.801    0.000    0.573    0.573
##     sc1|t4            1.634    0.028   57.529    0.000    1.634    1.634
##     sc2|t1           -1.603    0.028  -57.595    0.000   -1.603   -1.603
##     sc2|t2           -0.586    0.018  -32.434    0.000   -0.586   -0.586
##     sc2|t3            0.413    0.018   23.603    0.000    0.413    0.413
##     sc2|t4            1.460    0.025   57.275    0.000    1.460    1.460
##     sc3|t1           -1.474    0.026  -57.358    0.000   -1.474   -1.474
##     sc3|t2           -0.378    0.017  -21.698    0.000   -0.378   -0.378
##     sc3|t3            0.738    0.019   39.330    0.000    0.738    0.738
##     sc3|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     sc4|t1           -1.581    0.027  -57.615    0.000   -1.581   -1.581
##     sc4|t2           -0.507    0.018  -28.488    0.000   -0.507   -0.507
##     sc4|t3            0.494    0.018   27.850    0.000    0.494    0.494
##     sc4|t4            1.534    0.027   57.573    0.000    1.534    1.534
##     sc5|t1           -1.512    0.026  -57.515    0.000   -1.512   -1.512
##     sc5|t2           -0.438    0.018  -24.941    0.000   -0.438   -0.438
##     sc5|t3            0.626    0.018   34.352    0.000    0.626    0.626
##     sc5|t4            1.700    0.030   57.230    0.000    1.700    1.700
##     ir1|t1           -1.177    0.022  -53.462    0.000   -1.177   -1.177
##     ir1|t2           -0.106    0.017   -6.212    0.000   -0.106   -0.106
##     ir1|t3            1.001    0.020   48.938    0.000    1.001    1.001
##     ir1|t4            2.074    0.040   52.061    0.000    2.074    2.074
##     ir2|t1           -1.230    0.023  -54.504    0.000   -1.230   -1.230
##     ir2|t2           -0.181    0.017  -10.620    0.000   -0.181   -0.181
##     ir2|t3            0.872    0.020   44.631    0.000    0.872    0.872
##     ir2|t4            1.940    0.036   54.528    0.000    1.940    1.940
##     ir3|t1           -1.276    0.023  -55.290    0.000   -1.276   -1.276
##     ir3|t2           -0.250    0.017  -14.563    0.000   -0.250   -0.250
##     ir3|t3            0.812    0.019   42.373    0.000    0.812    0.812
##     ir3|t4            1.839    0.033   55.961    0.000    1.839    1.839
##     ir4|t1           -1.161    0.022  -53.130    0.000   -1.161   -1.161
##     ir4|t2           -0.083    0.017   -4.859    0.000   -0.083   -0.083
##     ir4|t3            1.029    0.021   49.777    0.000    1.029    1.029
##     ir4|t4            2.102    0.041   51.464    0.000    2.102    2.102
##     ir5|t1           -1.227    0.023  -54.451    0.000   -1.227   -1.227
##     ir5|t2           -0.169    0.017   -9.917    0.000   -0.169   -0.169
##     ir5|t3            0.938    0.020   46.952    0.000    0.938    0.938
##     ir5|t4            2.086    0.040   51.812    0.000    2.086    2.086
##     sp1|t1           -1.326    0.024  -56.014    0.000   -1.326   -1.326
##     sp1|t2           -0.263    0.017  -15.319    0.000   -0.263   -0.263
##     sp1|t3            0.780    0.019   41.087    0.000    0.780    0.780
##     sp1|t4            1.841    0.033   55.931    0.000    1.841    1.841
##     sp2|t1           -1.238    0.023  -54.646    0.000   -1.238   -1.238
##     sp2|t2           -0.200    0.017  -11.674    0.000   -0.200   -0.200
##     sp2|t3            0.857    0.019   44.089    0.000    0.857    0.857
##     sp2|t4            1.872    0.034   55.533    0.000    1.872    1.872
##     sp3|t1           -1.338    0.024  -56.156    0.000   -1.338   -1.338
##     sp3|t2           -0.324    0.017  -18.714    0.000   -0.324   -0.324
##     sp3|t3            0.702    0.019   37.786    0.000    0.702    0.702
##     sp3|t4            1.749    0.031   56.879    0.000    1.749    1.749
##     sp4|t1           -1.315    0.024  -55.868    0.000   -1.315   -1.315
##     sp4|t2           -0.238    0.017  -13.889    0.000   -0.238   -0.238
##     sp4|t3            0.789    0.019   41.441    0.000    0.789    0.789
##     sp4|t4            1.844    0.033   55.900    0.000    1.844    1.844
##     sp5|t1           -1.281    0.023  -55.372    0.000   -1.281   -1.281
##     sp5|t2           -0.186    0.017  -10.917    0.000   -0.186   -0.186
##     sp5|t3            0.891    0.020   45.315    0.000    0.891    0.891
##     sp5|t4            2.043    0.039   52.677    0.000    2.043    2.043
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.403                               0.403    0.403
##    .hc2               0.346                               0.346    0.346
##    .hc3               0.429                               0.429    0.429
##    .hc4               0.392                               0.392    0.392
##    .hc5               0.361                               0.361    0.361
##    .sc1               0.378                               0.378    0.378
##    .sc2               0.376                               0.376    0.376
##    .sc3               0.447                               0.447    0.447
##    .sc4               0.379                               0.379    0.379
##    .sc5               0.424                               0.424    0.424
##    .ir1               0.436                               0.436    0.436
##    .ir2               0.400                               0.400    0.400
##    .ir3               0.391                               0.391    0.391
##    .ir4               0.458                               0.458    0.458
##    .ir5               0.423                               0.423    0.423
##    .sp1               0.390                               0.390    0.390
##    .sp2               0.402                               0.402    0.402
##    .sp3               0.375                               0.375    0.375
##    .sp4               0.418                               0.418    0.418
##    .sp5               0.436                               0.436    0.436
##     hc                0.597    0.012   48.606    0.000    1.000    1.000
##     sc                0.622    0.012   50.555    0.000    1.000    1.000
##     ir                0.564    0.013   42.977    0.000    1.000    1.000
##     sp                0.610    0.012   49.692    0.000    1.000    1.000
#Model 3: 2-factor solution
rfq_omod3 <- 'intrinsic =~ hc1 + hc2 + hc3 + hc4 + hc5 + sc1 + sc2 + sc3 + sc4 + sc5
              extrinsic =~ ir1 + ir2 + ir3 + ir4 + ir5 + sp1 + sp2 + sp3 + sp4 + sp5
              '
rfq_omod3_fit <- cfa(rfq_omod3, 
                     data = data_cleaned, 
                     estimator = "WLSMV", 
                     ordered = rfq_items
                     )
summary(rfq_omod3_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 28 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       101
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              8788.236    8436.875
##   Degrees of freedom                               169         169
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.050
##   Shift parameter                                           66.373
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                            204417.968   80216.076
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.552
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.958       0.897
##   Tucker-Lewis Index (TLI)                       0.953       0.884
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.791
##   Robust Tucker-Lewis Index (TLI)                            0.765
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.097       0.095
##   90 Percent confidence interval - lower         0.095       0.093
##   90 Percent confidence interval - upper         0.098       0.096
##   P-value H_0: RMSEA <= 0.050                    0.000       0.000
##   P-value H_0: RMSEA >= 0.080                    1.000       1.000
##                                                                   
##   Robust RMSEA                                               0.115
##   90 Percent confidence interval - lower                     0.112
##   90 Percent confidence interval - upper                     0.117
##   P-value H_0: Robust RMSEA <= 0.050                         0.000
##   P-value H_0: Robust RMSEA >= 0.080                         1.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.077       0.077
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   intrinsic =~                                                          
##     hc1               1.000                               0.700    0.700
##     hc2               1.051    0.015   70.213    0.000    0.735    0.735
##     hc3               0.979    0.015   65.340    0.000    0.685    0.685
##     hc4               1.006    0.015   67.797    0.000    0.704    0.704
##     hc5               1.036    0.015   70.383    0.000    0.725    0.725
##     sc1               1.036    0.016   64.956    0.000    0.725    0.725
##     sc2               1.034    0.016   64.113    0.000    0.723    0.723
##     sc3               0.976    0.016   59.269    0.000    0.682    0.682
##     sc4               1.033    0.016   65.204    0.000    0.723    0.723
##     sc5               0.995    0.016   61.428    0.000    0.696    0.696
##   extrinsic =~                                                          
##     ir1               1.000                               0.684    0.684
##     ir2               1.032    0.016   63.585    0.000    0.706    0.706
##     ir3               1.040    0.016   63.985    0.000    0.711    0.711
##     ir4               0.979    0.016   59.861    0.000    0.670    0.670
##     ir5               1.010    0.017   60.036    0.000    0.691    0.691
##     sp1               1.066    0.017   62.230    0.000    0.730    0.730
##     sp2               1.055    0.017   61.519    0.000    0.722    0.722
##     sp3               1.082    0.017   62.294    0.000    0.741    0.741
##     sp4               1.043    0.017   59.948    0.000    0.714    0.714
##     sp5               1.028    0.018   58.325    0.000    0.704    0.704
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   intrinsic ~~                                                          
##     extrinsic         0.198    0.007   27.454    0.000    0.414    0.414
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     hc1|t1           -1.435    0.025  -57.111    0.000   -1.435   -1.435
##     hc1|t2           -0.403    0.017  -23.040    0.000   -0.403   -0.403
##     hc1|t3            0.617    0.018   33.906    0.000    0.617    0.617
##     hc1|t4            1.695    0.030   57.265    0.000    1.695    1.695
##     hc2|t1           -1.492    0.026  -57.442    0.000   -1.492   -1.492
##     hc2|t2           -0.498    0.018  -28.036    0.000   -0.498   -0.498
##     hc2|t3            0.528    0.018   29.578    0.000    0.528    0.528
##     hc2|t4            1.517    0.026   57.529    0.000    1.517    1.517
##     hc3|t1           -1.336    0.024  -56.142    0.000   -1.336   -1.336
##     hc3|t2           -0.256    0.017  -14.914    0.000   -0.256   -0.256
##     hc3|t3            0.845    0.019   43.644    0.000    0.845    0.845
##     hc3|t4            1.910    0.035   54.984    0.000    1.910    1.910
##     hc4|t1           -1.365    0.024  -56.477    0.000   -1.365   -1.365
##     hc4|t2           -0.314    0.017  -18.149    0.000   -0.314   -0.314
##     hc4|t3            0.750    0.019   39.841    0.000    0.750    0.750
##     hc4|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     hc5|t1           -1.442    0.025  -57.166    0.000   -1.442   -1.442
##     hc5|t2           -0.451    0.018  -25.636    0.000   -0.451   -0.451
##     hc5|t3            0.559    0.018   31.114    0.000    0.559    0.559
##     hc5|t4            1.612    0.028   57.582    0.000    1.612    1.612
##     sc1|t1           -1.531    0.027  -57.567    0.000   -1.531   -1.531
##     sc1|t2           -0.472    0.018  -26.731    0.000   -0.472   -0.472
##     sc1|t3            0.573    0.018   31.801    0.000    0.573    0.573
##     sc1|t4            1.634    0.028   57.529    0.000    1.634    1.634
##     sc2|t1           -1.603    0.028  -57.595    0.000   -1.603   -1.603
##     sc2|t2           -0.586    0.018  -32.434    0.000   -0.586   -0.586
##     sc2|t3            0.413    0.018   23.603    0.000    0.413    0.413
##     sc2|t4            1.460    0.025   57.275    0.000    1.460    1.460
##     sc3|t1           -1.474    0.026  -57.358    0.000   -1.474   -1.474
##     sc3|t2           -0.378    0.017  -21.698    0.000   -0.378   -0.378
##     sc3|t3            0.738    0.019   39.330    0.000    0.738    0.738
##     sc3|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     sc4|t1           -1.581    0.027  -57.615    0.000   -1.581   -1.581
##     sc4|t2           -0.507    0.018  -28.488    0.000   -0.507   -0.507
##     sc4|t3            0.494    0.018   27.850    0.000    0.494    0.494
##     sc4|t4            1.534    0.027   57.573    0.000    1.534    1.534
##     sc5|t1           -1.512    0.026  -57.515    0.000   -1.512   -1.512
##     sc5|t2           -0.438    0.018  -24.941    0.000   -0.438   -0.438
##     sc5|t3            0.626    0.018   34.352    0.000    0.626    0.626
##     sc5|t4            1.700    0.030   57.230    0.000    1.700    1.700
##     ir1|t1           -1.177    0.022  -53.462    0.000   -1.177   -1.177
##     ir1|t2           -0.106    0.017   -6.212    0.000   -0.106   -0.106
##     ir1|t3            1.001    0.020   48.938    0.000    1.001    1.001
##     ir1|t4            2.074    0.040   52.061    0.000    2.074    2.074
##     ir2|t1           -1.230    0.023  -54.504    0.000   -1.230   -1.230
##     ir2|t2           -0.181    0.017  -10.620    0.000   -0.181   -0.181
##     ir2|t3            0.872    0.020   44.631    0.000    0.872    0.872
##     ir2|t4            1.940    0.036   54.528    0.000    1.940    1.940
##     ir3|t1           -1.276    0.023  -55.290    0.000   -1.276   -1.276
##     ir3|t2           -0.250    0.017  -14.563    0.000   -0.250   -0.250
##     ir3|t3            0.812    0.019   42.373    0.000    0.812    0.812
##     ir3|t4            1.839    0.033   55.961    0.000    1.839    1.839
##     ir4|t1           -1.161    0.022  -53.130    0.000   -1.161   -1.161
##     ir4|t2           -0.083    0.017   -4.859    0.000   -0.083   -0.083
##     ir4|t3            1.029    0.021   49.777    0.000    1.029    1.029
##     ir4|t4            2.102    0.041   51.464    0.000    2.102    2.102
##     ir5|t1           -1.227    0.023  -54.451    0.000   -1.227   -1.227
##     ir5|t2           -0.169    0.017   -9.917    0.000   -0.169   -0.169
##     ir5|t3            0.938    0.020   46.952    0.000    0.938    0.938
##     ir5|t4            2.086    0.040   51.812    0.000    2.086    2.086
##     sp1|t1           -1.326    0.024  -56.014    0.000   -1.326   -1.326
##     sp1|t2           -0.263    0.017  -15.319    0.000   -0.263   -0.263
##     sp1|t3            0.780    0.019   41.087    0.000    0.780    0.780
##     sp1|t4            1.841    0.033   55.931    0.000    1.841    1.841
##     sp2|t1           -1.238    0.023  -54.646    0.000   -1.238   -1.238
##     sp2|t2           -0.200    0.017  -11.674    0.000   -0.200   -0.200
##     sp2|t3            0.857    0.019   44.089    0.000    0.857    0.857
##     sp2|t4            1.872    0.034   55.533    0.000    1.872    1.872
##     sp3|t1           -1.338    0.024  -56.156    0.000   -1.338   -1.338
##     sp3|t2           -0.324    0.017  -18.714    0.000   -0.324   -0.324
##     sp3|t3            0.702    0.019   37.786    0.000    0.702    0.702
##     sp3|t4            1.749    0.031   56.879    0.000    1.749    1.749
##     sp4|t1           -1.315    0.024  -55.868    0.000   -1.315   -1.315
##     sp4|t2           -0.238    0.017  -13.889    0.000   -0.238   -0.238
##     sp4|t3            0.789    0.019   41.441    0.000    0.789    0.789
##     sp4|t4            1.844    0.033   55.900    0.000    1.844    1.844
##     sp5|t1           -1.281    0.023  -55.372    0.000   -1.281   -1.281
##     sp5|t2           -0.186    0.017  -10.917    0.000   -0.186   -0.186
##     sp5|t3            0.891    0.020   45.315    0.000    0.891    0.891
##     sp5|t4            2.043    0.039   52.677    0.000    2.043    2.043
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.511                               0.511    0.511
##    .hc2               0.460                               0.460    0.460
##    .hc3               0.531                               0.531    0.531
##    .hc4               0.504                               0.504    0.504
##    .hc5               0.475                               0.475    0.475
##    .sc1               0.474                               0.474    0.474
##    .sc2               0.477                               0.477    0.477
##    .sc3               0.534                               0.534    0.534
##    .sc4               0.478                               0.478    0.478
##    .sc5               0.515                               0.515    0.515
##    .ir1               0.532                               0.532    0.532
##    .ir2               0.501                               0.501    0.501
##    .ir3               0.494                               0.494    0.494
##    .ir4               0.551                               0.551    0.551
##    .ir5               0.522                               0.522    0.522
##    .sp1               0.468                               0.468    0.468
##    .sp2               0.479                               0.479    0.479
##    .sp3               0.452                               0.452    0.452
##    .sp4               0.491                               0.491    0.491
##    .sp5               0.505                               0.505    0.505
##     intrinsic         0.489    0.012   42.375    0.000    1.000    1.000
##     extrinsic         0.468    0.012   38.504    0.000    1.000    1.000
#Model 4: 2-order solution
rfq_omod4 <- '#1st order
             hc =~ hc1 + hc2 + hc3 + hc4 + hc5
             sc =~ sc1 + sc2 + sc3 + sc4 + sc5
             ir =~ ir1 + ir2 + ir3 + ir4 + ir5
             sp =~ sp1 + sp2 + sp3 + sp4 + sp5
             
             #2nd order
             intrinsic =~ hc + sc
             extrinsic =~ ir + sp
             '
rfq_omod4_fit <- cfa(rfq_omod4, 
                     data = data_cleaned, 
                     estimator = "WLSMV", 
                     ordered = rfq_items
                     )
summary(rfq_omod4_fit, 
        standardized = TRUE, 
        fit.measures = TRUE
        )
## lavaan 0.6-19 ended normally after 51 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       105
## 
##   Number of observations                          5457
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                92.175     165.300
##   Degrees of freedom                               165         165
##   P-value (Chi-square)                           1.000       0.479
##   Scaling correction factor                                  0.764
##   Shift parameter                                           44.693
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                            204417.968   80216.076
##   Degrees of freedom                               190         190
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.552
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       1.000
##   Tucker-Lewis Index (TLI)                       1.000       1.000
##                                                                   
##   Robust Comparative Fit Index (CFI)                         0.999
##   Robust Tucker-Lewis Index (TLI)                            0.999
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.001
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.000       0.006
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                               0.006
##   90 Percent confidence interval - lower                     0.000
##   90 Percent confidence interval - upper                     0.010
##   P-value H_0: Robust RMSEA <= 0.050                         1.000
##   P-value H_0: Robust RMSEA >= 0.080                         0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.009       0.009
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   hc =~                                                                 
##     hc1               1.000                               0.773    0.773
##     hc2               1.046    0.014   74.557    0.000    0.808    0.808
##     hc3               0.978    0.014   69.517    0.000    0.756    0.756
##     hc4               1.009    0.014   72.244    0.000    0.780    0.780
##     hc5               1.034    0.014   74.441    0.000    0.799    0.799
##   sc =~                                                                 
##     sc1               1.000                               0.789    0.789
##     sc2               1.001    0.014   72.594    0.000    0.790    0.790
##     sc3               0.943    0.014   66.507    0.000    0.744    0.744
##     sc4               0.999    0.013   74.502    0.000    0.788    0.788
##     sc5               0.962    0.014   68.402    0.000    0.759    0.759
##   ir =~                                                                 
##     ir1               1.000                               0.751    0.751
##     ir2               1.031    0.016   66.194    0.000    0.775    0.775
##     ir3               1.039    0.016   66.376    0.000    0.781    0.781
##     ir4               0.979    0.016   62.313    0.000    0.736    0.736
##     ir5               1.011    0.016   62.629    0.000    0.760    0.760
##   sp =~                                                                 
##     sp1               1.000                               0.781    0.781
##     sp2               0.990    0.014   71.725    0.000    0.773    0.773
##     sp3               1.012    0.014   72.815    0.000    0.791    0.791
##     sp4               0.976    0.014   69.670    0.000    0.763    0.763
##     sp5               0.962    0.014   68.460    0.000    0.751    0.751
##   intrinsic =~                                                          
##     hc                1.000                               0.693    0.693
##     sc                1.262    0.052   24.502    0.000    0.857    0.857
##   extrinsic =~                                                          
##     ir                1.000                               0.762    0.762
##     sp                1.193    0.044   26.941    0.000    0.874    0.874
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   intrinsic ~~                                                          
##     extrinsic         0.168    0.008   19.862    0.000    0.548    0.548
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     hc1|t1           -1.435    0.025  -57.111    0.000   -1.435   -1.435
##     hc1|t2           -0.403    0.017  -23.040    0.000   -0.403   -0.403
##     hc1|t3            0.617    0.018   33.906    0.000    0.617    0.617
##     hc1|t4            1.695    0.030   57.265    0.000    1.695    1.695
##     hc2|t1           -1.492    0.026  -57.442    0.000   -1.492   -1.492
##     hc2|t2           -0.498    0.018  -28.036    0.000   -0.498   -0.498
##     hc2|t3            0.528    0.018   29.578    0.000    0.528    0.528
##     hc2|t4            1.517    0.026   57.529    0.000    1.517    1.517
##     hc3|t1           -1.336    0.024  -56.142    0.000   -1.336   -1.336
##     hc3|t2           -0.256    0.017  -14.914    0.000   -0.256   -0.256
##     hc3|t3            0.845    0.019   43.644    0.000    0.845    0.845
##     hc3|t4            1.910    0.035   54.984    0.000    1.910    1.910
##     hc4|t1           -1.365    0.024  -56.477    0.000   -1.365   -1.365
##     hc4|t2           -0.314    0.017  -18.149    0.000   -0.314   -0.314
##     hc4|t3            0.750    0.019   39.841    0.000    0.750    0.750
##     hc4|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     hc5|t1           -1.442    0.025  -57.166    0.000   -1.442   -1.442
##     hc5|t2           -0.451    0.018  -25.636    0.000   -0.451   -0.451
##     hc5|t3            0.559    0.018   31.114    0.000    0.559    0.559
##     hc5|t4            1.612    0.028   57.582    0.000    1.612    1.612
##     sc1|t1           -1.531    0.027  -57.567    0.000   -1.531   -1.531
##     sc1|t2           -0.472    0.018  -26.731    0.000   -0.472   -0.472
##     sc1|t3            0.573    0.018   31.801    0.000    0.573    0.573
##     sc1|t4            1.634    0.028   57.529    0.000    1.634    1.634
##     sc2|t1           -1.603    0.028  -57.595    0.000   -1.603   -1.603
##     sc2|t2           -0.586    0.018  -32.434    0.000   -0.586   -0.586
##     sc2|t3            0.413    0.018   23.603    0.000    0.413    0.413
##     sc2|t4            1.460    0.025   57.275    0.000    1.460    1.460
##     sc3|t1           -1.474    0.026  -57.358    0.000   -1.474   -1.474
##     sc3|t2           -0.378    0.017  -21.698    0.000   -0.378   -0.378
##     sc3|t3            0.738    0.019   39.330    0.000    0.738    0.738
##     sc3|t4            1.814    0.032   56.245    0.000    1.814    1.814
##     sc4|t1           -1.581    0.027  -57.615    0.000   -1.581   -1.581
##     sc4|t2           -0.507    0.018  -28.488    0.000   -0.507   -0.507
##     sc4|t3            0.494    0.018   27.850    0.000    0.494    0.494
##     sc4|t4            1.534    0.027   57.573    0.000    1.534    1.534
##     sc5|t1           -1.512    0.026  -57.515    0.000   -1.512   -1.512
##     sc5|t2           -0.438    0.018  -24.941    0.000   -0.438   -0.438
##     sc5|t3            0.626    0.018   34.352    0.000    0.626    0.626
##     sc5|t4            1.700    0.030   57.230    0.000    1.700    1.700
##     ir1|t1           -1.177    0.022  -53.462    0.000   -1.177   -1.177
##     ir1|t2           -0.106    0.017   -6.212    0.000   -0.106   -0.106
##     ir1|t3            1.001    0.020   48.938    0.000    1.001    1.001
##     ir1|t4            2.074    0.040   52.061    0.000    2.074    2.074
##     ir2|t1           -1.230    0.023  -54.504    0.000   -1.230   -1.230
##     ir2|t2           -0.181    0.017  -10.620    0.000   -0.181   -0.181
##     ir2|t3            0.872    0.020   44.631    0.000    0.872    0.872
##     ir2|t4            1.940    0.036   54.528    0.000    1.940    1.940
##     ir3|t1           -1.276    0.023  -55.290    0.000   -1.276   -1.276
##     ir3|t2           -0.250    0.017  -14.563    0.000   -0.250   -0.250
##     ir3|t3            0.812    0.019   42.373    0.000    0.812    0.812
##     ir3|t4            1.839    0.033   55.961    0.000    1.839    1.839
##     ir4|t1           -1.161    0.022  -53.130    0.000   -1.161   -1.161
##     ir4|t2           -0.083    0.017   -4.859    0.000   -0.083   -0.083
##     ir4|t3            1.029    0.021   49.777    0.000    1.029    1.029
##     ir4|t4            2.102    0.041   51.464    0.000    2.102    2.102
##     ir5|t1           -1.227    0.023  -54.451    0.000   -1.227   -1.227
##     ir5|t2           -0.169    0.017   -9.917    0.000   -0.169   -0.169
##     ir5|t3            0.938    0.020   46.952    0.000    0.938    0.938
##     ir5|t4            2.086    0.040   51.812    0.000    2.086    2.086
##     sp1|t1           -1.326    0.024  -56.014    0.000   -1.326   -1.326
##     sp1|t2           -0.263    0.017  -15.319    0.000   -0.263   -0.263
##     sp1|t3            0.780    0.019   41.087    0.000    0.780    0.780
##     sp1|t4            1.841    0.033   55.931    0.000    1.841    1.841
##     sp2|t1           -1.238    0.023  -54.646    0.000   -1.238   -1.238
##     sp2|t2           -0.200    0.017  -11.674    0.000   -0.200   -0.200
##     sp2|t3            0.857    0.019   44.089    0.000    0.857    0.857
##     sp2|t4            1.872    0.034   55.533    0.000    1.872    1.872
##     sp3|t1           -1.338    0.024  -56.156    0.000   -1.338   -1.338
##     sp3|t2           -0.324    0.017  -18.714    0.000   -0.324   -0.324
##     sp3|t3            0.702    0.019   37.786    0.000    0.702    0.702
##     sp3|t4            1.749    0.031   56.879    0.000    1.749    1.749
##     sp4|t1           -1.315    0.024  -55.868    0.000   -1.315   -1.315
##     sp4|t2           -0.238    0.017  -13.889    0.000   -0.238   -0.238
##     sp4|t3            0.789    0.019   41.441    0.000    0.789    0.789
##     sp4|t4            1.844    0.033   55.900    0.000    1.844    1.844
##     sp5|t1           -1.281    0.023  -55.372    0.000   -1.281   -1.281
##     sp5|t2           -0.186    0.017  -10.917    0.000   -0.186   -0.186
##     sp5|t3            0.891    0.020   45.315    0.000    0.891    0.891
##     sp5|t4            2.043    0.039   52.677    0.000    2.043    2.043
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .hc1               0.403                               0.403    0.403
##    .hc2               0.346                               0.346    0.346
##    .hc3               0.429                               0.429    0.429
##    .hc4               0.392                               0.392    0.392
##    .hc5               0.361                               0.361    0.361
##    .sc1               0.378                               0.378    0.378
##    .sc2               0.376                               0.376    0.376
##    .sc3               0.447                               0.447    0.447
##    .sc4               0.379                               0.379    0.379
##    .sc5               0.424                               0.424    0.424
##    .ir1               0.435                               0.435    0.435
##    .ir2               0.400                               0.400    0.400
##    .ir3               0.391                               0.391    0.391
##    .ir4               0.458                               0.458    0.458
##    .ir5               0.423                               0.423    0.423
##    .sp1               0.390                               0.390    0.390
##    .sp2               0.402                               0.402    0.402
##    .sp3               0.375                               0.375    0.375
##    .sp4               0.418                               0.418    0.418
##    .sp5               0.436                               0.436    0.436
##    .hc                0.311    0.014   22.171    0.000    0.520    0.520
##    .sc                0.165    0.019    8.836    0.000    0.266    0.266
##    .ir                0.237    0.013   17.701    0.000    0.420    0.420
##    .sp                0.144    0.017    8.491    0.000    0.236    0.236
##     intrinsic         0.287    0.015   19.636    0.000    1.000    1.000
##     extrinsic         0.327    0.015   21.783    0.000    1.000    1.000
#Relative fitness between the multidimensional solutions and the unidimensional solution
anova(rfq_omod1_fit, rfq_omod2_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##                Df AIC BIC    Chisq Chisq diff Df diff Pr(>Chisq)    
## rfq_omod2_fit 164            92.04                                  
## rfq_omod1_fit 170         33513.45     6401.8       6  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(rfq_omod1_fit, rfq_omod3_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##                Df AIC BIC   Chisq Chisq diff Df diff Pr(>Chisq)    
## rfq_omod3_fit 169          8788.2                                  
## rfq_omod1_fit 170         33513.5     2546.2       1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
anova(rfq_omod1_fit, rfq_omod4_fit)
## 
## Scaled Chi-Squared Difference Test (method = "satorra.2000")
## 
## lavaan->lavTestLRT():  
##    lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
##    robust test that should be reported per model. A robust difference test is 
##    a function of two standard (not robust) statistics.
##                Df AIC BIC     Chisq Chisq diff Df diff Pr(>Chisq)    
## rfq_omod4_fit 165            92.175                                  
## rfq_omod1_fit 170         33513.452     5950.1       5  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Select the most plausible continuous and ordinal RFQ models
rfq_cselect_fit <- 
rfq_oselect_fit <- 

#Explore the modification indices of the selected WISMD-37 structural model 
rfq_mi <- modificationIndices(...)

#Reconstruct the selected models following hypothesis-consistent modifications
rfq_cmodified <- 
rfq_omodified <- 
#Calculate composite reliability for the selected continuous and ordinal RFQ model
rfq_cont_rel <- compRelSEM(...)
print(rfq_cont_rel, digits = 3)

rfq_ord_rel <- compRelSEM(...)
print(rfq_ord_rel, digits = 3)
#Calculate the corrected item-total correlation for the selected RFQ model

#Store items of each factors
#Calculate the RFQ scores
data_cleaned$hc = rowMeans(data_cleaned[,c(22, 26, 30, 34, 39)])
data_cleaned$sc = rowMeans(data_cleaned[,c(23, 27, 31, 36, 40)])
data_cleaned$ir = rowMeans(data_cleaned[,c(24, 28, 32, 37, 41)])
data_cleaned$sp = rowMeans(data_cleaned[,c(25, 29, 33, 38, 42)])
data_cleaned$intrinsic = rowMeans(data_cleaned[,c(118, 119)])
data_cleaned$extrinsic = rowMeans(data_cleaned[,c(120, 121)])

#Robust multiple linear regression analysis:

#RFQ factors -> dependence on cigarettes
rfq_time <- multinom(time_since_quitting ~ hc + sc + ir + sp, 
                     data = data_cleaned,
                     )
## # weights:  18 (10 variable)
## initial  value 5995.127259 
## iter  10 value 5885.425176
## final  value 5874.165673 
## converged
rfq_time_sum <- summary(rfq_time)

z_vals <- rfq_time_sum$coefficients / rfq_time_sum$standard.errors
p_vals <- 2 * (1 - pnorm(abs(z_vals)))

rfq_time_sum
## Call:
## multinom(formula = time_since_quitting ~ hc + sc + ir + sp, data = data_cleaned)
## 
## Coefficients:
##                    (Intercept)           hc          sc           ir         sp
## => 1 year           -0.6336889 -0.001657043  0.03124429 -0.007280025 0.04333373
## 6 months to 1 year  -0.1170516 -0.006777783 -0.03977053 -0.023712100 0.07699098
## 
## Std. Errors:
##                    (Intercept)         hc         sc         ir         sp
## => 1 year            0.1187273 0.05220082 0.05453709 0.05754741 0.05686789
## 6 months to 1 year   0.1051800 0.04652587 0.04860551 0.05130505 0.05067117
## 
## Residual Deviance: 11748.33 
## AIC: 11768.33
p_vals
##                     (Intercept)        hc        sc        ir        sp
## => 1 year          9.431715e-08 0.9746765 0.5667125 0.8993323 0.4460558
## 6 months to 1 year 2.657645e-01 0.8841758 0.4132253 0.6439532 0.1286559