library(tidySEM)
library(lavaan)
## This is lavaan 0.6-21
## lavaan is FREE software! Please report any bugs.
library(readxl)
library(ggplot2)
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
##
## Attaching package: 'compareGroups'
## The following object is masked from 'package:tidySEM':
##
## report
setwd("C:/Users/mvx13/OneDrive - Texas State University/Papers/2025/00_NewPapers/Survey/PewSurvey/W152")
df= read.csv("ATP W152_Cat.csv")
head(df)
## QKEY INTERVIEW_START_W152 INTERVIEW_END_W152 DEVICE_TYPE_W152
## 1 Min. Val. 8/15/2024 15:30 8/15/2024 15:40 Mobile
## 2 103379 8/15/2024 13:58 8/15/2024 14:21 Desktop
## 3 104727 8/15/2024 7:18 8/15/2024 7:24 Mobile
## 4 106590 8/13/2024 22:30 8/13/2024 22:36 Mobile
## 5 107668 8/13/2024 15:23 8/13/2024 15:30 Mobile
## 6 108435 8/13/2024 15:00 8/13/2024 15:07 Mobile
## SVYMODE_W152 LANG_W152 FORM_W152 AI_HEARD_W152 CNCEXC_W152
## 1 Web English Form 1 A little More concerned than excited
## 2 Web English Form 1 A little More concerned than excited
## 3 Web English Form 2 A little Equally concerned and excited
## 4 Web English Form 1 A little More concerned than excited
## 5 Web English Form 2 A little More concerned than excited
## 6 Web English Form 1 A little More concerned than excited
## USEAI_W152 AICONTROL1_W152
## 1 Less often Some
## 2 Less often None
## 3 Less often Quite a bit
## 4 Less often None
## 5 About once a day Not too much
## 6 Several times a day Not too much
## AICONTROL2_W152
## 1 Not sure
## 2 I'd like more control over how AI is used in my life
## 3 I'd like more control over how AI is used in my life
## 4 I'd like more control over how AI is used in my life
## 5 I'd like more control over how AI is used in my life
## 6 I'd like more control over how AI is used in my life
## AICHANGE_W152 AIFUTRIMPCT_a_W152
## 1 Not sure Somewhat positive
## 2 Somewhat negative Somewhat positive
## 3 Equally positive and negative No Response
## 4 Very negative Somewhat positive
## 5 Somewhat negative No Response
## 6 Somewhat negative Not sure
## AIFUTRIMPCT_b_W152 AIFUTRIMPCT_c_W152
## 1 Somewhat positive Equally positive and negative
## 2 Equally positive and negative Somewhat negative
## 3 No Response No Response
## 4 Somewhat negative Somewhat negative
## 5 No Response No Response
## 6 Somewhat negative Somewhat negative
## AIFUTRIMPCT_d_W152 AIFUTRIMPCT_e_W152
## 1 Somewhat positive Equally positive and negative
## 2 Somewhat negative Very negative
## 3 No Response No Response
## 4 Equally positive and negative Not sure
## 5 No Response No Response
## 6 Somewhat negative Not sure
## AIFUTRIMPCT_f_W152 AIFUTRIMPCT_g_W152
## 1 No Response No Response
## 2 No Response No Response
## 3 Equally positive and negative Not sure
## 4 No Response No Response
## 5 Somewhat negative Somewhat negative
## 6 No Response No Response
## AIFUTRIMPCT_h_W152 AIFUTRIMPCT_i_W152 AIFUTRIMPCT_j_W152
## 1 No Response No Response No Response
## 2 No Response No Response No Response
## 3 Equally positive and negative Not sure Very negative
## 4 No Response No Response No Response
## 5 Equally positive and negative Not sure Somewhat negative
## 6 No Response No Response No Response
## AIJOBS_W152 AIJOBIMPCT_a_W152 AIJOBIMPCT_b_W152
## 1 Fewer jobs Will not make much difference More jobs
## 2 Will not make much difference More jobs More jobs
## 3 Fewer jobs No Response No Response
## 4 Fewer jobs Will not make much difference Fewer jobs
## 5 Fewer jobs No Response No Response
## 6 Fewer jobs Fewer jobs Fewer jobs
## AIJOBIMPCT_c_W152 AIJOBIMPCT_d_W152 AIJOBIMPCT_e_W152
## 1 Fewer jobs Fewer jobs Will not make much difference
## 2 Fewer jobs Fewer jobs Will not make much difference
## 3 No Response No Response No Response
## 4 Fewer jobs Fewer jobs Will not make much difference
## 5 No Response No Response No Response
## 6 Fewer jobs Not sure Will not make much difference
## AIJOBIMPCT_f_W152 AIJOBIMPCT_g_W152 AIJOBIMPCT_h_W152
## 1 No Response No Response No Response
## 2 No Response No Response No Response
## 3 Fewer jobs Fewer jobs Will not make much difference
## 4 No Response No Response No Response
## 5 Fewer jobs Fewer jobs Will not make much difference
## 6 No Response No Response No Response
## AIJOBIMPCT_i_W152 AIJOBIMPCT_j_W152
## 1 No Response No Response
## 2 No Response No Response
## 3 Fewer jobs Will not make much difference
## 4 No Response No Response
## 5 Not sure Will not make much difference
## 6 No Response No Response
## HUMANVAI_a_W152 HUMANVAI_b_W152
## 1 AI would do this better Not sure
## 2 AI would do this about the same AI would do this worse
## 3 AI would do this worse AI would do this worse
## 4 Not sure AI would do this better
## 5 AI would do this better AI would do this about the same
## 6 AI would do this worse AI would do this worse
## HUMANVAI_c_W152 HUMANVAI_d_W152
## 1 Not sure Not sure
## 2 AI would do this worse AI would do this about the same
## 3 AI would do this worse AI would do this worse
## 4 AI would do this worse AI would do this better
## 5 AI would do this worse Not sure
## 6 AI would do this worse AI would do this worse
## HUMANVAI_e_W152 HUMANVAI_f_W152
## 1 Not sure Not sure
## 2 AI would do this worse AI would do this worse
## 3 AI would do this worse AI would do this worse
## 4 AI would do this about the same AI would do this better
## 5 AI would do this worse AI would do this worse
## 6 AI would do this worse Not sure
## HUMANVAI_g_W152 HUMANVAI_h_W152
## 1 Not sure Not sure
## 2 AI would do this worse AI would do this worse
## 3 AI would do this worse AI would do this worse
## 4 Not sure Not sure
## 5 AI would do this worse AI would do this about the same
## 6 AI would do this about the same AI would do this worse
## PERSBENHRM_W152 TRSTAIPRS_W152 AICONCERN_a_W152
## 1 Not sure Not sure Somewhat concerned
## 2 Harm you than benefit you No, it will not Very concerned
## 3 Not sure No, it will not Extremely concerned
## 4 Harm you than benefit you No, it will not Extremely concerned
## 5 Not sure No, it will not Somewhat concerned
## 6 Not sure No, it will not Very concerned
## AICONCERN_b_W152 AICONCERN_c_W152 AICONCERN_d_W152
## 1 Somewhat concerned Somewhat concerned Somewhat concerned
## 2 Extremely concerned Very concerned Extremely concerned
## 3 Extremely concerned Extremely concerned Very concerned
## 4 Extremely concerned Extremely concerned Extremely concerned
## 5 Extremely concerned Very concerned Very concerned
## 6 Very concerned Very concerned Very concerned
## AICONCERN_e_W152 AICONCERN_f_W152 AICONCERN_g_W152 FUTRAI_a_W152
## 1 Somewhat concerned Somewhat concerned Somewhat concerned Very likely
## 2 Very concerned Very concerned Very concerned Somewhat likely
## 3 Extremely concerned Extremely concerned Very concerned Very likely
## 4 Not too concerned Extremely concerned Very concerned Extremely likely
## 5 Very concerned Very concerned Very concerned Very likely
## 6 Very concerned Somewhat concerned Somewhat concerned Not too likely
## FUTRAI_b_W152 FUTRAI_c_W152 FUTRAI_d_W152 DISCRIM1_a_W152
## 1 Very likely Somewhat likely Somewhat likely Not sure
## 2 Very likely Not at all likely Not at all likely Not too well
## 3 Very likely Not too likely Not too likely Not sure
## 4 Extremely likely Not at all likely Not at all likely Not too well
## 5 Somewhat likely Not too likely Not too likely Not sure
## 6 Not sure Somewhat likely Not too likely Not sure
## DISCRIM1_b_W152 DISCRIM1_c_W152 DISCRIM1_d_W152 DISCRIM1_e_W152
## 1 Not sure Not sure Not sure Not sure
## 2 Not at all well Not too well Not too well Not at all well
## 3 Not sure Not sure Not sure Not sure
## 4 Not at all well Not at all well Not at all well Not sure
## 5 Not sure Not sure Not sure Very well
## 6 Not sure Not sure Not sure Not sure
## DISCRIM1_f_W152 AIREG_W152 REGCONFG_W152
## 1 Not sure Go too far regulating its use Not sure
## 2 Not at all well Go too far regulating its use None
## 3 Not sure Not go far enough regulating its use None
## 4 Not sure Not go far enough regulating its use Not too much
## 5 Not sure Not go far enough regulating its use Not too much
## 6 Not sure Not sure Not too much
## REGCONFI_W152 CHATAWARE_W152 CHATUSE_W152 CHATHELPFUL_W152
## 1 Quite a bit Nothing at all No Response No Response
## 2 None Nothing at all No Response No Response
## 3 None Nothing at all No Response No Response
## 4 Not too much Nothing at all No Response No Response
## 5 Not too much A little No, I have not No Response
## 6 Not too much A little No, I have not No Response
## DRIVE1_W152 DRIVE2_a_W152 DRIVE2_b_W152 DRIVE2_c_W152
## 1 Somewhat less safely Major problem Major problem Major problem
## 2 A lot less safely Major problem Major problem Minor problem
## 3 Somewhat less safely Major problem Minor problem Minor problem
## 4 Neither more nor less safely Minor problem Major problem Major problem
## 5 Somewhat less safely Minor problem Minor problem Major problem
## 6 Somewhat more safely Minor problem Major problem Minor problem
## DRIVE2_d_W152 DRIVE2_e_W152 DRIVE2_f_W152 DRIVE3_W152
## 1 Major problem Major problem Major problem Very often
## 2 Minor problem Minor problem Minor problem Very often
## 3 Not a problem Major problem Minor problem Sometimes
## 4 Major problem Major problem Major problem Very often
## 5 Major problem Major problem Minor problem Rarely
## 6 Don't know/Refused/Web blank Major problem Minor problem Sometimes
## DRIVER_W152 F_METRO F_CREGION F_CDIVISION F_USR_SELFID
## 1 Daily Non-metropolitan Midwest East North Central Rural
## 2 Daily Metropolitan South South Atlantic Suburban
## 3 Daily Non-metropolitan Midwest East North Central Rural
## 4 Daily Metropolitan West Pacific Suburban
## 5 Daily Non-metropolitan South West South Central Rural
## 6 A few times a week Metropolitan Midwest East North Central Suburban
## F_AGECAT F_GENDER F_EDUCCAT F_EDUCCAT2
## 1 65+ A man Some College Some college, no degree
## 2 65+ A man Some College Some college, no degree
## 3 50-64 A man H.S. graduate or less High school graduate
## 4 50-64 A woman College graduate+ Postgraduate
## 5 50-64 A woman College graduate+ College graduate/some post grad
## 6 65+ A woman College graduate+ Postgraduate
## F_HISP F_HISP_ORIGIN F_YEARSINUS_RECODE
## 1 No No Response Born in US (not including unincorporated territories)
## 2 No No Response Born in US (not including unincorporated territories)
## 3 No No Response Born in US (not including unincorporated territories)
## 4 No No Response Born in US (not including unincorporated territories)
## 5 No No Response Born in US (not including unincorporated territories)
## 6 No No Response Born in US (not including unincorporated territories)
## F_RACECMB F_RACETHNMOD F_BIRTHPLACE
## 1 White White non-Hispanic U.S. 50 states, District of Columbia
## 2 White White non-Hispanic U.S. 50 states, District of Columbia
## 3 White White non-Hispanic U.S. 50 states, District of Columbia
## 4 White White non-Hispanic U.S. 50 states, District of Columbia
## 5 White White non-Hispanic U.S. 50 states, District of Columbia
## 6 White White non-Hispanic U.S. 50 states, District of Columbia
## F_MARITAL F_RELIG
## 1 Married Protestant
## 2 Married Protestant
## 3 Married Nothing in particular
## 4 Married Nothing in particular
## 5 Never been married Nothing in particular
## 6 Married Roman Catholic
## F_BORN F_RELIGCAT1 F_ATTENDPER
## 1 No, not born-again or evangelical Christian Protestant Seldom
## 2 Yes, born-again or evangelical Christian Protestant Once a week
## 3 No Response Unaffiliated Never
## 4 No Response Unaffiliated Seldom
## 5 No Response Unaffiliated Never
## 6 No, not born-again or evangelical Christian Catholic A few times a year
## F_PARTY_FINAL F_PARTYLN_FINAL F_PARTYSUM_FINAL F_PARTYSUMIDEO_FINAL
## 1 Republican No Response Rep/Lean Rep Moderate/Liberal Rep/Lean
## 2 Republican No Response Rep/Lean Rep Conservative Rep/Lean
## 3 Republican No Response Rep/Lean Rep Conservative Rep/Lean
## 4 Independent The Republican Party Rep/Lean Rep Moderate/Liberal Rep/Lean
## 5 Independent The Republican Party Rep/Lean Rep Moderate/Liberal Rep/Lean
## 6 Republican No Response Rep/Lean Rep Conservative Rep/Lean
## F_REG
## 1 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## 2 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## 3 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## 4 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## 5 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## 6 You are ABSOLUTELY CERTAIN that you are registered to vote at your current address
## F_INC_SDT1 F_IDEO F_INTFREQ F_VOLSUM
## 1 $80,000 to less than $90,000 Moderate About once a day Yes
## 2 $100,000 or more Conservative Less often No
## 3 Refused Conservative Several times a day No
## 4 $90,000 to less than $100,000 Moderate Several times a day Yes
## 5 $100,000 or more Moderate Almost constantly Yes
## 6 $100,000 or more Conservative Several times a day No
## F_INC_TIER2 WEIGHT_W152
## 1 Middle income 0.6397686
## 2 Upper income 1.3388399
## 3 Refused 0.9093601
## 4 Middle income 0.9198955
## 5 Upper income 0.7199926
## 6 Upper income 0.9483941
## [1] "QKEY" "INTERVIEW_START_W152" "INTERVIEW_END_W152"
## [4] "DEVICE_TYPE_W152" "SVYMODE_W152" "LANG_W152"
## [7] "FORM_W152" "AI_HEARD_W152" "CNCEXC_W152"
## [10] "USEAI_W152" "AICONTROL1_W152" "AICONTROL2_W152"
## [13] "AICHANGE_W152" "AIFUTRIMPCT_a_W152" "AIFUTRIMPCT_b_W152"
## [16] "AIFUTRIMPCT_c_W152" "AIFUTRIMPCT_d_W152" "AIFUTRIMPCT_e_W152"
## [19] "AIFUTRIMPCT_f_W152" "AIFUTRIMPCT_g_W152" "AIFUTRIMPCT_h_W152"
## [22] "AIFUTRIMPCT_i_W152" "AIFUTRIMPCT_j_W152" "AIJOBS_W152"
## [25] "AIJOBIMPCT_a_W152" "AIJOBIMPCT_b_W152" "AIJOBIMPCT_c_W152"
## [28] "AIJOBIMPCT_d_W152" "AIJOBIMPCT_e_W152" "AIJOBIMPCT_f_W152"
## [31] "AIJOBIMPCT_g_W152" "AIJOBIMPCT_h_W152" "AIJOBIMPCT_i_W152"
## [34] "AIJOBIMPCT_j_W152" "HUMANVAI_a_W152" "HUMANVAI_b_W152"
## [37] "HUMANVAI_c_W152" "HUMANVAI_d_W152" "HUMANVAI_e_W152"
## [40] "HUMANVAI_f_W152" "HUMANVAI_g_W152" "HUMANVAI_h_W152"
## [43] "PERSBENHRM_W152" "TRSTAIPRS_W152" "AICONCERN_a_W152"
## [46] "AICONCERN_b_W152" "AICONCERN_c_W152" "AICONCERN_d_W152"
## [49] "AICONCERN_e_W152" "AICONCERN_f_W152" "AICONCERN_g_W152"
## [52] "FUTRAI_a_W152" "FUTRAI_b_W152" "FUTRAI_c_W152"
## [55] "FUTRAI_d_W152" "DISCRIM1_a_W152" "DISCRIM1_b_W152"
## [58] "DISCRIM1_c_W152" "DISCRIM1_d_W152" "DISCRIM1_e_W152"
## [61] "DISCRIM1_f_W152" "AIREG_W152" "REGCONFG_W152"
## [64] "REGCONFI_W152" "CHATAWARE_W152" "CHATUSE_W152"
## [67] "CHATHELPFUL_W152" "DRIVE1_W152" "DRIVE2_a_W152"
## [70] "DRIVE2_b_W152" "DRIVE2_c_W152" "DRIVE2_d_W152"
## [73] "DRIVE2_e_W152" "DRIVE2_f_W152" "DRIVE3_W152"
## [76] "DRIVER_W152" "F_METRO" "F_CREGION"
## [79] "F_CDIVISION" "F_USR_SELFID" "F_AGECAT"
## [82] "F_GENDER" "F_EDUCCAT" "F_EDUCCAT2"
## [85] "F_HISP" "F_HISP_ORIGIN" "F_YEARSINUS_RECODE"
## [88] "F_RACECMB" "F_RACETHNMOD" "F_BIRTHPLACE"
## [91] "F_MARITAL" "F_RELIG" "F_BORN"
## [94] "F_RELIGCAT1" "F_ATTENDPER" "F_PARTY_FINAL"
## [97] "F_PARTYLN_FINAL" "F_PARTYSUM_FINAL" "F_PARTYSUMIDEO_FINAL"
## [100] "F_REG" "F_INC_SDT1" "F_IDEO"
## [103] "F_INTFREQ" "F_VOLSUM" "F_INC_TIER2"
## [106] "WEIGHT_W152"
concern_levels <- c(
"Not at all concerned",
"Not too concerned",
"Somewhat concerned",
"Very concerned",
"Extremely concerned"
)
df2 <- df %>%
mutate(
across(c(F_USR_SELFID, F_AGECAT, F_GENDER, F_EDUCCAT),
~na_if(.x, "Refused")),
across(c(F_USR_SELFID, F_AGECAT, F_GENDER, F_EDUCCAT),
~na_if(.x, "Don't know/Refused/Web blank"))
) %>%
mutate(
across(starts_with("AICONCERN_"),
~factor(.x, levels = concern_levels, ordered = TRUE))
)
library(lavaan)
demovars <- c("F_CDIVISION","F_USR_SELFID","F_AGECAT","F_GENDER","F_EDUCCAT")
df_cc <- df2 %>% filter(if_all(all_of(demovars), ~ !is.na(.x)))
X <- model.matrix(~ F_USR_SELFID + F_AGECAT + F_GENDER + F_EDUCCAT,
data = df_cc)
X <- X[, colnames(X) != "(Intercept)", drop = FALSE]
# after you build X with model.matrix(...)
colnames(X) <- make.names(colnames(X)) # makes names syntactically valid in R
colnames(X) <- gsub("\\.", "_", colnames(X))# optional: replace dots with underscores
df_sem <- bind_cols(df_cc, as.data.frame(X))
items <- c("AICONCERN_a_W152","AICONCERN_b_W152","AICONCERN_c_W152",
"AICONCERN_d_W152","AICONCERN_e_W152")
# Regress AIConcern on ALL dummies created above
rhs <- paste(colnames(X), collapse = " + ")
model <- paste0('
# measurement model (ordinal indicators)
AIConcern =~ ', paste(items, collapse = " + "), '
# structural part
AIConcern ~ ', rhs, '
')
fit <- sem(
model,
data = df_sem,
ordered = items, # tells lavaan these are ordinal
estimator = "WLSMV", # best practice for ordinal Likert
missing = "pairwise" # or "fiml" if using ML/MLR; WLSMV uses pairwise
)
## Warning: lavaan->lav_data_full():
## some cases are empty and will be ignored: 71 923 1627 3257 3291 3293 3583
## 4284.
summary(fit, fit.measures = TRUE, standardized = TRUE)
## lavaan 0.6-21 ended normally after 24 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 34
##
## Used Total
## Number of observations 5286 5294
## Number of missing patterns 13
##
## Model Test User Model:
## Standard Scaled
## Test Statistic 115.451 200.771
## Degrees of freedom 41 41
## P-value (Unknown) NA 0.000
## Scaling correction factor 0.600
## Shift parameter 8.361
## simple second-order correction
##
## Model Test Baseline Model:
##
## Test statistic 41019.832 23369.266
## Degrees of freedom 10 10
## P-value NA 0.000
## Scaling correction factor 1.756
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.998 0.993
## Tucker-Lewis Index (TLI) 1.000 0.998
##
## Robust Comparative Fit Index (CFI) NA
## Robust Tucker-Lewis Index (TLI) NA
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.019 0.027
## 90 Percent confidence interval - lower 0.015 0.023
## 90 Percent confidence interval - upper 0.023 0.031
## P-value H_0: RMSEA <= 0.050 1.000 1.000
## P-value H_0: RMSEA >= 0.080 0.000 0.000
##
## Robust RMSEA NA
## 90 Percent confidence interval - lower NA
## 90 Percent confidence interval - upper NA
## P-value H_0: Robust RMSEA <= 0.050 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.013 0.013
##
## 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
## AIConcern =~
## AICONCERN__W15 1.000 0.751 0.748
## AICONCERN__W15 1.056 0.012 87.889 0.000 0.793 0.790
## AICONCERN__W15 1.105 0.011 96.268 0.000 0.830 0.826
## AICONCERN__W15 1.106 0.012 95.535 0.000 0.830 0.827
## AICONCERN__W15 0.885 0.012 71.445 0.000 0.664 0.663
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## AIConcern ~
## F_USR_SELFIDSb -0.026 0.029 -0.880 0.379 -0.034 -0.017
## F_USR_SELFIDUr -0.047 0.034 -1.384 0.166 -0.062 -0.027
## F_AGECAT30_49 0.051 0.034 1.518 0.129 0.069 0.033
## F_AGECAT50_64 0.137 0.037 3.708 0.000 0.183 0.079
## F_AGECAT65_ 0.108 0.037 2.898 0.004 0.143 0.063
## F_GENDERA_womn 0.075 0.023 3.275 0.001 0.100 0.050
## F_GENDERIn_s__ 0.222 0.152 1.455 0.146 0.295 0.023
## F_EDUCCATH_S__ -0.102 0.029 -3.533 0.000 -0.135 -0.060
## F_EDUCCATSm_Cl 0.054 0.027 1.985 0.047 0.072 0.033
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## AICONCERN__W15 -1.868 0.066 -28.139 0.000 -1.868 -1.861
## AICONCERN__W15 -1.100 0.060 -18.461 0.000 -1.100 -1.096
## AICONCERN__W15 -0.136 0.058 -2.325 0.020 -0.136 -0.135
## AICONCERN__W15 0.549 0.059 9.374 0.000 0.549 0.547
## AICONCERN__W15 -2.082 0.074 -28.260 0.000 -2.082 -2.074
## AICONCERN__W15 -1.586 0.064 -24.706 0.000 -1.586 -1.580
## AICONCERN__W15 -0.734 0.061 -12.072 0.000 -0.734 -0.731
## AICONCERN__W15 0.081 0.060 1.339 0.180 0.081 0.081
## AICONCERN__W15 -1.947 0.075 -26.094 0.000 -1.947 -1.938
## AICONCERN__W15 -1.329 0.064 -20.875 0.000 -1.329 -1.323
## AICONCERN__W15 -0.363 0.060 -6.028 0.000 -0.363 -0.362
## AICONCERN__W15 0.437 0.060 7.227 0.000 0.437 0.435
## AICONCERN__W15 -2.123 0.071 -29.822 0.000 -2.123 -2.113
## AICONCERN__W15 -1.503 0.062 -24.417 0.000 -1.503 -1.497
## AICONCERN__W15 -0.465 0.059 -7.877 0.000 -0.465 -0.463
## AICONCERN__W15 0.367 0.059 6.225 0.000 0.367 0.365
## AICONCERN__W15 -1.836 0.066 -27.806 0.000 -1.836 -1.831
## AICONCERN__W15 -1.125 0.059 -19.055 0.000 -1.125 -1.122
## AICONCERN__W15 -0.149 0.058 -2.578 0.010 -0.149 -0.148
## AICONCERN__W15 0.655 0.058 11.294 0.000 0.655 0.653
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .AICONCERN__W15 0.443 0.443 0.440
## .AICONCERN__W15 0.379 0.379 0.376
## .AICONCERN__W15 0.321 0.321 0.318
## .AICONCERN__W15 0.319 0.319 0.317
## .AICONCERN__W15 0.564 0.564 0.561
## .AIConcern 0.557 0.011 52.819 0.000 0.987 0.987
## fit <- sem(model, data=df_sem, ordered=items, estimator="WLSMV",
### sampling.weights = "WEIGHT", missing="pairwise")
library(tidySEM)
g <- prepare_graph(fit)
plot(g)

library(semPlot)
# Shorter labels (optional)
labs <- c(
AIConcern = "AI Concern",
AICONCERN_a_W152 = "A",
AICONCERN_b_W152 = "B",
AICONCERN_c_W152 = "C",
AICONCERN_d_W152 = "D",
AICONCERN_e_W152 = "E"
)
### png("sem_nice.png", width = 2600, height = 1800, res = 300)
semPaths(
fit,
what = "path",
whatLabels = "std", # standardized estimates look cleaner
style = "ram",
layout = "tree2", # good default for SEM
residuals = FALSE, # remove residual arrows (less clutter)
intercepts = FALSE,
thresholds = FALSE, # for ordinal indicators, hides thresholds
nCharNodes = 0,
nodeLabels = labs[semPlot::semPlotModel(fit)@Vars$name] %||% semPlotModel(fit)@Vars$name,
sizeMan = 7,
sizeLat = 10,
edge.label.cex = 0.9,
label.cex = 1.0,
curvePivot = TRUE,
mar = c(6, 6, 6, 6)
)
