library(readr)
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(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
options(scipen=999)

# Set working directory
setwd("/Users/melissalagunas/Desktop/Lab/DISSERTATION")

# Read datasets
quant_df <- read_csv("quant_data.csv")
## New names:
## Rows: 230 Columns: 18
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," dbl
## (18): ...1, age, gender, race, US_born, sexual_orientation, employment_s...
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
qual_df <- read_csv("qual_df.csv")
## New names:
## Rows: 187 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (3): year_education, SS_13_TEXT, PD dbl (1): ...1
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
jobs_df <- read_csv("job_classifications_results.csv")
## Rows: 173 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): job_title, soc_code, soc_description
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Add participant ID to each dataset
quant_df <- quant_df %>%
  mutate(Participant_ID = row_number())
qual_df <- qual_df %>%
  mutate(Participant_ID = row_number())
jobs_df <- jobs_df %>%
  mutate(Participant_ID = row_number())

# Merge datasets sequentially using left_join
merged_df <- quant_df %>%
  left_join(qual_df, by = "Participant_ID") %>%
  left_join(jobs_df, by = "Participant_ID")

# Print dimensions of all datasets to verify merge
cat("Dimensions of datasets:\n")
## Dimensions of datasets:
cat("Quantitative data:", dim(quant_df), "\n")
## Quantitative data: 230 19
cat("Qualitative data:", dim(qual_df), "\n")
## Qualitative data: 187 5
cat("Jobs data:", dim(jobs_df), "\n")
## Jobs data: 173 4
cat("Merged data:", dim(merged_df), "\n")
## Merged data: 230 26
# Optional: Check for any duplicate column names
duplicate_cols <- names(merged_df)[duplicated(names(merged_df))]
if(length(duplicate_cols) > 0) {
  warning("Duplicate column names found: ", paste(duplicate_cols, collapse = ", "))
}
# First create the new grouped fields mapping from SOC codes
soc_group_mapping <- c(
    # STEM & Technical (Group 1)
    '15-0000' = 1,  # Computer and Mathematical
    '19-0000' = 1,  # Life, Physical, and Social Science
    '17-0000' = 1,  # Architecture and Engineering
    
    # Education & Community Services (Group 2)
    '25-0000' = 2,  # Educational Instruction and Library
    '21-0000' = 2,  # Community and Social Service
    
    # Healthcare & Medical (Group 3)
    '29-0000' = 3,  # Healthcare Practitioners and Technical
    
    # Business & Management (Group 4)
    '13-0000' = 4,  # Business and Financial Operations
    '11-0000' = 4,  # Management
    
    # Other Professional Services (Group 5)
    '51-0000' = 5,  # Production
    '53-0000' = 5,  # Transportation and Material Moving
    '27-0000' = 5,  # Arts, Design, Entertainment, Sports, Media
    '23-0000' = 5,  # Legal
    '37-0000' = 5,  # Building/Grounds Maintenance
    '45-0000' = 5,  # Farming, Fishing, Forestry
    '35-0000' = 5,  # Food Preparation/Serving
    '49-0000' = 5   # Installation, Maintenance, Repair
)

# Create new column with mapped values
merged_df$occupation_group <- soc_group_mapping[merged_df$soc_code]

# Add descriptive labels for the groups
merged_df$occupation_group_label <- factor(merged_df$occupation_group,
    levels = 1:5,
    labels = c("STEM & Technical",
               "Education & Community Services",
               "Healthcare & Medical",
               "Business & Management",
               "Other Professional Services"))

# Verify the new groupings
table(merged_df$occupation_group_label, useNA = "ifany")
## 
##               STEM & Technical Education & Community Services 
##                             56                             41 
##           Healthcare & Medical          Business & Management 
##                             26                             34 
##    Other Professional Services                           <NA> 
##                             16                             57
# Check structure
str(merged_df)
## tibble [230 × 28] (S3: tbl_df/tbl/data.frame)
##  $ ...1.x                : num [1:230] 1 2 3 4 5 6 7 8 9 10 ...
##  $ age                   : num [1:230] NA 21 25 29 NA NA 40 27 60 40 ...
##  $ gender                : num [1:230] 1 2 2 1 1 2 1 2 1 5 ...
##  $ race                  : num [1:230] 1 2 2 1 1 6 6 9 1 5 ...
##  $ US_born               : num [1:230] 1 1 1 1 1 1 1 1 1 1 ...
##  $ sexual_orientation    : num [1:230] 5 5 5 2 5 9 5 5 5 5 ...
##  $ employment_status     : num [1:230] 1 2 1 2 1 1 1 1 1 1 ...
##  $ education             : num [1:230] 6 4 4 4 6 5 1 3 6 3 ...
##  $ religion              : num [1:230] 4 5 14 4 10 5 5 10 4 4 ...
##  $ income                : num [1:230] 9 1 1 2 8 5 5 9 8 2 ...
##  $ fam_income            : num [1:230] 7 2 2 2 8 3 3 6 3 2 ...
##  $ OC_AVG                : num [1:230] 3.5 4 NA 3 NA NA NA 3.5 2.5 3.5 ...
##  $ SBS_AVG               : num [1:230] 3.14 4.43 3.57 2.57 3.14 3.86 3.86 3.57 2.86 4.57 ...
##  $ SS_AVG                : num [1:230] 4 5.5 5.75 3.08 4 4.82 5.92 5.27 6.42 5.92 ...
##  $ BRS_AVG               : num [1:230] 3.33 3.33 2.83 NA 2 3.6 2.5 NA 3.67 2.83 ...
##  $ PSNQ_AVG              : num [1:230] NA 5.9 5.33 2.9 4.8 5.6 5.9 5.3 4.3 6.6 ...
##  $ PF_AVG                : num [1:230] 3.88 6 5.12 3 3.62 6 6.12 4.88 5.5 7 ...
##  $ CS_AVG                : num [1:230] 3.25 NA 4.2 2.4 3.2 4 4.4 3.8 4.4 4.8 ...
##  $ Participant_ID        : int [1:230] 1 2 3 4 5 6 7 8 9 10 ...
##  $ ...1.y                : num [1:230] 1 2 3 4 5 6 7 8 9 10 ...
##  $ year_education        : chr [1:230] "2017" "2022" "2022" "2022" ...
##  $ SS_13_TEXT            : chr [1:230] "Mother and Friend" "Uncle(Family Member)" "Friend" "A friend who also is a mother-figure to me." ...
##  $ PD                    : chr [1:230] "Associate Attorney at large international law firm." "The Information Technology (IT) profession involves designing, developing, managing, and maintaining computer s"| __truncated__ "Health education" "Education - I work as a college advisor for high school students and support them throughout the college application process." ...
##  $ job_title             : chr [1:230] "Attorney" "IT/Database Administrator" "Health Education" "College Advisor" ...
##  $ soc_code              : chr [1:230] "23-0000" "15-0000" "25-0000" "25-0000" ...
##  $ soc_description       : chr [1:230] "Legal Occupations" "Computer and Mathematical Occupations" "Educational Instruction and Library Occupations" "Educational Instruction and Library Occupations" ...
##  $ occupation_group      : Named num [1:230] 5 1 2 2 1 2 1 1 2 5 ...
##   ..- attr(*, "names")= chr [1:230] "23-0000" "15-0000" "25-0000" "25-0000" ...
##  $ occupation_group_label: Factor w/ 5 levels "STEM & Technical",..: 5 1 2 2 1 2 1 1 2 5 ...
##   ..- attr(*, "names")= chr [1:230] "23-0000" "15-0000" "25-0000" "25-0000" ...
# Optional: Create a visualization of the new groupings
library(ggplot2)

ggplot(merged_df, aes(x = occupation_group_label)) +
  geom_bar(fill = "steelblue") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  labs(title = "Distribution of Regrouped Occupational Fields",
       x = "Occupational Field",
       y = "Count")

dat <- merged_df[, c("occupation_group", "OC_AVG", "SS_AVG", "PSNQ_AVG", "BRS_AVG", "SBS_AVG", "PF_AVG", "CS_AVG")]

CORRELATION

# Correlation
library(dplyr)
library(apaTables)
library(Hmisc)
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
# Subset your quant_dfa to include only the columns of interest
subset_df <- merged_df %>%
  select(OC_AVG, SS_AVG, PSNQ_AVG, BRS_AVG, SBS_AVG, PF_AVG, CS_AVG)

# Compute and save the correlation table
cor_df <- apa.cor.table(subset_df, 
                        table.number = 1, 
                        show.sig.stars = TRUE, 
                        landscape = TRUE, 
                        filename = "correlation_table.doc")

# Ensure the table was created successfully
if (file.exists("correlation_table.doc")) {
  cat("Correlation table successfully saved as 'correlation_table.doc'.\n")
} else {
  cat("Error: Correlation table was not saved.\n")
}
## Correlation table successfully saved as 'correlation_table.doc'.
# Print the correlation table object to check contents
print(cor_df)
## 
## 
## Table 1 
## 
## Means, standard deviations, and correlations with confidence intervals
##  
## 
##   Variable    M    SD   1           2          3          4          
##   1. OC_AVG   3.68 0.90                                              
##                                                                      
##   2. SS_AVG   5.39 0.82 .26**                                        
##                         [.13, .38]                                   
##                                                                      
##   3. PSNQ_AVG 5.63 0.79 .23**       .72**                            
##                         [.11, .35]  [.66, .78]                       
##                                                                      
##   4. BRS_AVG  3.31 0.64 -.00        .20**      .20**                 
##                         [-.13, .13] [.07, .32] [.07, .32]            
##                                                                      
##   5. SBS_AVG  3.75 0.66 .28**       .73**      .72**      .19**      
##                         [.16, .40]  [.67, .79] [.65, .77] [.06, .31] 
##                                                                      
##   6. PF_AVG   5.80 0.87 .23**       .72**      .80**      .36**      
##                         [.10, .35]  [.65, .77] [.75, .84] [.25, .47] 
##                                                                      
##   7. CS_AVG   4.08 0.65 .17*        .51**      .69**      .09        
##                         [.04, .29]  [.40, .60] [.62, .75] [-.04, .22]
##                                                                      
##   5          6         
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##                        
##   .74**                
##   [.68, .80]           
##                        
##   .49**      .64**     
##   [.38, .58] [.55, .71]
##                        
## 
## Note. M and SD are used to represent mean and standard deviation, respectively.
## Values in square brackets indicate the 95% confidence interval.
## The confidence interval is a plausible range of population correlations 
## that could have caused the sample correlation (Cumming, 2014).
##  * indicates p < .05. ** indicates p < .01.
## 
# Get p-values using rcorr from Hmisc
corr_matrix <- rcorr(as.matrix(subset_df))

# Print correlation coefficients
cat("\nCorrelation Coefficients:\n")
## 
## Correlation Coefficients:
print(corr_matrix$r)
##                 OC_AVG    SS_AVG  PSNQ_AVG       BRS_AVG   SBS_AVG    PF_AVG
## OC_AVG    1.0000000000 0.2572256 0.2339663 -0.0009919913 0.2826210 0.2299285
## SS_AVG    0.2572255684 1.0000000 0.7235918  0.2010254704 0.7331107 0.7165600
## PSNQ_AVG  0.2339662571 0.7235918 1.0000000  0.1964278942 0.7150035 0.7980969
## BRS_AVG  -0.0009919913 0.2010255 0.1964279  1.0000000000 0.1852365 0.3641014
## SBS_AVG   0.2826210042 0.7331107 0.7150035  0.1852364814 1.0000000 0.7430219
## PF_AVG    0.2299285281 0.7165600 0.7980969  0.3641013971 0.7430219 1.0000000
## CS_AVG    0.1701073431 0.5071161 0.6909374  0.0906436961 0.4867393 0.6375525
##             CS_AVG
## OC_AVG   0.1701073
## SS_AVG   0.5071161
## PSNQ_AVG 0.6909374
## BRS_AVG  0.0906437
## SBS_AVG  0.4867393
## PF_AVG   0.6375525
## CS_AVG   1.0000000
# Print p-values
cat("\nP-values:\n")
## 
## P-values:
print(corr_matrix$P)
##                 OC_AVG                   SS_AVG     PSNQ_AVG          BRS_AVG
## OC_AVG              NA 0.0000917145853218670482 0.0004013479 0.98822069466786
## SS_AVG   0.00009171459                       NA 0.0000000000 0.00228894743622
## PSNQ_AVG 0.00040134788 0.0000000000000000000000           NA 0.00295716365666
## BRS_AVG  0.98822069467 0.0022889474362208783731 0.0029571637               NA
## SBS_AVG  0.00001607417 0.0000000000000000000000 0.0000000000 0.00501668401152
## PF_AVG   0.00049358283 0.0000000000000000000000 0.0000000000 0.00000001485944
## CS_AVG   0.01058665470 0.0000000000000002220446 0.0000000000 0.17352986726366
##                          SBS_AVG           PF_AVG                   CS_AVG
## OC_AVG   0.000016074169621127510 0.00049358283231 0.0105866547001400856942
## SS_AVG   0.000000000000000000000 0.00000000000000 0.0000000000000002220446
## PSNQ_AVG 0.000000000000000000000 0.00000000000000 0.0000000000000000000000
## BRS_AVG  0.005016684011523553366 0.00000001485944 0.1735298672636571559735
## SBS_AVG                       NA 0.00000000000000 0.0000000000000048849813
## PF_AVG   0.000000000000000000000               NA 0.0000000000000000000000
## CS_AVG   0.000000000000004884981 0.00000000000000                       NA

MAIN ANALYSES

One Way ANOVA

RQ1a - How does the type of percieved social support accessible to first-generation professionals in their workplace vary based on their professional discipline?

# One-way ANOVA for RQ1a
# Examining differences in perceived social support across professional disciplines

# First, let's get descriptive statistics by professional discipline
library(dplyr)
desc_stats <- dat %>%
  group_by(occupation_group) %>%
  summarise(
    n = n(),
    mean_ss = mean(SS_AVG, na.rm = TRUE),
    sd_ss = sd(SS_AVG, na.rm = TRUE),
    se_ss = sd_ss/sqrt(n)
  )
print(desc_stats)
## # A tibble: 6 × 5
##   occupation_group     n mean_ss sd_ss  se_ss
##              <dbl> <int>   <dbl> <dbl>  <dbl>
## 1                1    56    5.29 0.860 0.115 
## 2                2    41    5.62 0.811 0.127 
## 3                3    26    5.37 0.808 0.158 
## 4                4    34    5.47 0.786 0.135 
## 5                5    16    5.78 0.855 0.214 
## 6               NA    57    5.19 0.735 0.0973
# Check assumptions
# 1. Test for normality within each group
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:purrr':
## 
##     some
## The following object is masked from 'package:dplyr':
## 
##     recode
leveneTest(SS_AVG ~ as.factor(occupation_group), data = dat)
## Levene's Test for Homogeneity of Variance (center = median)
##        Df F value Pr(>F)
## group   4  0.1758 0.9506
##       168
# 2. Visual check of distributions
library(ggplot2)
# Box plot
ggplot(dat, aes(x = as.factor(occupation_group), y = SS_AVG)) +
  geom_boxplot() +
  labs(title = "Social Support by Professional Discipline",
       x = "Professional Discipline Code",
       y = "Social Support Score")

# Conduct one-way ANOVA
anova_result <- aov(SS_AVG ~ as.factor(occupation_group), data = dat)
summary(anova_result)
##                              Df Sum Sq Mean Sq F value Pr(>F)
## as.factor(occupation_group)   4   4.34  1.0845   1.589   0.18
## Residuals                   168 114.68  0.6826               
## 57 observations deleted due to missingness
# If ANOVA is significant, conduct post-hoc tests
TukeyHSD(anova_result)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = SS_AVG ~ as.factor(occupation_group), data = dat)
## 
## $`as.factor(occupation_group)`
##            diff        lwr       upr     p adj
## 2-1  0.32210366 -0.1461913 0.7903986 0.3230865
## 3-1  0.07817308 -0.4625138 0.6188599 0.9946279
## 4-1  0.17889706 -0.3164475 0.6742416 0.8568890
## 5-1  0.48125000 -0.1646002 1.1271002 0.2448464
## 3-2 -0.24393058 -0.8151177 0.3272565 0.7641321
## 4-2 -0.14320660 -0.6716748 0.3852616 0.9449195
## 5-2  0.15914634 -0.5124450 0.8307377 0.9657891
## 4-3  0.10072398 -0.4928421 0.6942901 0.9900896
## 5-3  0.40307692 -0.3208547 1.1270086 0.5410042
## 5-4  0.30235294 -0.3883720 0.9930779 0.7472813
library(lavaan)
## This is lavaan 0.6-16
## lavaan is FREE software! Please report any bugs.
# Define the full SEM model
model <- '
  # Direct effects from IVs to Mediators
  PSNQ_AVG ~ a1 * SS_AVG + oc1 * OC_AVG      # Network Quality
  BRS_AVG ~ a2 * SS_AVG + oc2 * OC_AVG       # Resilience

  # Direct effects to DVs
  SBS_AVG ~ c1 * SS_AVG + b1 * PSNQ_AVG + b2 * BRS_AVG + oc3 * OC_AVG    # Belonging
  PF_AVG ~ c2 * SS_AVG + b3 * PSNQ_AVG + b4 * BRS_AVG + oc4 * OC_AVG     # Flourishing
  CS_AVG ~ c3 * SS_AVG + b5 * PSNQ_AVG + b6 * BRS_AVG + oc5 * OC_AVG     # Career Satisfaction

  # Allow DVs to covary
  SBS_AVG ~~ PF_AVG + CS_AVG
  PF_AVG ~~ CS_AVG

  # Define indirect effects through Network Quality
  indirect_nq_sbs := a1 * b1    # to Belonging
  indirect_nq_pf := a1 * b3     # to Flourishing
  indirect_nq_cs := a1 * b5     # to Career Satisfaction

  # Define indirect effects through Resilience
  indirect_rs_sbs := a2 * b2    # to Belonging
  indirect_rs_pf := a2 * b4     # to Flourishing
  indirect_rs_cs := a2 * b6     # to Career Satisfaction
'

# Fit the model
fit <- sem(model, data = dat, 
           se = "bootstrap", 
           bootstrap = 5000)

# Get summary with standardized estimates and confidence intervals
summary(fit, standardized = TRUE, ci = TRUE)
## lavaan 0.6.16 ended normally after 21 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        24
## 
##                                                   Used       Total
##   Number of observations                           222         230
## 
## Model Test User Model:
##                                                       
##   Test statistic                                 1.299
##   Degrees of freedom                                 1
##   P-value (Chi-square)                           0.254
## 
## Parameter Estimates:
## 
##   Standard errors                            Bootstrap
##   Number of requested bootstrap draws             5000
##   Number of successful bootstrap draws            5000
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   PSNQ_AVG ~                                                            
##     SS_AVG    (a1)    0.676    0.055   12.381    0.000    0.565    0.779
##     OC_AVG   (oc1)    0.044    0.049    0.911    0.362   -0.046    0.143
##   BRS_AVG ~                                                             
##     SS_AVG    (a2)    0.170    0.055    3.065    0.002    0.062    0.280
##     OC_AVG   (oc2)   -0.039    0.049   -0.782    0.434   -0.131    0.060
##   SBS_AVG ~                                                             
##     SS_AVG    (c1)    0.364    0.066    5.539    0.000    0.242    0.500
##     PSNQ_AVG  (b1)    0.322    0.068    4.753    0.000    0.185    0.447
##     BRS_AVG   (b2)    0.023    0.041    0.549    0.583   -0.060    0.102
##     OC_AVG   (oc3)    0.060    0.028    2.108    0.035    0.002    0.112
##   PF_AVG ~                                                              
##     SS_AVG    (c2)    0.260    0.064    4.062    0.000    0.135    0.387
##     PSNQ_AVG  (b3)    0.608    0.074    8.204    0.000    0.465    0.752
##     BRS_AVG   (b4)    0.256    0.057    4.487    0.000    0.150    0.370
##     OC_AVG   (oc4)    0.030    0.038    0.779    0.436   -0.049    0.102
##   CS_AVG ~                                                              
##     SS_AVG    (c3)   -0.001    0.076   -0.010    0.992   -0.148    0.149
##     PSNQ_AVG  (b5)    0.567    0.074    7.677    0.000    0.428    0.716
##     BRS_AVG   (b6)   -0.047    0.058   -0.800    0.424   -0.170    0.061
##     OC_AVG   (oc5)    0.005    0.045    0.111    0.912   -0.086    0.091
##    Std.lv  Std.all
##                   
##     0.676    0.699
##     0.044    0.052
##                   
##     0.170    0.212
##    -0.039   -0.054
##                   
##     0.364    0.439
##     0.322    0.376
##     0.023    0.022
##     0.060    0.081
##                   
##     0.260    0.252
##     0.608    0.569
##     0.256    0.199
##     0.030    0.033
##                   
##    -0.001   -0.001
##     0.567    0.684
##    -0.047   -0.047
##     0.005    0.007
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##  .SBS_AVG ~~                                                            
##    .PF_AVG            0.063    0.012    5.367    0.000    0.039    0.084
##    .CS_AVG           -0.004    0.014   -0.264    0.791   -0.030    0.023
##  .PF_AVG ~~                                                             
##    .CS_AVG            0.049    0.017    2.899    0.004    0.015    0.082
##    Std.lv  Std.all
##                   
##     0.063    0.336
##    -0.004   -0.018
##                   
##     0.049    0.230
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .PSNQ_AVG          0.295    0.034    8.597    0.000    0.229    0.363
##    .BRS_AVG           0.396    0.038   10.432    0.000    0.319    0.468
##    .SBS_AVG           0.170    0.017   10.266    0.000    0.135    0.201
##    .PF_AVG            0.208    0.027    7.708    0.000    0.152    0.258
##    .CS_AVG            0.222    0.024    9.321    0.000    0.171    0.263
##    Std.lv  Std.all
##     0.295    0.491
##     0.396    0.958
##     0.170    0.386
##     0.208    0.304
##     0.222    0.537
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     indirct_nq_sbs    0.218    0.046    4.709    0.000    0.127    0.308
##     indirect_nq_pf    0.411    0.064    6.425    0.000    0.297    0.544
##     indirect_nq_cs    0.384    0.066    5.838    0.000    0.266    0.520
##     indirct_rs_sbs    0.004    0.007    0.527    0.598   -0.011    0.019
##     indirect_rs_pf    0.043    0.018    2.379    0.017    0.013    0.086
##     indirect_rs_cs   -0.008    0.010   -0.777    0.437   -0.030    0.012
##    Std.lv  Std.all
##     0.218    0.262
##     0.411    0.398
##     0.384    0.478
##     0.004    0.005
##     0.043    0.042
##    -0.008   -0.010
# Get fit indices
fitMeasures(fit)
##                  npar                  fmin                 chisq 
##                24.000                 0.003                 1.299 
##                    df                pvalue        baseline.chisq 
##                 1.000                 0.254               825.442 
##           baseline.df       baseline.pvalue                   cfi 
##                20.000                 0.000                 1.000 
##                   tli                  nnfi                   rfi 
##                 0.993                 0.993                 0.969 
##                   nfi                  pnfi                   ifi 
##                 0.998                 0.050                 1.000 
##                   rni                  logl     unrestricted.logl 
##                 1.000              -777.470              -776.821 
##                   aic                   bic                ntotal 
##              1602.941              1684.605               222.000 
##                  bic2                 rmsea        rmsea.ci.lower 
##              1608.547                 0.037                 0.000 
##        rmsea.ci.upper        rmsea.ci.level          rmsea.pvalue 
##                 0.187                 0.900                 0.376 
##        rmsea.close.h0 rmsea.notclose.pvalue     rmsea.notclose.h0 
##                 0.050                 0.469                 0.080 
##                   rmr            rmr_nomean                  srmr 
##                 0.007                 0.007                 0.014 
##          srmr_bentler   srmr_bentler_nomean                  crmr 
##                 0.014                 0.014                 0.016 
##           crmr_nomean            srmr_mplus     srmr_mplus_nomean 
##                 0.016                 0.014                 0.014 
##                 cn_05                 cn_01                   gfi 
##               657.508              1134.909                 0.999 
##                  agfi                  pgfi                   mfi 
##                 0.958                 0.036                 0.999 
##                  ecvi 
##                 0.222
# Optional: Create a path diagram
library(semPlot)
semPaths(fit, "std", layout = "tree")