DEMOGRAPHIC FREQUENCIES
# Summary of all demographic variables
library(dplyr)
# Get frequencies for each variable
gender_freq <- quant_df %>% count(gender)
race_freq <- quant_df %>% count(race)
sexual_orientation_freq <- quant_df %>% count(sexual_orientation)
US_born_freq <- quant_df %>% count(US_born)
income_freq <- quant_df %>% count(income)
fam_income_freq <- quant_df %>% count(fam_income)
religion_freq <- quant_df %>% count(religion)
education_freq <- quant_df %>% count(education)
employment_status_freq <- quant_df %>% count(employment_status)
# Print the frequency tables
gender_freq
## # A tibble: 7 × 2
## gender n
## <dbl> <int>
## 1 1 94
## 2 2 64
## 3 3 3
## 4 4 9
## 5 5 6
## 6 6 1
## 7 7 53
race_freq
## # A tibble: 8 × 2
## race n
## <dbl> <int>
## 1 1 30
## 2 2 25
## 3 3 11
## 4 4 2
## 5 5 35
## 6 6 56
## 7 7 3
## 8 9 68
sexual_orientation_freq
## # A tibble: 8 × 2
## sexual_orientation n
## <dbl> <int>
## 1 1 22
## 2 2 16
## 3 3 3
## 4 5 125
## 5 6 4
## 6 7 4
## 7 8 55
## 8 9 1
US_born_freq
## # A tibble: 3 × 2
## US_born n
## <dbl> <int>
## 1 1 167
## 2 2 10
## 3 NA 53
income_freq
## # A tibble: 10 × 2
## income n
## <dbl> <int>
## 1 1 7
## 2 2 20
## 3 3 23
## 4 4 18
## 5 5 17
## 6 6 18
## 7 7 14
## 8 8 31
## 9 9 32
## 10 10 50
fam_income_freq
## # A tibble: 10 × 2
## fam_income n
## <dbl> <int>
## 1 1 8
## 2 2 21
## 3 3 22
## 4 4 25
## 5 5 25
## 6 6 27
## 7 7 10
## 8 8 26
## 9 9 16
## 10 10 50
religion_freq
## # A tibble: 14 × 2
## religion n
## <dbl> <int>
## 1 1 9
## 2 2 17
## 3 3 6
## 4 4 25
## 5 5 37
## 6 6 4
## 7 7 1
## 8 8 5
## 9 10 9
## 10 11 1
## 11 12 1
## 12 13 4
## 13 14 97
## 14 15 14
education_freq
## # A tibble: 8 × 2
## education n
## <dbl> <int>
## 1 1 8
## 2 2 10
## 3 3 63
## 4 4 46
## 5 5 23
## 6 6 26
## 7 7 1
## 8 8 53
employment_status_freq
## # A tibble: 4 × 2
## employment_status n
## <dbl> <int>
## 1 1 188
## 2 2 31
## 3 3 1
## 4 NA 10
CORRELATION
# Correlation
library(dplyr)
library(apaTables)
# Subset your quant_dfa to include only the columns of interest
subset_df <- quant_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.21 0.45 .00 .19** .20**
## [-.13, .14] [.06, .31] [.07, .32]
##
## 5. SBS_AVG 3.75 0.66 .28** .73** .72** .20**
## [.16, .40] [.67, .79] [.65, .77] [.08, .33]
##
## 6. PF_AVG 5.80 0.87 .23** .72** .80** .35**
## [.10, .35] [.65, .77] [.75, .84] [.23, .46]
##
## 7. CS_AVG 4.08 0.65 .17* .51** .69** .10
## [.04, .29] [.40, .60] [.62, .75] [-.03, .23]
##
## 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.
##
MAIN ANALYSES
SENSE OF BELONGING AS OUTCOME
#Simple Mediation - Perceived Network Quality
# Define the simple mediation model
simple_med_PSNQ_SBS <- "
SBS_AVG ~ b1*PSNQ_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_PSNQ_SBS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 21 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 2
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 385.736
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -308.374
## Loglikelihood unrestricted model (H1) -308.374
##
## Akaike (AIC) 630.747
## Bayesian (BIC) 654.814
## Sample-size adjusted Bayesian (SABIC) 632.628
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## SBS_AVG ~
## PSNQ_AVG (b1) 0.326 0.069 4.750 0.000 0.189 0.456
## SS_AVG (c_p) 0.367 0.064 5.711 0.000 0.253 0.493
## PSNQ_AVG ~
## SS_AVG (a1) 0.702 0.048 14.482 0.000 0.606 0.801
## Std.lv Std.all
##
## 0.326 0.388
## 0.367 0.452
##
## 0.702 0.725
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG -0.058 0.194 -0.297 0.767 -0.476 0.306
## .PSNQ_AVG 1.843 0.269 6.839 0.000 1.304 2.385
## Std.lv Std.all
## -0.058 -0.087
## 1.843 2.338
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG 0.171 0.016 10.808 0.000 0.138 0.199
## .PSNQ_AVG 0.295 0.034 8.735 0.000 0.227 0.362
## Std.lv Std.all
## 0.171 0.391
## 0.295 0.475
##
## R-Square:
## Estimate
## SBS_AVG 0.609
## PSNQ_AVG 0.525
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.229 0.047 4.852 0.000 0.134 0.316
## total_c 0.595 0.038 15.865 0.000 0.522 0.669
## direct 0.367 0.064 5.708 0.000 0.253 0.493
## Std.lv Std.all
## 0.229 0.281
## 0.595 0.733
## 0.367 0.452
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 SBS_AVG ~ PSNQ_AVG b1 0.326 0.069 4.750 0.000 0.196
## 2 SBS_AVG ~ SS_AVG c_p 0.367 0.064 5.711 0.000 0.242
## 3 PSNQ_AVG ~ SS_AVG a1 0.702 0.048 14.482 0.000 0.597
## 4 SBS_AVG ~~ SBS_AVG 0.171 0.016 10.808 0.000 0.144
## 5 PSNQ_AVG ~~ PSNQ_AVG 0.295 0.034 8.735 0.000 0.241
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 SBS_AVG ~1 -0.058 0.194 -0.297 0.767 -0.458
## 8 PSNQ_AVG ~1 1.843 0.269 6.839 0.000 1.342
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.229 0.047 4.852 0.000 0.141
## 11 total_c := c_p+indirect total_c 0.595 0.038 15.865 0.000 0.515
## 12 direct := c_p direct 0.367 0.064 5.708 0.000 0.242
## ci.upper std.lv std.all std.nox
## 1 0.459 0.326 0.388 0.388
## 2 0.485 0.367 0.452 0.555
## 3 0.790 0.702 0.725 0.890
## 4 0.207 0.171 0.391 0.391
## 5 0.381 0.295 0.475 0.475
## 6 0.663 0.663 1.000 0.663
## 7 0.312 -0.058 -0.087 -0.087
## 8 2.413 1.843 2.338 2.338
## 9 5.394 5.394 6.627 5.394
## 10 0.327 0.229 0.281 0.346
## 11 0.662 0.595 0.733 0.901
## 12 0.485 0.367 0.452 0.555
#Simple Mediation -Resilience
# Define the simple mediation model
simple_med_BRS_SBS <- "
SBS_AVG ~ b1*BRS_AVG + c_p*SS_AVG
BRS_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_BRS_SBS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 27 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 2
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 188.032
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -277.337
## Loglikelihood unrestricted model (H1) -277.337
##
## Akaike (AIC) 568.675
## Bayesian (BIC) 592.741
## Sample-size adjusted Bayesian (SABIC) 570.555
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## SBS_AVG ~
## BRS_AVG (b1) 0.097 0.067 1.447 0.148 -0.036 0.230
## SS_AVG (c_p) 0.585 0.039 14.924 0.000 0.508 0.663
## BRS_AVG ~
## SS_AVG (a1) 0.107 0.037 2.881 0.004 0.035 0.181
## Std.lv Std.all
##
## 0.097 0.066
## 0.585 0.720
##
## 0.107 0.195
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG 0.287 0.241 1.188 0.235 -0.196 0.749
## .BRS_AVG 2.633 0.200 13.154 0.000 2.223 3.013
## Std.lv Std.all
## 0.287 0.434
## 2.633 5.882
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG 0.200 0.022 9.090 0.000 0.157 0.244
## .BRS_AVG 0.193 0.018 10.681 0.000 0.155 0.226
## Std.lv Std.all
## 0.200 0.458
## 0.193 0.962
##
## R-Square:
## Estimate
## SBS_AVG 0.542
## BRS_AVG 0.038
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.010 0.008 1.262 0.207 -0.004 0.028
## total_c 0.595 0.038 15.865 0.000 0.522 0.669
## direct 0.585 0.039 14.916 0.000 0.508 0.663
## Std.lv Std.all
## 0.010 0.013
## 0.595 0.733
## 0.585 0.720
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 SBS_AVG ~ BRS_AVG b1 0.097 0.067 1.447 0.148 -0.035
## 2 SBS_AVG ~ SS_AVG c_p 0.585 0.039 14.924 0.000 0.498
## 3 BRS_AVG ~ SS_AVG a1 0.107 0.037 2.881 0.004 0.035
## 4 SBS_AVG ~~ SBS_AVG 0.200 0.022 9.090 0.000 0.163
## 5 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.681 0.000 0.159
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 SBS_AVG ~1 0.287 0.241 1.188 0.235 -0.181
## 8 BRS_AVG ~1 2.633 0.200 13.154 0.000 2.229
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.010 0.008 1.262 0.207 -0.002
## 11 total_c := c_p+indirect total_c 0.595 0.038 15.865 0.000 0.515
## 12 direct := c_p direct 0.585 0.039 14.916 0.000 0.498
## ci.upper std.lv std.all std.nox
## 1 0.235 0.097 0.066 0.066
## 2 0.650 0.585 0.720 0.885
## 3 0.181 0.107 0.195 0.239
## 4 0.250 0.200 0.458 0.458
## 5 0.233 0.193 0.962 0.962
## 6 0.663 0.663 1.000 0.663
## 7 0.775 0.287 0.434 0.434
## 8 3.020 2.633 5.882 5.882
## 9 5.394 5.394 6.627 5.394
## 10 0.033 0.010 0.013 0.016
## 11 0.662 0.595 0.733 0.901
## 12 0.650 0.585 0.720 0.885
# Parallel Mediation
parallel_med_SBS <- "
SBS_AVG ~ b1*PSNQ_AVG + b2*BRS_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
BRS_AVG ~ a2*SS_AVG
# Define indirect effects
indirect1 := a1 * b1
indirect2 := a2 * b2
contrast := indirect1 - indirect2
total_indirects := indirect1 + indirect2
total_c := c_p + total_indirects
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the parallel mediation model using lavaan's sem function
parallel_fit <- lavaan::sem(parallel_med_SBS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
pfit_sum <- lavaan::summary(parallel_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
pfit_ParEsts <- lavaan::parameterEstimates(parallel_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(pfit_sum)
## lavaan 0.6.16 ended normally after 31 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 11
##
## Number of observations 230
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 2.019
## Degrees of freedom 1
## P-value (Chi-square) 0.155
##
## Model Test Baseline Model:
##
## Test statistic 397.313
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.997
## Tucker-Lewis Index (TLI) 0.984
##
## Robust Comparative Fit Index (CFI) 0.997
## Robust Tucker-Lewis Index (TLI) 0.984
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -443.773
## Loglikelihood unrestricted model (H1) -442.763
##
## Akaike (AIC) 909.545
## Bayesian (BIC) 947.364
## Sample-size adjusted Bayesian (SABIC) 912.501
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.067
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.202
## P-value H_0: RMSEA <= 0.050 0.269
## P-value H_0: RMSEA >= 0.080 0.578
##
## Robust RMSEA 0.067
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.204
## P-value H_0: Robust RMSEA <= 0.050 0.266
## P-value H_0: Robust RMSEA >= 0.080 0.583
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.019
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## SBS_AVG ~
## PSNQ_AVG (b1) 0.321 0.068 4.692 0.000 0.188 0.450
## BRS_AVG (b2) 0.060 0.061 0.999 0.318 -0.061 0.178
## SS_AVG (c_p) 0.364 0.065 5.635 0.000 0.247 0.492
## PSNQ_AVG ~
## SS_AVG (a1) 0.702 0.048 14.480 0.000 0.606 0.801
## BRS_AVG ~
## SS_AVG (a2) 0.107 0.037 2.870 0.004 0.035 0.181
## Std.lv Std.all
##
## 0.321 0.383
## 0.060 0.041
## 0.364 0.448
##
## 0.702 0.725
##
## 0.107 0.194
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG -0.209 0.227 -0.918 0.359 -0.655 0.227
## .PSNQ_AVG 1.843 0.269 6.838 0.000 1.304 2.385
## .BRS_AVG 2.635 0.200 13.149 0.000 2.225 3.013
## Std.lv Std.all
## -0.209 -0.316
## 1.843 2.338
## 2.635 5.886
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .SBS_AVG 0.170 0.015 11.002 0.000 0.138 0.197
## .PSNQ_AVG 0.295 0.034 8.735 0.000 0.227 0.362
## .BRS_AVG 0.193 0.018 10.680 0.000 0.155 0.226
## Std.lv Std.all
## 0.170 0.390
## 0.295 0.475
## 0.193 0.962
##
## R-Square:
## Estimate
## SBS_AVG 0.610
## PSNQ_AVG 0.525
## BRS_AVG 0.038
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect1 0.225 0.047 4.801 0.000 0.132 0.316
## indirect2 0.006 0.007 0.916 0.360 -0.007 0.021
## contrast 0.219 0.048 4.586 0.000 0.122 0.308
## total_indircts 0.232 0.047 4.911 0.000 0.138 0.321
## total_c 0.595 0.038 15.865 0.000 0.522 0.669
## direct 0.364 0.065 5.633 0.000 0.247 0.492
## Std.lv Std.all
## 0.225 0.278
## 0.006 0.008
## 0.219 0.270
## 0.232 0.286
## 0.595 0.734
## 0.364 0.448
print(pfit_ParEsts)
## lhs op rhs label est se z
## 1 SBS_AVG ~ PSNQ_AVG b1 0.321 0.068 4.692
## 2 SBS_AVG ~ BRS_AVG b2 0.060 0.061 0.999
## 3 SBS_AVG ~ SS_AVG c_p 0.364 0.065 5.635
## 4 PSNQ_AVG ~ SS_AVG a1 0.702 0.048 14.480
## 5 BRS_AVG ~ SS_AVG a2 0.107 0.037 2.870
## 6 SBS_AVG ~~ SBS_AVG 0.170 0.015 11.002
## 7 PSNQ_AVG ~~ PSNQ_AVG 0.295 0.034 8.735
## 8 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.680
## 9 SS_AVG ~~ SS_AVG 0.663 0.000 NA
## 10 SBS_AVG ~1 -0.209 0.227 -0.918
## 11 PSNQ_AVG ~1 1.843 0.269 6.838
## 12 BRS_AVG ~1 2.635 0.200 13.149
## 13 SS_AVG ~1 5.394 0.000 NA
## 14 indirect1 := a1*b1 indirect1 0.225 0.047 4.801
## 15 indirect2 := a2*b2 indirect2 0.006 0.007 0.916
## 16 contrast := indirect1-indirect2 contrast 0.219 0.048 4.586
## 17 total_indirects := indirect1+indirect2 total_indirects 0.232 0.047 4.911
## 18 total_c := c_p+total_indirects total_c 0.595 0.038 15.865
## 19 direct := c_p direct 0.364 0.065 5.633
## pvalue ci.lower ci.upper std.lv std.all std.nox
## 1 0.000 0.192 0.454 0.321 0.383 0.383
## 2 0.318 -0.060 0.180 0.060 0.041 0.041
## 3 0.000 0.223 0.482 0.364 0.448 0.551
## 4 0.000 0.597 0.789 0.702 0.725 0.890
## 5 0.004 0.034 0.179 0.107 0.194 0.239
## 6 0.000 0.144 0.207 0.170 0.390 0.390
## 7 0.000 0.241 0.381 0.295 0.475 0.475
## 8 0.000 0.159 0.233 0.193 0.962 0.962
## 9 NA 0.663 0.663 0.663 1.000 0.663
## 10 0.359 -0.624 0.247 -0.209 -0.316 -0.316
## 11 0.000 1.344 2.414 1.843 2.338 2.338
## 12 0.000 2.231 3.025 2.635 5.886 5.886
## 13 NA 5.394 5.394 5.394 6.627 5.394
## 14 0.000 0.137 0.322 0.225 0.278 0.341
## 15 0.360 -0.005 0.025 0.006 0.008 0.010
## 16 0.000 0.129 0.320 0.219 0.270 0.331
## 17 0.000 0.145 0.329 0.232 0.286 0.351
## 18 0.000 0.515 0.662 0.595 0.734 0.902
## 19 0.000 0.223 0.482 0.364 0.448 0.551
PROFESSIONAL FLOURISHING AS OUTCOME
#Perceived Network Quality
simple_med_PSNQ_PF <- "
PF_AVG ~ b1*PSNQ_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_PSNQ_PF, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 23 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 2
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 430.846
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -347.304
## Loglikelihood unrestricted model (H1) -347.304
##
## Akaike (AIC) 708.608
## Bayesian (BIC) 732.675
## Sample-size adjusted Bayesian (SABIC) 710.489
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## PF_AVG ~
## PSNQ_AVG (b1) 0.648 0.076 8.494 0.000 0.492 0.811
## SS_AVG (c_p) 0.303 0.073 4.119 0.000 0.155 0.451
## PSNQ_AVG ~
## SS_AVG (a1) 0.707 0.048 14.640 0.000 0.612 0.805
## Std.lv Std.all
##
## 0.648 0.594
## 0.303 0.285
##
## 0.707 0.727
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG 0.529 0.267 1.978 0.048 -0.006 1.031
## .PSNQ_AVG 1.812 0.268 6.751 0.000 1.289 2.348
## Std.lv Std.all
## 0.529 0.612
## 1.812 2.290
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG 0.239 0.032 7.385 0.000 0.175 0.299
## .PSNQ_AVG 0.296 0.034 8.733 0.000 0.227 0.362
## Std.lv Std.all
## 0.239 0.320
## 0.296 0.472
##
## R-Square:
## Estimate
## PF_AVG 0.680
## PSNQ_AVG 0.528
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.458 0.063 7.268 0.000 0.347 0.591
## total_c 0.760 0.056 13.595 0.000 0.654 0.877
## direct 0.303 0.073 4.117 0.000 0.155 0.451
## Std.lv Std.all
## 0.458 0.431
## 0.760 0.717
## 0.303 0.285
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 PF_AVG ~ PSNQ_AVG b1 0.648 0.076 8.494 0.000 0.488
## 2 PF_AVG ~ SS_AVG c_p 0.303 0.073 4.119 0.000 0.160
## 3 PSNQ_AVG ~ SS_AVG a1 0.707 0.048 14.640 0.000 0.605
## 4 PF_AVG ~~ PF_AVG 0.239 0.032 7.385 0.000 0.183
## 5 PSNQ_AVG ~~ PSNQ_AVG 0.296 0.034 8.733 0.000 0.242
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 PF_AVG ~1 0.529 0.267 1.978 0.048 0.008
## 8 PSNQ_AVG ~1 1.812 0.268 6.751 0.000 1.305
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.458 0.063 7.268 0.000 0.342
## 11 total_c := c_p+indirect total_c 0.760 0.056 13.595 0.000 0.652
## 12 direct := c_p direct 0.303 0.073 4.117 0.000 0.160
## ci.upper std.lv std.all std.nox
## 1 0.799 0.648 0.594 0.594
## 2 0.466 0.303 0.285 0.350
## 3 0.798 0.707 0.727 0.893
## 4 0.307 0.239 0.320 0.320
## 5 0.382 0.296 0.472 0.472
## 6 0.663 0.663 1.000 0.663
## 7 1.063 0.529 0.612 0.612
## 8 2.366 1.812 2.290 2.290
## 9 5.394 5.394 6.627 5.394
## 10 0.583 0.458 0.431 0.530
## 11 0.874 0.760 0.717 0.880
## 12 0.466 0.303 0.285 0.350
#Resilience
simple_med_BRS_PF <- "
PF_AVG ~ b1*BRS_AVG + c_p*SS_AVG
BRS_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_BRS_PF, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 21 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 2
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 197.783
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -333.947
## Loglikelihood unrestricted model (H1) -333.947
##
## Akaike (AIC) 681.893
## Bayesian (BIC) 705.960
## Sample-size adjusted Bayesian (SABIC) 683.774
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## PF_AVG ~
## BRS_AVG (b1) 0.431 0.088 4.907 0.000 0.264 0.610
## SS_AVG (c_p) 0.712 0.052 13.718 0.000 0.612 0.820
## BRS_AVG ~
## SS_AVG (a1) 0.111 0.038 2.959 0.003 0.040 0.186
## Std.lv Std.all
##
## 0.431 0.224
## 0.712 0.671
##
## 0.111 0.202
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG 0.578 0.375 1.541 0.123 -0.165 1.310
## .BRS_AVG 2.608 0.203 12.859 0.000 2.186 2.991
## Std.lv Std.all
## 0.578 0.669
## 2.608 5.814
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG 0.327 0.037 8.730 0.000 0.251 0.400
## .BRS_AVG 0.193 0.018 10.668 0.000 0.155 0.227
## Std.lv Std.all
## 0.327 0.438
## 0.193 0.959
##
## R-Square:
## Estimate
## PF_AVG 0.562
## BRS_AVG 0.041
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.048 0.020 2.447 0.014 0.014 0.092
## total_c 0.760 0.056 13.595 0.000 0.654 0.877
## direct 0.712 0.052 13.711 0.000 0.612 0.820
## Std.lv Std.all
## 0.048 0.045
## 0.760 0.717
## 0.712 0.671
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 PF_AVG ~ BRS_AVG b1 0.431 0.088 4.907 0.000 0.274
## 2 PF_AVG ~ SS_AVG c_p 0.712 0.052 13.718 0.000 0.608
## 3 BRS_AVG ~ SS_AVG a1 0.111 0.038 2.959 0.003 0.040
## 4 PF_AVG ~~ PF_AVG 0.327 0.037 8.730 0.000 0.256
## 5 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.668 0.000 0.159
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 PF_AVG ~1 0.578 0.375 1.541 0.123 -0.185
## 8 BRS_AVG ~1 2.608 0.203 12.859 0.000 2.215
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.048 0.020 2.447 0.014 0.019
## 11 total_c := c_p+indirect total_c 0.760 0.056 13.595 0.000 0.652
## 12 direct := c_p direct 0.712 0.052 13.711 0.000 0.608
## ci.upper std.lv std.all std.nox
## 1 0.618 0.431 0.224 0.224
## 2 0.818 0.712 0.671 0.825
## 3 0.187 0.111 0.202 0.248
## 4 0.407 0.327 0.438 0.438
## 5 0.233 0.193 0.959 0.959
## 6 0.663 0.663 1.000 0.663
## 7 1.306 0.578 0.669 0.669
## 8 3.004 2.608 5.814 5.814
## 9 5.394 5.394 6.627 5.394
## 10 0.096 0.048 0.045 0.056
## 11 0.874 0.760 0.717 0.880
## 12 0.818 0.712 0.671 0.825
#Parallel Mediation
parallel_med_PF <- "
PF_AVG ~ b1*PSNQ_AVG + b2*BRS_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
BRS_AVG ~ a2*SS_AVG
# Define indirect effects
indirect1 := a1 * b1
indirect2 := a2 * b2
contrast := indirect1 - indirect2
total_indirects := indirect1 + indirect2
total_c := c_p + total_indirects
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the parallel mediation model using lavaan's sem function
parallel_fit <- lavaan::sem(parallel_med_PF, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
pfit_sum <- lavaan::summary(parallel_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
pfit_ParEsts <- lavaan::parameterEstimates(parallel_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(pfit_sum)
## lavaan 0.6.16 ended normally after 33 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 11
##
## Number of observations 230
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 2.207
## Degrees of freedom 1
## P-value (Chi-square) 0.137
##
## Model Test Baseline Model:
##
## Test statistic 465.725
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.997
## Tucker-Lewis Index (TLI) 0.984
##
## Robust Comparative Fit Index (CFI) 0.997
## Robust Tucker-Lewis Index (TLI) 0.984
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -471.146
## Loglikelihood unrestricted model (H1) -470.043
##
## Akaike (AIC) 964.292
## Bayesian (BIC) 1002.111
## Sample-size adjusted Bayesian (SABIC) 967.248
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.072
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.206
## P-value H_0: RMSEA <= 0.050 0.246
## P-value H_0: RMSEA >= 0.080 0.604
##
## Robust RMSEA 0.073
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.208
## P-value H_0: Robust RMSEA <= 0.050 0.244
## P-value H_0: Robust RMSEA >= 0.080 0.608
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.022
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## PF_AVG ~
## PSNQ_AVG (b1) 0.620 0.073 8.505 0.000 0.480 0.781
## BRS_AVG (b2) 0.354 0.082 4.309 0.000 0.199 0.519
## SS_AVG (c_p) 0.283 0.067 4.254 0.000 0.148 0.413
## PSNQ_AVG ~
## SS_AVG (a1) 0.707 0.048 14.639 0.000 0.612 0.805
## BRS_AVG ~
## SS_AVG (a2) 0.109 0.037 2.927 0.003 0.037 0.185
## Std.lv Std.all
##
## 0.620 0.572
## 0.354 0.185
## 0.283 0.269
##
## 0.707 0.727
##
## 0.109 0.198
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG -0.349 0.342 -1.021 0.307 -1.043 0.330
## .PSNQ_AVG 1.811 0.269 6.745 0.000 1.289 2.348
## .BRS_AVG 2.620 0.201 13.036 0.000 2.210 3.001
## Std.lv Std.all
## -0.349 -0.406
## 1.811 2.288
## 2.620 5.848
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .PF_AVG 0.215 0.027 7.958 0.000 0.160 0.261
## .PSNQ_AVG 0.296 0.034 8.733 0.000 0.227 0.362
## .BRS_AVG 0.193 0.018 10.679 0.000 0.155 0.226
## Std.lv Std.all
## 0.215 0.292
## 0.296 0.472
## 0.193 0.961
##
## R-Square:
## Estimate
## PF_AVG 0.708
## PSNQ_AVG 0.528
## BRS_AVG 0.039
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect1 0.438 0.060 7.260 0.000 0.333 0.576
## indirect2 0.039 0.017 2.279 0.023 0.010 0.076
## contrast 0.400 0.064 6.239 0.000 0.287 0.543
## total_indircts 0.477 0.061 7.776 0.000 0.364 0.614
## total_c 0.760 0.056 13.595 0.000 0.654 0.877
## direct 0.283 0.067 4.252 0.000 0.148 0.413
## Std.lv Std.all
## 0.438 0.416
## 0.039 0.037
## 0.400 0.379
## 0.477 0.453
## 0.760 0.721
## 0.283 0.269
print(pfit_ParEsts)
## lhs op rhs label est se z
## 1 PF_AVG ~ PSNQ_AVG b1 0.620 0.073 8.505
## 2 PF_AVG ~ BRS_AVG b2 0.354 0.082 4.309
## 3 PF_AVG ~ SS_AVG c_p 0.283 0.067 4.254
## 4 PSNQ_AVG ~ SS_AVG a1 0.707 0.048 14.639
## 5 BRS_AVG ~ SS_AVG a2 0.109 0.037 2.927
## 6 PF_AVG ~~ PF_AVG 0.215 0.027 7.958
## 7 PSNQ_AVG ~~ PSNQ_AVG 0.296 0.034 8.733
## 8 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.679
## 9 SS_AVG ~~ SS_AVG 0.663 0.000 NA
## 10 PF_AVG ~1 -0.349 0.342 -1.021
## 11 PSNQ_AVG ~1 1.811 0.269 6.745
## 12 BRS_AVG ~1 2.620 0.201 13.036
## 13 SS_AVG ~1 5.394 0.000 NA
## 14 indirect1 := a1*b1 indirect1 0.438 0.060 7.260
## 15 indirect2 := a2*b2 indirect2 0.039 0.017 2.279
## 16 contrast := indirect1-indirect2 contrast 0.400 0.064 6.239
## 17 total_indirects := indirect1+indirect2 total_indirects 0.477 0.061 7.776
## 18 total_c := c_p+total_indirects total_c 0.760 0.056 13.595
## 19 direct := c_p direct 0.283 0.067 4.252
## pvalue ci.lower ci.upper std.lv std.all std.nox
## 1 0.000 0.469 0.772 0.620 0.572 0.572
## 2 0.000 0.210 0.534 0.354 0.185 0.185
## 3 0.000 0.162 0.430 0.283 0.269 0.330
## 4 0.000 0.605 0.798 0.707 0.727 0.893
## 5 0.003 0.037 0.185 0.109 0.198 0.244
## 6 0.000 0.167 0.274 0.215 0.292 0.292
## 7 0.000 0.242 0.381 0.296 0.472 0.472
## 8 0.000 0.159 0.233 0.193 0.961 0.961
## 9 NA 0.663 0.663 0.663 1.000 0.663
## 10 0.307 -1.043 0.328 -0.349 -0.406 -0.406
## 11 0.000 1.302 2.362 1.811 2.288 2.288
## 12 0.000 2.216 3.016 2.620 5.848 5.848
## 13 NA 5.394 5.394 5.394 6.627 5.394
## 14 0.000 0.328 0.561 0.438 0.416 0.511
## 15 0.023 0.012 0.077 0.039 0.037 0.045
## 16 0.000 0.283 0.531 0.400 0.379 0.466
## 17 0.000 0.360 0.597 0.477 0.453 0.556
## 18 0.000 0.652 0.874 0.760 0.721 0.886
## 19 0.000 0.162 0.430 0.283 0.269 0.330
CAREER SATISFACTION AS OUTCOME
#Perceived Network Quality
simple_med_PSNQ_CS <- "
CS_AVG ~ b1*PSNQ_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_PSNQ_CS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 20 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 319.475
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -335.499
## Loglikelihood unrestricted model (H1) -335.499
##
## Akaike (AIC) 684.998
## Bayesian (BIC) 709.065
## Sample-size adjusted Bayesian (SABIC) 686.879
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## CS_AVG ~
## PSNQ_AVG (b1) 0.562 0.072 7.756 0.000 0.430 0.716
## SS_AVG (c_p) 0.007 0.073 0.095 0.924 -0.145 0.143
## PSNQ_AVG ~
## SS_AVG (a1) 0.704 0.048 14.595 0.000 0.609 0.803
## Std.lv Std.all
##
## 0.562 0.686
## 0.007 0.009
##
## 0.704 0.726
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 0.886 0.215 4.116 0.000 0.474 1.328
## .PSNQ_AVG 1.829 0.268 6.821 0.000 1.296 2.369
## Std.lv Std.all
## 0.886 1.371
## 1.829 2.317
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 0.218 0.025 8.769 0.000 0.170 0.266
## .PSNQ_AVG 0.295 0.034 8.734 0.000 0.227 0.362
## Std.lv Std.all
## 0.218 0.521
## 0.295 0.473
##
## R-Square:
## Estimate
## CS_AVG 0.479
## PSNQ_AVG 0.527
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.395 0.063 6.311 0.000 0.284 0.540
## total_c 0.402 0.049 8.133 0.000 0.299 0.491
## direct 0.007 0.073 0.095 0.924 -0.145 0.143
## Std.lv Std.all
## 0.395 0.498
## 0.402 0.507
## 0.007 0.009
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 CS_AVG ~ PSNQ_AVG b1 0.562 0.072 7.756 0.000 0.427
## 2 CS_AVG ~ SS_AVG c_p 0.007 0.073 0.095 0.924 -0.139
## 3 PSNQ_AVG ~ SS_AVG a1 0.704 0.048 14.595 0.000 0.602
## 4 CS_AVG ~~ CS_AVG 0.218 0.025 8.769 0.000 0.178
## 5 PSNQ_AVG ~~ PSNQ_AVG 0.295 0.034 8.734 0.000 0.241
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 CS_AVG ~1 0.886 0.215 4.116 0.000 0.472
## 8 PSNQ_AVG ~1 1.829 0.268 6.821 0.000 1.323
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.395 0.063 6.311 0.000 0.282
## 11 total_c := c_p+indirect total_c 0.402 0.049 8.133 0.000 0.297
## 12 direct := c_p direct 0.007 0.073 0.095 0.924 -0.139
## ci.upper std.lv std.all std.nox
## 1 0.712 0.562 0.686 0.686
## 2 0.154 0.007 0.009 0.011
## 3 0.794 0.704 0.726 0.892
## 4 0.274 0.218 0.521 0.521
## 5 0.381 0.295 0.473 0.473
## 6 0.663 0.663 1.000 0.663
## 7 1.328 0.886 1.371 1.371
## 8 2.384 1.829 2.317 2.317
## 9 5.394 5.394 6.627 5.394
## 10 0.535 0.395 0.498 0.612
## 11 0.490 0.402 0.507 0.622
## 12 0.154 0.007 0.009 0.011
#Resilience
simple_med_BRS_CS <- "
CS_AVG ~ b1*BRS_AVG + c_p*SS_AVG
BRS_AVG ~ a1*SS_AVG
# Define indirect and direct effects
indirect := a1 * b1
total_c := c_p + indirect
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the simple mediation model using lavaan's sem function
simple_fit <- lavaan::sem(simple_med_BRS_CS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
sfit_sum <- lavaan::summary(simple_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
sfit_ParEsts <- lavaan::parameterEstimates(simple_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(sfit_sum)
## lavaan 0.6.16 ended normally after 15 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 7
##
## Number of observations 230
## Number of missing patterns 3
##
## Model Test User Model:
##
## Test statistic 0.000
## Degrees of freedom 0
##
## Model Test Baseline Model:
##
## Test statistic 76.709
## Degrees of freedom 3
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 1.000
## Tucker-Lewis Index (TLI) 1.000
##
## Robust Comparative Fit Index (CFI) 1.000
## Robust Tucker-Lewis Index (TLI) 1.000
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -326.993
## Loglikelihood unrestricted model (H1) -326.993
##
## Akaike (AIC) 667.987
## Bayesian (BIC) 692.053
## Sample-size adjusted Bayesian (SABIC) 669.868
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.000
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.000
## P-value H_0: RMSEA <= 0.050 NA
## P-value H_0: RMSEA >= 0.080 NA
##
## 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 NA
## P-value H_0: Robust RMSEA >= 0.080 NA
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.000
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## CS_AVG ~
## BRS_AVG (b1) 0.007 0.090 0.072 0.942 -0.189 0.168
## SS_AVG (c_p) 0.401 0.050 7.968 0.000 0.297 0.494
## BRS_AVG ~
## SS_AVG (a1) 0.107 0.037 2.889 0.004 0.035 0.182
## Std.lv Std.all
##
## 0.007 0.005
## 0.401 0.505
##
## 0.107 0.195
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 1.896 0.360 5.272 0.000 1.249 2.670
## .BRS_AVG 2.631 0.200 13.140 0.000 2.215 3.014
## Std.lv Std.all
## 1.896 2.932
## 2.631 5.877
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 0.311 0.035 8.810 0.000 0.243 0.385
## .BRS_AVG 0.193 0.018 10.679 0.000 0.155 0.226
## Std.lv Std.all
## 0.311 0.744
## 0.193 0.962
##
## R-Square:
## Estimate
## CS_AVG 0.256
## BRS_AVG 0.038
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect 0.001 0.010 0.068 0.946 -0.022 0.021
## total_c 0.402 0.049 8.133 0.000 0.299 0.490
## direct 0.401 0.050 7.964 0.000 0.297 0.494
## Std.lv Std.all
## 0.001 0.001
## 0.402 0.506
## 0.401 0.505
print(sfit_ParEsts)
## lhs op rhs label est se z pvalue ci.lower
## 1 CS_AVG ~ BRS_AVG b1 0.007 0.090 0.072 0.942 -0.181
## 2 CS_AVG ~ SS_AVG c_p 0.401 0.050 7.968 0.000 0.294
## 3 BRS_AVG ~ SS_AVG a1 0.107 0.037 2.889 0.004 0.035
## 4 CS_AVG ~~ CS_AVG 0.311 0.035 8.810 0.000 0.252
## 5 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.679 0.000 0.159
## 6 SS_AVG ~~ SS_AVG 0.663 0.000 NA NA 0.663
## 7 CS_AVG ~1 1.896 0.360 5.272 0.000 1.245
## 8 BRS_AVG ~1 2.631 0.200 13.140 0.000 2.226
## 9 SS_AVG ~1 5.394 0.000 NA NA 5.394
## 10 indirect := a1*b1 indirect 0.001 0.010 0.068 0.946 -0.021
## 11 total_c := c_p+indirect total_c 0.402 0.049 8.133 0.000 0.297
## 12 direct := c_p direct 0.401 0.050 7.964 0.000 0.294
## ci.upper std.lv std.all std.nox
## 1 0.173 0.007 0.005 0.005
## 2 0.493 0.401 0.505 0.621
## 3 0.182 0.107 0.195 0.240
## 4 0.394 0.311 0.744 0.744
## 5 0.233 0.193 0.962 0.962
## 6 0.663 0.663 1.000 0.663
## 7 2.654 1.896 2.932 2.932
## 8 3.021 2.631 5.877 5.877
## 9 5.394 5.394 6.627 5.394
## 10 0.021 0.001 0.001 0.001
## 11 0.490 0.402 0.506 0.622
## 12 0.493 0.401 0.505 0.621
#Parallel Mediation
parallel_med_CS <- "
CS_AVG ~ b1*PSNQ_AVG + b2*BRS_AVG + c_p*SS_AVG
PSNQ_AVG ~ a1*SS_AVG
BRS_AVG ~ a2*SS_AVG
# Define indirect effects
indirect1 := a1 * b1
indirect2 := a2 * b2
contrast := indirect1 - indirect2
total_indirects := indirect1 + indirect2
total_c := c_p + total_indirects
direct := c_p
"
# Set seed for reproducibility
set.seed(11051999)
# Run the parallel mediation model using lavaan's sem function
parallel_fit <- lavaan::sem(parallel_med_CS, data = quant_df, se = "bootstrap",
missing = "fiml", bootstrap = 1000)
# Summarize the fit of the model with standardized estimates, R-squared, and confidence intervals
pfit_sum <- lavaan::summary(parallel_fit, standardized = TRUE, rsq = TRUE,
fit = TRUE, ci = TRUE)
# Extract parameter estimates with bootstrapped confidence intervals
pfit_ParEsts <- lavaan::parameterEstimates(parallel_fit, boot.ci.type = "bca.simple",
standardized = TRUE)
# Print the summary and parameter estimates
print(pfit_sum)
## lavaan 0.6.16 ended normally after 28 iterations
##
## Estimator ML
## Optimization method NLMINB
## Number of model parameters 11
##
## Number of observations 230
## Number of missing patterns 4
##
## Model Test User Model:
##
## Test statistic 2.058
## Degrees of freedom 1
## P-value (Chi-square) 0.151
##
## Model Test Baseline Model:
##
## Test statistic 330.868
## Degrees of freedom 6
## P-value 0.000
##
## User Model versus Baseline Model:
##
## Comparative Fit Index (CFI) 0.997
## Tucker-Lewis Index (TLI) 0.980
##
## Robust Comparative Fit Index (CFI) 0.997
## Robust Tucker-Lewis Index (TLI) 0.980
##
## Loglikelihood and Information Criteria:
##
## Loglikelihood user model (H0) -471.010
## Loglikelihood unrestricted model (H1) -469.981
##
## Akaike (AIC) 964.020
## Bayesian (BIC) 1001.839
## Sample-size adjusted Bayesian (SABIC) 966.976
##
## Root Mean Square Error of Approximation:
##
## RMSEA 0.068
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.203
## P-value H_0: RMSEA <= 0.050 0.264
## P-value H_0: RMSEA >= 0.080 0.583
##
## Robust RMSEA 0.069
## 90 Percent confidence interval - lower 0.000
## 90 Percent confidence interval - upper 0.205
## P-value H_0: Robust RMSEA <= 0.050 0.261
## P-value H_0: Robust RMSEA >= 0.080 0.588
##
## Standardized Root Mean Square Residual:
##
## SRMR 0.022
##
## Parameter Estimates:
##
## Standard errors Bootstrap
## Number of requested bootstrap draws 1000
## Number of successful bootstrap draws 1000
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## CS_AVG ~
## PSNQ_AVG (b1) 0.566 0.074 7.677 0.000 0.434 0.723
## BRS_AVG (b2) -0.059 0.082 -0.722 0.470 -0.223 0.089
## SS_AVG (c_p) 0.010 0.073 0.139 0.890 -0.144 0.146
## PSNQ_AVG ~
## SS_AVG (a1) 0.704 0.048 14.596 0.000 0.609 0.803
## BRS_AVG ~
## SS_AVG (a2) 0.107 0.037 2.885 0.004 0.035 0.181
## Std.lv Std.all
##
## 0.566 0.690
## -0.059 -0.041
## 0.010 0.013
##
## 0.704 0.726
##
## 0.107 0.195
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 1.034 0.300 3.445 0.001 0.453 1.674
## .PSNQ_AVG 1.829 0.268 6.821 0.000 1.296 2.367
## .BRS_AVG 2.632 0.200 13.147 0.000 2.219 3.011
## Std.lv Std.all
## 1.034 1.597
## 1.829 2.317
## 2.632 5.880
##
## Variances:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## .CS_AVG 0.217 0.024 8.958 0.000 0.169 0.262
## .PSNQ_AVG 0.295 0.034 8.734 0.000 0.227 0.362
## .BRS_AVG 0.193 0.018 10.679 0.000 0.155 0.226
## Std.lv Std.all
## 0.217 0.517
## 0.295 0.473
## 0.193 0.962
##
## R-Square:
## Estimate
## CS_AVG 0.483
## PSNQ_AVG 0.527
## BRS_AVG 0.038
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) ci.lower ci.upper
## indirect1 0.398 0.064 6.256 0.000 0.289 0.548
## indirect2 -0.006 0.009 -0.673 0.501 -0.029 0.010
## contrast 0.405 0.066 6.139 0.000 0.292 0.556
## total_indircts 0.392 0.063 6.243 0.000 0.280 0.536
## total_c 0.402 0.049 8.133 0.000 0.299 0.491
## direct 0.010 0.073 0.138 0.890 -0.144 0.146
## Std.lv Std.all
## 0.398 0.501
## -0.006 -0.008
## 0.405 0.509
## 0.392 0.493
## 0.402 0.506
## 0.010 0.013
print(pfit_ParEsts)
## lhs op rhs label est se z
## 1 CS_AVG ~ PSNQ_AVG b1 0.566 0.074 7.677
## 2 CS_AVG ~ BRS_AVG b2 -0.059 0.082 -0.722
## 3 CS_AVG ~ SS_AVG c_p 0.010 0.073 0.139
## 4 PSNQ_AVG ~ SS_AVG a1 0.704 0.048 14.596
## 5 BRS_AVG ~ SS_AVG a2 0.107 0.037 2.885
## 6 CS_AVG ~~ CS_AVG 0.217 0.024 8.958
## 7 PSNQ_AVG ~~ PSNQ_AVG 0.295 0.034 8.734
## 8 BRS_AVG ~~ BRS_AVG 0.193 0.018 10.679
## 9 SS_AVG ~~ SS_AVG 0.663 0.000 NA
## 10 CS_AVG ~1 1.034 0.300 3.445
## 11 PSNQ_AVG ~1 1.829 0.268 6.821
## 12 BRS_AVG ~1 2.632 0.200 13.147
## 13 SS_AVG ~1 5.394 0.000 NA
## 14 indirect1 := a1*b1 indirect1 0.398 0.064 6.256
## 15 indirect2 := a2*b2 indirect2 -0.006 0.009 -0.673
## 16 contrast := indirect1-indirect2 contrast 0.405 0.066 6.139
## 17 total_indirects := indirect1+indirect2 total_indirects 0.392 0.063 6.243
## 18 total_c := c_p+total_indirects total_c 0.402 0.049 8.133
## 19 direct := c_p direct 0.010 0.073 0.138
## pvalue ci.lower ci.upper std.lv std.all std.nox
## 1 0.000 0.433 0.719 0.566 0.690 0.690
## 2 0.470 -0.223 0.091 -0.059 -0.041 -0.041
## 3 0.890 -0.132 0.160 0.010 0.013 0.016
## 4 0.000 0.602 0.794 0.704 0.726 0.892
## 5 0.004 0.035 0.181 0.107 0.195 0.240
## 6 0.000 0.178 0.273 0.217 0.517 0.517
## 7 0.000 0.241 0.381 0.295 0.473 0.473
## 8 0.000 0.159 0.233 0.193 0.962 0.962
## 9 NA 0.663 0.663 0.663 1.000 0.663
## 10 0.001 0.448 1.662 1.034 1.597 1.597
## 11 0.000 1.323 2.383 1.829 2.317 2.317
## 12 0.000 2.224 3.016 2.632 5.880 5.880
## 13 NA 5.394 5.394 5.394 6.627 5.394
## 14 0.000 0.283 0.537 0.398 0.501 0.615
## 15 0.501 -0.031 0.009 -0.006 -0.008 -0.010
## 16 0.000 0.289 0.551 0.405 0.509 0.625
## 17 0.000 0.277 0.530 0.392 0.493 0.606
## 18 0.000 0.297 0.490 0.402 0.506 0.621
## 19 0.890 -0.132 0.160 0.010 0.013 0.016