library(multilevel)
## Loading required package: nlme
## Loading required package: MASS
library(car)
## Loading required package: carData
library(sjstats)
## Registered S3 methods overwritten by 'lme4':
##   method                          from
##   cooks.distance.influence.merMod car 
##   influence.merMod                car 
##   dfbeta.influence.merMod         car 
##   dfbetas.influence.merMod        car
library(psych)
## 
## Attaching package: 'psych'
## The following object is masked from 'package:sjstats':
## 
##     phi
## The following object is masked from 'package:car':
## 
##     logit
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.0.5     ✓ dplyr   1.0.3
## ✓ tidyr   1.1.2     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x ggplot2::%+%()    masks psych::%+%()
## x ggplot2::alpha()  masks psych::alpha()
## x dplyr::collapse() masks nlme::collapse()
## x dplyr::filter()   masks stats::filter()
## x dplyr::lag()      masks stats::lag()
## x dplyr::recode()   masks car::recode()
## x dplyr::select()   masks MASS::select()
## x purrr::some()     masks car::some()
library(QuantPsyc)
## Loading required package: boot
## 
## Attaching package: 'boot'
## The following object is masked from 'package:psych':
## 
##     logit
## The following object is masked from 'package:car':
## 
##     logit
## 
## Attaching package: 'QuantPsyc'
## The following object is masked from 'package:base':
## 
##     norm
library(readr)
library(dplyr)
library(rockchalk)
## 
## Attaching package: 'rockchalk'
## The following object is masked from 'package:QuantPsyc':
## 
##     meanCenter
## The following object is masked from 'package:dplyr':
## 
##     summarize
## The following object is masked from 'package:MASS':
## 
##     mvrnorm
library(corrplot)
## corrplot 0.84 loaded
library(ggplot2)
library(GGally)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
library(ggpubr)
library(Hmisc)
## Loading required package: lattice
## 
## Attaching package: 'lattice'
## The following object is masked from 'package:boot':
## 
##     melanoma
## Loading required package: survival
## 
## Attaching package: 'survival'
## The following object is masked from 'package:boot':
## 
##     aml
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## The following object is masked from 'package:rockchalk':
## 
##     summarize
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following object is masked from 'package:psych':
## 
##     describe
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(lavaan)
## This is lavaan 0.6-8
## lavaan is FREE software! Please report any bugs.
## 
## Attaching package: 'lavaan'
## The following object is masked from 'package:psych':
## 
##     cor2cov
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following objects are masked from 'package:rockchalk':
## 
##     kurtosis, skewness
## The following object is masked from 'package:graphics':
## 
##     legend
library(jmv)
## 
## Attaching package: 'jmv'
## The following object is masked from 'package:lavaan':
## 
##     cfa
## The following object is masked from 'package:psych':
## 
##     pca
library(moments)
## 
## Attaching package: 'moments'
## The following objects are masked from 'package:PerformanceAnalytics':
## 
##     kurtosis, skewness
## The following objects are masked from 'package:rockchalk':
## 
##     kurtosis, skewness
library(plyr)
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:Hmisc':
## 
##     is.discrete, summarize
## The following object is masked from 'package:ggpubr':
## 
##     mutate
## The following object is masked from 'package:rockchalk':
## 
##     summarize
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following object is masked from 'package:purrr':
## 
##     compact
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(semPlot)
library(bda)
## bda v15 (Bin Wang, 2020)
library(relaimpo)
## Loading required package: survey
## Loading required package: grid
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Attaching package: 'survey'
## The following object is masked from 'package:Hmisc':
## 
##     deff
## The following object is masked from 'package:sjstats':
## 
##     cv
## The following object is masked from 'package:graphics':
## 
##     dotchart
## Loading required package: mitools
## This is the global version of package relaimpo.
## If you are a non-US user, a version with the interesting additional metric pmvd is available
## from Ulrike Groempings web site at prof.beuth-hochschule.de/groemping.
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(readxl)
library(tidyverse)
library(ggpubr)
library(lme4)
## 
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
## 
##     lmList
library(sjPlot)
## Registered S3 methods overwritten by 'datawizard':
##   method                           from      
##   as.double.parameters_kurtosis    parameters
##   as.double.parameters_skewness    parameters
##   as.double.parameters_smoothness  parameters
##   as.numeric.parameters_kurtosis   parameters
##   as.numeric.parameters_skewness   parameters
##   as.numeric.parameters_smoothness parameters
##   print.parameters_distribution    parameters
##   print.parameters_kurtosis        parameters
##   print.parameters_skewness        parameters
##   summary.parameters_kurtosis      parameters
##   summary.parameters_skewness      parameters
## #refugeeswelcome
library(emmeans)
## 
## Attaching package: 'emmeans'
## The following object is masked from 'package:GGally':
## 
##     pigs
library(car)
library(Rmisc)
library(jmv)
library(RColorBrewer)
library(MBESS)
## 
## Attaching package: 'MBESS'
## The following object is masked from 'package:survey':
## 
##     cv
## The following object is masked from 'package:lavaan':
## 
##     cor2cov
## The following object is masked from 'package:psych':
## 
##     cor2cov
## The following objects are masked from 'package:sjstats':
## 
##     cv, mediation
library(semTable)

pp <- read_csv("personal.projects.merged.v7.csv") #wide format
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double(),
##   recruit.source = col_character(),
##   pp.1 = col_character(),
##   pp.2 = col_character(),
##   pp.3 = col_character(),
##   perf = col_character(),
##   mh = col_character(),
##   pp1.type = col_character(),
##   pp2.type = col_character(),
##   pp3.type = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
pp.full <- read_csv("personal.projects.merged.v5.csv") #long format
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   id...1 = col_double(),
##   pp.type = col_character(),
##   type = col_character(),
##   id...4 = col_double(),
##   pp.support = col_character(),
##   support = col_double(),
##   id...7 = col_double(),
##   pp.competence = col_character(),
##   competence = col_double(),
##   id...10 = col_double(),
##   pp.autonomy = col_character(),
##   autonomy = col_double()
## )
pp$ethnicity <- factor(pp$ethnicity,levels = c(1,2,3),labels = c("white", "black", "asian"))
pp$student <- factor(pp$student,levels = c(1,2,3),labels = c("full-time", "part-time", "not a student"))
pp$gender <- factor(pp$gender,levels = c(1,2,3, 4),labels = c("female", "male", "non-binary", "perfer not to answer"))
pp$occupation <- factor(pp$occupation,levels = c(1,2,3),labels = c("full-time", "part-time", "not working"))

#########################################################################################################
                        ### DESCRIPTIVE STATISTICS ###

#scales
descriptives(pp, vars = vars(bpns, age, autonomy, competence, relatedness, pp.support, pp.competence, pp.autonomy), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                                                                                                          
##  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
##                          bpns        age         autonomy    competence    relatedness    pp.support    pp.competence    pp.autonomy   
##  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
##    N                          323         303         323           323            322           303              303            303   
##    Missing                      4          24           4             4              5            24               24             24   
##    Mean                  5.037668    24.94719    5.391641      5.088235       4.627329      6.918592         7.613861       8.224422   
##    Median                5.166667    21.00000    5.500000      5.500000       5.000000      7.666667         8.000000       8.666667   
##    Standard deviation    1.107744    10.49490    1.278352      1.296478       1.654108      2.333012         1.932488       1.903547   
##    Minimum               1.000000    17.00000    1.000000      1.000000       1.000000      0.000000         0.000000       0.000000   
##    Maximum               7.000000    72.00000    7.000000      7.000000       7.000000      10.00000         10.00000       10.00000   
##  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
descriptives(pp, vars = vars(pp.importance, pp.difficulty, pp.visibility, pp.control, pp.respons, pp.outcome, 
                                                         pp.othersview, pp.congruency, pp.progress, pp.challenge, pp.absorp), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                                                                                                                                                                      
##  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
##                          pp.importance    pp.difficulty    pp.visibility    pp.control    pp.respons    pp.outcome    pp.othersview    pp.congruency    pp.progress    pp.challenge    pp.absorp   
##  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
##    N                               327              327              327           327           327           327              327              327            327             327          327   
##    Missing                           0                0                0             0             0             0                0                0              0               0            0   
##    Mean                       23.77676         20.39144         21.29358      19.55963      23.23547      21.13456         19.48318         22.36391       21.45872        20.64832     19.90826   
##    Median                     27.00000         23.00000         23.00000      21.00000      26.00000      24.00000         22.00000         25.00000       24.00000        23.00000     22.00000   
##    Standard deviation         8.429917         7.779929         8.002265      7.876849      8.500608      8.034832         8.486304         8.314688       8.138222        7.949719     7.982966   
##    Minimum                    0.000000         0.000000         0.000000      0.000000      0.000000      0.000000         0.000000         0.000000       0.000000        0.000000     0.000000   
##    Maximum                    30.00000         30.00000         30.00000      30.00000      30.00000      30.00000         30.00000         30.00000       30.00000        30.00000     30.00000   
##  ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
descriptives(pp, vars = vars(pp.timeadeq, pp.trademark), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                          
##  ───────────────────────────────────────────────────── 
##                          pp.timeadeq    pp.trademark   
##  ───────────────────────────────────────────────────── 
##    N                             327             327   
##    Missing                         0               0   
##    Mean                     17.22936        19.83486   
##    Median                   19.00000        22.00000   
##    Standard deviation       7.903521        8.542403   
##    Minimum                  0.000000        0.000000   
##    Maximum                  31.00000        31.00000   
##  ─────────────────────────────────────────────────────
descriptives(pp, vars = vars(passion, vlq, zestR, engagementR), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                                               
##  ────────────────────────────────────────────────────────────────────────── 
##                          passion      vlq         zestR       engagementR   
##  ────────────────────────────────────────────────────────────────────────── 
##    N                           313         308         310            310   
##    Missing                      14          19          17             17   
##    Mean                   4.173513    52.05205    4.556896       4.051452   
##    Median                 4.375000    50.15000    4.500000       4.166667   
##    Standard deviation    0.8088683    17.58257    1.216113      0.5646091   
##    Minimum                1.000000    1.000000    1.333333       2.500000   
##    Maximum                5.000000    100.0000    6.916667       5.166667   
##  ──────────────────────────────────────────────────────────────────────────
descriptives(pp, vars = vars(as.5f, as.6f, aps.stand, aps.discrep), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                                                 
##  ──────────────────────────────────────────────────────────────────────────── 
##                          as.5f        as.6f        aps.stand    aps.discrep   
##  ──────────────────────────────────────────────────────────────────────────── 
##    N                           327          327          314            315   
##    Missing                       0            0           13             12   
##    Mean                   4.691957     4.403874     5.806688       4.233790   
##    Median                 4.666667     4.375000     6.000000       4.250000   
##    Standard deviation    0.5494878    0.6245790     1.026802       1.434279   
##    Minimum                1.000000     1.000000     1.000000       1.000000   
##    Maximum                7.000000     7.000000     7.000000       7.000000   
##  ────────────────────────────────────────────────────────────────────────────
descriptives(pp, vars = vars(mhcR, mhc.e, mhc.s, mhc.pR), missing = TRUE, sd = TRUE)
## 
##  DESCRIPTIVES
## 
##  Descriptives                                                           
##  ────────────────────────────────────────────────────────────────────── 
##                          mhcR        mhc.e       mhc.s       mhc.pR     
##  ────────────────────────────────────────────────────────────────────── 
##    N                          317         317         317         317   
##    Missing                     10          10          10          10   
##    Mean                  3.881712    4.390116    3.381178    4.213354   
##    Median                4.000000    4.666667    3.500000    4.400000   
##    Standard deviation    1.031149    1.185472    1.231826    1.156744   
##    Minimum               1.000000    1.000000    1.000000    1.000000   
##    Maximum               6.000000    6.000000    6.000000    6.000000   
##  ──────────────────────────────────────────────────────────────────────
##################################################################################################################
#H1: Achievement striving leads to satisfaction of competence needs at both the psychological and project level, 
# which in turn leads to well-being, even when controlling for perfectionist standards and discrepancies 
##################################################################################################################


mmed1.mhcR <- 

  '
mhcR ~ b1 * competence + b2 * pp.competence + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep 
pp.competence ~ a1 * as.5f
pp.competence ~ aa1 * aps.stand
pp.competence ~ aaa1 * aps.discrep
competence ~ d21 * pp.competence
competence ~ aa2 * aps.stand
competence ~ aaa2 * aps.discrep
competence ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
competence ~ sample
pp.competence ~ sample
mhcR ~ sample
'

#covariance section of output - sample is positively related w. A.S. (because dal students, sona = 1)
#aps.r standards subscale a little different from self-oriented perfectionism

fit1.mhcR <- sem(model = mmed1.mhcR, data = pp)
summary(fit1.mhcR, standardized = TRUE)
## lavaan 0.6-8 ended normally after 46 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   mhcR ~                                                                
##     comptnc   (b1)    0.268    0.044    6.069    0.000    0.268    0.344
##     pp.cmpt   (b2)    0.069    0.027    2.541    0.011    0.069    0.132
##     as.5f     (c1)    0.184    0.093    1.986    0.047    0.184    0.099
##     aps.stn   (c2)    0.068    0.055    1.236    0.216    0.068    0.067
##     aps.dsc   (c3)   -0.205    0.036   -5.630    0.000   -0.205   -0.288
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.191    3.424    0.001    0.654    0.185
##     aps.stn  (aa1)    0.653    0.107    6.111    0.000    0.653    0.336
##     aps.dsc (aaa1)   -0.365    0.070   -5.248    0.000   -0.365   -0.270
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.035    3.691    0.000    0.128    0.190
##     aps.stn  (aa2)    0.399    0.068    5.855    0.000    0.399    0.305
##     aps.dsc (aaa2)   -0.318    0.044   -7.279    0.000   -0.318   -0.349
##     as.5f     (a2)    0.517    0.117    4.415    0.000    0.517    0.217
##     sample           -0.148    0.131   -1.131    0.258   -0.148   -0.053
##   pp.competence ~                                                       
##     sample            0.156    0.218    0.713    0.476    0.156    0.037
##   mhcR ~                                                                
##     sample           -0.139    0.101   -1.380    0.167   -0.139   -0.063
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .mhcR              0.605    0.049   12.288    0.000    0.605    0.593
##    .pp.competence     2.846    0.232   12.288    0.000    2.846    0.766
##    .competence        1.030    0.084   12.288    0.000    1.030    0.611
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.216    0.061    3.533    0.000    0.216    0.097
##     standardsndrct    0.208    0.042    4.992    0.000    0.208    0.164
##     discrepindirct   -0.123    0.026   -4.750    0.000   -0.123   -0.145
##     total1            0.400    0.103    3.886    0.000    0.400    0.196
##     total2            0.276    0.058    4.727    0.000    0.276    0.231
##     total3           -0.327    0.038   -8.728    0.000   -0.327   -0.434
fit1.mhcR <- sem(
  model = mmed1.mhcR,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit1.mhcR, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 46 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               454.555
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2738.949
##   Loglikelihood unrestricted model (H1)      -2738.949
##                                                       
##   Akaike (AIC)                                5533.898
##   Bayesian (BIC)                              5637.790
##   Sample-size adjusted Bayesian (BIC)         5548.989
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   mhcR ~                                                                
##     comptnc   (b1)    0.268    0.045    5.999    0.000    0.180    0.355
##     pp.cmpt   (b2)    0.069    0.031    2.244    0.025    0.011    0.130
##     as.5f     (c1)    0.184    0.102    1.795    0.073   -0.028    0.373
##     aps.stn   (c2)    0.068    0.058    1.177    0.239   -0.054    0.173
##     aps.dsc   (c3)   -0.205    0.038   -5.381    0.000   -0.278   -0.130
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.204    3.210    0.001    0.224    1.014
##     aps.stn  (aa1)    0.653    0.119    5.505    0.000    0.429    0.894
##     aps.dsc (aaa1)   -0.365    0.074   -4.905    0.000   -0.513   -0.221
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.039    3.270    0.001    0.051    0.206
##     aps.stn  (aa2)    0.399    0.077    5.189    0.000    0.243    0.541
##     aps.dsc (aaa2)   -0.318    0.046   -6.860    0.000   -0.408   -0.227
##     as.5f     (a2)    0.517    0.141    3.672    0.000    0.231    0.784
##     sample           -0.148    0.128   -1.158    0.247   -0.400    0.099
##   pp.competence ~                                                       
##     sample            0.156    0.230    0.677    0.498   -0.299    0.606
##   mhcR ~                                                                
##     sample           -0.139    0.106   -1.313    0.189   -0.340    0.076
##    Std.lv  Std.all
##                   
##     0.268    0.344
##     0.069    0.132
##     0.184    0.099
##     0.068    0.067
##    -0.205   -0.288
##                   
##     0.654    0.185
##     0.653    0.336
##    -0.365   -0.270
##                   
##     0.128    0.190
##     0.399    0.305
##    -0.318   -0.349
##     0.517    0.217
##    -0.148   -0.053
##                   
##     0.156    0.037
##                   
##    -0.139   -0.063
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.068    2.787    0.005    0.079    0.341
##     sample            0.034    0.017    2.029    0.042    0.002    0.067
##     aps.discrep       0.060    0.060    1.014    0.311   -0.048    0.186
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.096    2.203    0.028    0.025    0.409
##     sample            0.098    0.029    3.350    0.001    0.041    0.155
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.639    0.008    0.025    0.176
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .mhcR              0.605    0.047   12.931    0.000    0.502    0.684
##    .pp.competence     2.846    0.297    9.584    0.000    2.246    3.405
##    .competence        1.030    0.082   12.515    0.000    0.847    1.166
##     as.5f             0.297    0.053    5.582    0.000    0.208    0.412
##     aps.stand         0.986    0.122    8.082    0.000    0.768    1.246
##     aps.discrep       2.024    0.132   15.306    0.000    1.756    2.286
##     sample            0.212    0.010   20.176    0.000    0.188    0.230
##    Std.lv  Std.all
##     0.605    0.593
##     2.846    0.766
##     1.030    0.611
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     mhcR              0.407
##     pp.competence     0.234
##     competence        0.389
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.216    0.065    3.311    0.001    0.087    0.345
##     standardsndrct    0.208    0.041    5.037    0.000    0.134    0.295
##     discrepindirct   -0.123    0.028   -4.422    0.000   -0.183   -0.072
##     total1            0.400    0.116    3.443    0.001    0.146    0.607
##     total2            0.276    0.059    4.697    0.000    0.154    0.383
##     total3           -0.327    0.038   -8.521    0.000   -0.400   -0.253
##    Std.lv  Std.all
##     0.216    0.097
##     0.208    0.164
##    -0.123   -0.145
##     0.400    0.196
##     0.276    0.231
##    -0.327   -0.434
standardizedSolution(fit1.mhcR, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1               mhcR  ~                       competence   0.344 0.056  6.100
## 2               mhcR  ~                    pp.competence   0.132 0.057  2.325
## 3               mhcR  ~                            as.5f   0.099 0.058  1.695
## 4               mhcR  ~                        aps.stand   0.067 0.057  1.165
## 5               mhcR  ~                      aps.discrep  -0.288 0.053 -5.433
## 6      pp.competence  ~                            as.5f   0.185 0.061  3.016
## 7      pp.competence  ~                        aps.stand   0.336 0.058  5.777
## 8      pp.competence  ~                      aps.discrep  -0.270 0.054 -4.965
## 9         competence  ~                    pp.competence   0.190 0.057  3.316
## 10        competence  ~                        aps.stand   0.305 0.063  4.808
## 11        competence  ~                      aps.discrep  -0.349 0.049 -7.052
## 12        competence  ~                            as.5f   0.217 0.062  3.497
## 13             as.5f ~~                        aps.stand   0.352 0.090  3.928
## 14             as.5f ~~                           sample   0.135 0.062  2.187
## 15             as.5f ~~                      aps.discrep   0.078 0.072  1.083
## 16         aps.stand ~~                      aps.discrep   0.150 0.062  2.404
## 17         aps.stand ~~                           sample   0.214 0.059  3.614
## 18       aps.discrep ~~                           sample   0.155 0.057  2.696
## 19        competence  ~                           sample  -0.053 0.045 -1.163
## 20     pp.competence  ~                           sample   0.037 0.055  0.678
## 21              mhcR  ~                           sample  -0.063 0.048 -1.311
## 22              mhcR ~~                             mhcR   0.593 0.046 12.955
## 23     pp.competence ~~                    pp.competence   0.766 0.046 16.824
## 24        competence ~~                       competence   0.611 0.051 12.061
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.097 0.030  3.231
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.164 0.032  5.118
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.145 0.034 -4.275
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.196 0.068  2.888
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.231 0.058  4.018
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.434 0.051 -8.561
##    pvalue ci.lower ci.upper
## 1   0.000    0.234    0.455
## 2   0.020    0.021    0.242
## 3   0.090   -0.015    0.214
## 4   0.244   -0.046    0.180
## 5   0.000   -0.392   -0.184
## 6   0.003    0.065    0.305
## 7   0.000    0.222    0.450
## 8   0.000   -0.376   -0.163
## 9   0.001    0.078    0.302
## 10  0.000    0.181    0.429
## 11  0.000   -0.446   -0.252
## 12  0.000    0.095    0.338
## 13  0.000    0.176    0.527
## 14  0.029    0.014    0.256
## 15  0.279   -0.063    0.219
## 16  0.016    0.028    0.272
## 17  0.000    0.098    0.331
## 18  0.007    0.042    0.267
## 19  0.245   -0.141    0.036
## 20  0.498   -0.070    0.145
## 21  0.190   -0.158    0.031
## 22  0.000    0.503    0.683
## 23  0.000    0.677    0.855
## 24  0.000    0.511    0.710
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.001    0.038    0.155
## 30  0.000    0.101    0.227
## 31  0.000   -0.212   -0.079
## 32  0.004    0.063    0.329
## 33  0.000    0.118    0.344
## 34  0.000   -0.533   -0.334
parameterEstimates(fit1.mhcR, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1               mhcR  ~                       competence                b1
## 2               mhcR  ~                    pp.competence                b2
## 3               mhcR  ~                            as.5f                c1
## 4               mhcR  ~                        aps.stand                c2
## 5               mhcR  ~                      aps.discrep                c3
## 6      pp.competence  ~                            as.5f                a1
## 7      pp.competence  ~                        aps.stand               aa1
## 8      pp.competence  ~                      aps.discrep              aaa1
## 9         competence  ~                    pp.competence               d21
## 10        competence  ~                        aps.stand               aa2
## 11        competence  ~                      aps.discrep              aaa2
## 12        competence  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19        competence  ~                           sample                  
## 20     pp.competence  ~                           sample                  
## 21              mhcR  ~                           sample                  
## 22              mhcR ~~                             mhcR                  
## 23     pp.competence ~~                    pp.competence                  
## 24        competence ~~                       competence                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.268 0.045  5.999  0.000    0.181    0.357
## 2   0.069 0.031  2.244  0.025    0.010    0.130
## 3   0.184 0.102  1.795  0.073   -0.024    0.375
## 4   0.068 0.058  1.177  0.239   -0.047    0.178
## 5  -0.205 0.038 -5.381  0.000   -0.276   -0.127
## 6   0.654 0.204  3.210  0.001    0.262    1.039
## 7   0.653 0.119  5.505  0.000    0.428    0.894
## 8  -0.365 0.074 -4.905  0.000   -0.512   -0.220
## 9   0.128 0.039  3.270  0.001    0.052    0.206
## 10  0.399 0.077  5.189  0.000    0.242    0.540
## 11 -0.318 0.046 -6.860  0.000   -0.409   -0.228
## 12  0.517 0.141  3.672  0.000    0.236    0.790
## 13  0.190 0.068  2.787  0.005    0.089    0.366
## 14  0.034 0.017  2.029  0.042    0.003    0.068
## 15  0.060 0.060  1.014  0.311   -0.043    0.193
## 16  0.212 0.096  2.203  0.028    0.045    0.429
## 17  0.098 0.029  3.350  0.001    0.043    0.157
## 18  0.101 0.038  2.639  0.008    0.025    0.177
## 19 -0.148 0.128 -1.158  0.247   -0.408    0.093
## 20  0.156 0.230  0.677  0.498   -0.285    0.621
## 21 -0.139 0.106 -1.313  0.189   -0.348    0.063
## 22  0.605 0.047 12.931  0.000    0.531    0.726
## 23  2.846 0.297  9.584  0.000    2.363    3.567
## 24  1.030 0.082 12.515  0.000    0.897    1.228
## 25  0.297 0.053  5.582  0.000    0.216    0.431
## 26  0.986 0.122  8.082  0.000    0.786    1.271
## 27  2.024 0.132 15.306  0.000    1.782    2.313
## 28  0.212 0.010 20.176  0.000    0.189    0.231
## 29  0.216 0.065  3.311  0.001    0.102    0.361
## 30  0.208 0.041  5.037  0.000    0.139    0.304
## 31 -0.123 0.028 -4.422  0.000   -0.187   -0.075
## 32  0.400 0.116  3.443  0.001    0.157    0.616
## 33  0.276 0.059  4.697  0.000    0.161    0.389
## 34 -0.327 0.038 -8.521  0.000   -0.397   -0.248
#########################################################################################################

#Mediation model with zest as outcome controlling for perfectionistic standards and discrepancies

mmed1.zest <- 

  '
zestR ~ b1 * competence + b2 * pp.competence + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.competence ~ a1 * as.5f
pp.competence ~ aa1 * aps.stand
pp.competence ~ aaa1 * aps.discrep
competence ~ d21 * pp.competence
competence ~ aa2 * aps.stand
competence ~ aaa2 * aps.discrep
competence ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
competence ~ sample
pp.competence ~ sample
zestR ~ sample
'

fit1.zest <- sem(model = mmed1.zest, data = pp)
summary(fit1.zest, standardized = TRUE)
## lavaan 0.6-8 ended normally after 45 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   zestR ~                                                               
##     comptnc   (b1)    0.221    0.055    4.014    0.000    0.221    0.237
##     pp.cmpt   (b2)    0.052    0.034    1.540    0.124    0.052    0.083
##     as.5f     (c1)    0.166    0.116    1.432    0.152    0.166    0.074
##     aps.stn   (c2)    0.038    0.069    0.553    0.580    0.038    0.031
##     aps.dsc   (c3)   -0.358    0.045   -7.877    0.000   -0.358   -0.419
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.191    3.424    0.001    0.654    0.185
##     aps.stn  (aa1)    0.653    0.107    6.111    0.000    0.653    0.336
##     aps.dsc (aaa1)   -0.365    0.070   -5.248    0.000   -0.365   -0.270
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.035    3.691    0.000    0.128    0.190
##     aps.stn  (aa2)    0.399    0.068    5.855    0.000    0.399    0.305
##     aps.dsc (aaa2)   -0.318    0.044   -7.279    0.000   -0.318   -0.349
##     as.5f     (a2)    0.517    0.117    4.415    0.000    0.517    0.217
##     sample           -0.148    0.131   -1.131    0.258   -0.148   -0.053
##   pp.competence ~                                                       
##     sample            0.156    0.218    0.713    0.476    0.156    0.037
##   zestR ~                                                               
##     sample           -0.011    0.126   -0.090    0.929   -0.011   -0.004
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .zestR             0.945    0.077   12.288    0.000    0.945    0.642
##    .pp.competence     2.846    0.232   12.288    0.000    2.846    0.766
##    .competence        1.030    0.084   12.288    0.000    1.030    0.611
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.176    0.058    3.046    0.002    0.176    0.065
##     standardsndrct    0.170    0.044    3.869    0.000    0.170    0.110
##     discrepindirct   -0.100    0.027   -3.745    0.000   -0.100   -0.097
##     total1            0.341    0.118    2.882    0.004    0.341    0.139
##     total2            0.208    0.067    3.084    0.002    0.208    0.141
##     total3           -0.458    0.043  -10.598    0.000   -0.458   -0.516
fit1.zest <- sem(
  model = mmed1.zest,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit1.zest, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 45 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               430.781
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2806.271
##   Loglikelihood unrestricted model (H1)      -2806.271
##                                                       
##   Akaike (AIC)                                5668.541
##   Bayesian (BIC)                              5772.433
##   Sample-size adjusted Bayesian (BIC)         5683.632
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   zestR ~                                                               
##     comptnc   (b1)    0.221    0.058    3.795    0.000    0.107    0.337
##     pp.cmpt   (b2)    0.052    0.043    1.222    0.222   -0.029    0.138
##     as.5f     (c1)    0.166    0.115    1.445    0.149   -0.064    0.392
##     aps.stn   (c2)    0.038    0.070    0.542    0.588   -0.100    0.176
##     aps.dsc   (c3)   -0.358    0.047   -7.565    0.000   -0.451   -0.265
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.202    3.237    0.001    0.228    1.020
##     aps.stn  (aa1)    0.653    0.121    5.397    0.000    0.428    0.898
##     aps.dsc (aaa1)   -0.365    0.074   -4.955    0.000   -0.511   -0.224
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.039    3.312    0.001    0.053    0.205
##     aps.stn  (aa2)    0.399    0.077    5.160    0.000    0.238    0.543
##     aps.dsc (aaa2)   -0.318    0.047   -6.786    0.000   -0.409   -0.226
##     as.5f     (a2)    0.517    0.142    3.637    0.000    0.225    0.790
##     sample           -0.148    0.128   -1.158    0.247   -0.394    0.114
##   pp.competence ~                                                       
##     sample            0.156    0.227    0.685    0.494   -0.279    0.622
##   zestR ~                                                               
##     sample           -0.011    0.135   -0.084    0.933   -0.280    0.248
##    Std.lv  Std.all
##                   
##     0.221    0.237
##     0.052    0.083
##     0.166    0.074
##     0.038    0.031
##    -0.358   -0.419
##                   
##     0.654    0.185
##     0.653    0.336
##    -0.365   -0.270
##                   
##     0.128    0.190
##     0.399    0.305
##    -0.318   -0.349
##     0.517    0.217
##    -0.148   -0.053
##                   
##     0.156    0.037
##                   
##    -0.011   -0.004
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.067    2.855    0.004    0.078    0.344
##     sample            0.034    0.017    2.024    0.043    0.002    0.067
##     aps.discrep       0.060    0.059    1.028    0.304   -0.047    0.185
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.095    2.229    0.026    0.031    0.410
##     sample            0.098    0.029    3.425    0.001    0.044    0.157
##   aps.discrep ~~                                                        
##     sample            0.101    0.039    2.620    0.009    0.027    0.180
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .zestR             0.945    0.077   12.266    0.000    0.771    1.072
##    .pp.competence     2.846    0.297    9.596    0.000    2.231    3.398
##    .competence        1.030    0.082   12.565    0.000    0.855    1.176
##     as.5f             0.297    0.052    5.714    0.000    0.210    0.410
##     aps.stand         0.986    0.119    8.294    0.000    0.767    1.233
##     aps.discrep       2.024    0.131   15.502    0.000    1.767    2.272
##     sample            0.212    0.010   20.528    0.000    0.190    0.230
##    Std.lv  Std.all
##     0.945    0.642
##     2.846    0.766
##     1.030    0.611
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     zestR             0.358
##     pp.competence     0.234
##     competence        0.389
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.176    0.064    2.764    0.006    0.059    0.309
##     standardsndrct    0.170    0.050    3.418    0.001    0.082    0.277
##     discrepindirct   -0.100    0.030   -3.305    0.001   -0.165   -0.045
##     total1            0.341    0.111    3.064    0.002    0.109    0.552
##     total2            0.208    0.070    2.986    0.003    0.070    0.345
##     total3           -0.458    0.046   -9.986    0.000   -0.547   -0.366
##    Std.lv  Std.all
##     0.176    0.065
##     0.170    0.110
##    -0.100   -0.097
##     0.341    0.139
##     0.208    0.141
##    -0.458   -0.516
standardizedSolution(fit1.zest, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se       z
## 1              zestR  ~                       competence   0.237 0.062   3.841
## 2              zestR  ~                    pp.competence   0.083 0.067   1.239
## 3              zestR  ~                            as.5f   0.074 0.052   1.427
## 4              zestR  ~                        aps.stand   0.031 0.058   0.541
## 5              zestR  ~                      aps.discrep  -0.419 0.052  -8.061
## 6      pp.competence  ~                            as.5f   0.185 0.061   3.049
## 7      pp.competence  ~                        aps.stand   0.336 0.059   5.683
## 8      pp.competence  ~                      aps.discrep  -0.270 0.054  -5.032
## 9         competence  ~                    pp.competence   0.190 0.056   3.367
## 10        competence  ~                        aps.stand   0.305 0.063   4.826
## 11        competence  ~                      aps.discrep  -0.349 0.050  -7.032
## 12        competence  ~                            as.5f   0.217 0.062   3.473
## 13             as.5f ~~                        aps.stand   0.352 0.088   3.993
## 14             as.5f ~~                           sample   0.135 0.062   2.170
## 15             as.5f ~~                      aps.discrep   0.078 0.071   1.096
## 16         aps.stand ~~                      aps.discrep   0.150 0.062   2.434
## 17         aps.stand ~~                           sample   0.214 0.058   3.675
## 18       aps.discrep ~~                           sample   0.155 0.058   2.678
## 19        competence  ~                           sample  -0.053 0.045  -1.164
## 20     pp.competence  ~                           sample   0.037 0.054   0.685
## 21             zestR  ~                           sample  -0.004 0.051  -0.084
## 22             zestR ~~                            zestR   0.642 0.053  12.066
## 23     pp.competence ~~                    pp.competence   0.766 0.046  16.567
## 24        competence ~~                       competence   0.611 0.050  12.149
## 25             as.5f ~~                            as.5f   1.000 0.000      NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000      NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000      NA
## 28            sample ~~                           sample   1.000 0.000      NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.065 0.026   2.514
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.110 0.034   3.261
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.097 0.033  -2.907
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.139 0.052   2.678
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.141 0.055   2.591
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.516 0.049 -10.609
##    pvalue ci.lower ci.upper
## 1   0.000    0.116    0.358
## 2   0.215   -0.048    0.214
## 3   0.154   -0.028    0.176
## 4   0.589   -0.082    0.144
## 5   0.000   -0.521   -0.317
## 6   0.002    0.066    0.303
## 7   0.000    0.220    0.452
## 8   0.000   -0.375   -0.165
## 9   0.001    0.079    0.300
## 10  0.000    0.181    0.429
## 11  0.000   -0.446   -0.251
## 12  0.001    0.094    0.339
## 13  0.000    0.179    0.524
## 14  0.030    0.013    0.256
## 15  0.273   -0.061    0.217
## 16  0.015    0.029    0.270
## 17  0.000    0.100    0.329
## 18  0.007    0.041    0.268
## 19  0.244   -0.141    0.036
## 20  0.493   -0.069    0.143
## 21  0.933   -0.105    0.096
## 22  0.000    0.537    0.746
## 23  0.000    0.675    0.857
## 24  0.000    0.512    0.709
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.012    0.014    0.115
## 30  0.001    0.044    0.176
## 31  0.004   -0.162   -0.032
## 32  0.007    0.037    0.241
## 33  0.010    0.034    0.248
## 34  0.000   -0.612   -0.421
parameterEstimates(fit1.zest, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1              zestR  ~                       competence                b1
## 2              zestR  ~                    pp.competence                b2
## 3              zestR  ~                            as.5f                c1
## 4              zestR  ~                        aps.stand                c2
## 5              zestR  ~                      aps.discrep                c3
## 6      pp.competence  ~                            as.5f                a1
## 7      pp.competence  ~                        aps.stand               aa1
## 8      pp.competence  ~                      aps.discrep              aaa1
## 9         competence  ~                    pp.competence               d21
## 10        competence  ~                        aps.stand               aa2
## 11        competence  ~                      aps.discrep              aaa2
## 12        competence  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19        competence  ~                           sample                  
## 20     pp.competence  ~                           sample                  
## 21             zestR  ~                           sample                  
## 22             zestR ~~                            zestR                  
## 23     pp.competence ~~                    pp.competence                  
## 24        competence ~~                       competence                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.221 0.058  3.795  0.000    0.110    0.342
## 2   0.052 0.043  1.222  0.222   -0.030    0.137
## 3   0.166 0.115  1.445  0.149   -0.067    0.389
## 4   0.038 0.070  0.542  0.588   -0.100    0.176
## 5  -0.358 0.047 -7.565  0.000   -0.446   -0.261
## 6   0.654 0.202  3.237  0.001    0.250    1.048
## 7   0.653 0.121  5.397  0.000    0.433    0.908
## 8  -0.365 0.074 -4.955  0.000   -0.508   -0.219
## 9   0.128 0.039  3.312  0.001    0.051    0.203
## 10  0.399 0.077  5.160  0.000    0.242    0.546
## 11 -0.318 0.047 -6.786  0.000   -0.410   -0.227
## 12  0.517 0.142  3.637  0.000    0.241    0.804
## 13  0.190 0.067  2.855  0.004    0.091    0.369
## 14  0.034 0.017  2.024  0.043    0.002    0.068
## 15  0.060 0.059  1.028  0.304   -0.041    0.193
## 16  0.212 0.095  2.229  0.026    0.041    0.421
## 17  0.098 0.029  3.425  0.001    0.044    0.157
## 18  0.101 0.039  2.620  0.009    0.029    0.181
## 19 -0.148 0.128 -1.158  0.247   -0.400    0.108
## 20  0.156 0.227  0.685  0.494   -0.285    0.616
## 21 -0.011 0.135 -0.084  0.933   -0.272    0.256
## 22  0.945 0.077 12.266  0.000    0.820    1.117
## 23  2.846 0.297  9.596  0.000    2.345    3.505
## 24  1.030 0.082 12.565  0.000    0.896    1.223
## 25  0.297 0.052  5.714  0.000    0.219    0.435
## 26  0.986 0.119  8.294  0.000    0.790    1.259
## 27  2.024 0.131 15.502  0.000    1.779    2.289
## 28  0.212 0.010 20.528  0.000    0.190    0.230
## 29  0.176 0.064  2.764  0.006    0.073    0.333
## 30  0.170 0.050  3.418  0.001    0.086    0.286
## 31 -0.100 0.030 -3.305  0.001   -0.168   -0.048
## 32  0.341 0.111  3.064  0.002    0.111    0.555
## 33  0.208 0.070  2.986  0.003    0.071    0.347
## 34 -0.458 0.046 -9.986  0.000   -0.544   -0.363
#########################################################################################################

#Mediation model with engagement as outcome controlling for perfectionistic standards and discrepancies


mmed1.eng <- 

  '
engagementR ~ b1 * competence + b2 * pp.competence + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.competence ~ a1 * as.5f
pp.competence ~ aa1 * aps.stand
pp.competence ~ aaa1 * aps.discrep
competence ~ d21 * pp.competence
competence ~ aa2 * aps.stand
competence ~ aaa2 * aps.discrep
competence ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
competence ~ sample
pp.competence ~ sample
engagementR ~ sample
'

fit1.eng <- sem(model = mmed1.eng, data = pp)
summary(fit1.eng, standardized = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   engagementR ~                                                         
##     comptnc   (b1)    0.080    0.025    3.224    0.001    0.080    0.187
##     pp.cmpt   (b2)    0.050    0.015    3.243    0.001    0.050    0.172
##     as.5f     (c1)    0.126    0.052    2.424    0.015    0.126    0.124
##     aps.stn   (c2)    0.050    0.031    1.623    0.105    0.050    0.090
##     aps.dsc   (c3)   -0.149    0.020   -7.292    0.000   -0.149   -0.382
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.191    3.424    0.001    0.654    0.185
##     aps.stn  (aa1)    0.653    0.107    6.111    0.000    0.653    0.336
##     aps.dsc (aaa1)   -0.365    0.070   -5.248    0.000   -0.365   -0.270
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.035    3.691    0.000    0.128    0.190
##     aps.stn  (aa2)    0.399    0.068    5.855    0.000    0.399    0.305
##     aps.dsc (aaa2)   -0.318    0.044   -7.279    0.000   -0.318   -0.349
##     as.5f     (a2)    0.517    0.117    4.415    0.000    0.517    0.217
##     sample           -0.148    0.131   -1.131    0.258   -0.148   -0.053
##   pp.competence ~                                                       
##     sample            0.156    0.218    0.713    0.476    0.156    0.037
##   engagementR ~                                                         
##     sample           -0.054    0.057   -0.955    0.339   -0.054   -0.045
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .engagementR       0.192    0.016   12.288    0.000    0.192    0.620
##    .pp.competence     2.846    0.232   12.288    0.000    2.846    0.766
##    .competence        1.030    0.084   12.288    0.000    1.030    0.611
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.082    0.024    3.378    0.001    0.082    0.078
##     standardsndrct    0.076    0.019    3.998    0.000    0.076    0.126
##     discrepindirct   -0.047    0.012   -4.106    0.000   -0.047   -0.119
##     total1            0.209    0.053    3.965    0.000    0.209    0.201
##     total2            0.127    0.030    4.232    0.000    0.127    0.216
##     total3           -0.197    0.019  -10.261    0.000   -0.197   -0.501
fit1.eng <- sem(
  model = mmed1.eng,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit1.eng, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               441.014
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2565.805
##   Loglikelihood unrestricted model (H1)      -2565.805
##                                                       
##   Akaike (AIC)                                5187.610
##   Bayesian (BIC)                              5291.502
##   Sample-size adjusted Bayesian (BIC)         5202.702
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   engagementR ~                                                         
##     comptnc   (b1)    0.080    0.025    3.204    0.001    0.032    0.130
##     pp.cmpt   (b2)    0.050    0.018    2.832    0.005    0.016    0.086
##     as.5f     (c1)    0.126    0.053    2.389    0.017    0.020    0.228
##     aps.stn   (c2)    0.050    0.033    1.526    0.127   -0.012    0.117
##     aps.dsc   (c3)   -0.149    0.023   -6.599    0.000   -0.192   -0.104
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.207    3.164    0.002    0.213    1.026
##     aps.stn  (aa1)    0.653    0.116    5.611    0.000    0.433    0.888
##     aps.dsc (aaa1)   -0.365    0.074   -4.963    0.000   -0.508   -0.221
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.039    3.267    0.001    0.051    0.206
##     aps.stn  (aa2)    0.399    0.076    5.250    0.000    0.239    0.538
##     aps.dsc (aaa2)   -0.318    0.047   -6.843    0.000   -0.412   -0.228
##     as.5f     (a2)    0.517    0.140    3.688    0.000    0.233    0.782
##     sample           -0.148    0.131   -1.133    0.257   -0.401    0.119
##   pp.competence ~                                                       
##     sample            0.156    0.229    0.678    0.498   -0.298    0.598
##   engagementR ~                                                         
##     sample           -0.054    0.060   -0.900    0.368   -0.179    0.063
##    Std.lv  Std.all
##                   
##     0.080    0.187
##     0.050    0.172
##     0.126    0.124
##     0.050    0.090
##    -0.149   -0.382
##                   
##     0.654    0.185
##     0.653    0.336
##    -0.365   -0.270
##                   
##     0.128    0.190
##     0.399    0.305
##    -0.318   -0.349
##     0.517    0.217
##    -0.148   -0.053
##                   
##     0.156    0.037
##                   
##    -0.054   -0.045
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.069    2.777    0.005    0.079    0.344
##     sample            0.034    0.017    2.032    0.042    0.002    0.068
##     aps.discrep       0.060    0.060    1.010    0.312   -0.048    0.186
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.095    2.219    0.026    0.034    0.410
##     sample            0.098    0.030    3.320    0.001    0.041    0.156
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.655    0.008    0.028    0.177
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .engagementR       0.192    0.015   12.762    0.000    0.159    0.217
##    .pp.competence     2.846    0.293    9.721    0.000    2.233    3.383
##    .competence        1.030    0.082   12.585    0.000    0.851    1.172
##     as.5f             0.297    0.054    5.509    0.000    0.209    0.419
##     aps.stand         0.986    0.121    8.128    0.000    0.767    1.244
##     aps.discrep       2.024    0.134   15.158    0.000    1.761    2.285
##     sample            0.212    0.011   20.132    0.000    0.188    0.230
##    Std.lv  Std.all
##     0.192    0.620
##     2.846    0.766
##     1.030    0.611
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     engagementR       0.380
##     pp.competence     0.234
##     competence        0.389
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.082    0.028    2.925    0.003    0.031    0.141
##     standardsndrct    0.076    0.021    3.671    0.000    0.039    0.121
##     discrepindirct   -0.047    0.013   -3.727    0.000   -0.074   -0.025
##     total1            0.209    0.052    4.016    0.000    0.099    0.304
##     total2            0.127    0.032    3.896    0.000    0.067    0.194
##     total3           -0.197    0.021   -9.272    0.000   -0.237   -0.154
##    Std.lv  Std.all
##     0.082    0.078
##     0.076    0.126
##    -0.047   -0.119
##     0.209    0.201
##     0.127    0.216
##    -0.197   -0.501
standardizedSolution(fit1.eng, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se       z
## 1        engagementR  ~                       competence   0.187 0.058   3.244
## 2        engagementR  ~                    pp.competence   0.172 0.060   2.851
## 3        engagementR  ~                            as.5f   0.124 0.054   2.300
## 4        engagementR  ~                        aps.stand   0.090 0.058   1.539
## 5        engagementR  ~                      aps.discrep  -0.382 0.055  -6.994
## 6      pp.competence  ~                            as.5f   0.185 0.062   2.972
## 7      pp.competence  ~                        aps.stand   0.336 0.058   5.843
## 8      pp.competence  ~                      aps.discrep  -0.270 0.053  -5.049
## 9         competence  ~                    pp.competence   0.190 0.057   3.326
## 10        competence  ~                        aps.stand   0.305 0.062   4.879
## 11        competence  ~                      aps.discrep  -0.349 0.050  -7.013
## 12        competence  ~                            as.5f   0.217 0.062   3.501
## 13             as.5f ~~                        aps.stand   0.352 0.090   3.927
## 14             as.5f ~~                           sample   0.135 0.062   2.189
## 15             as.5f ~~                      aps.discrep   0.078 0.072   1.081
## 16         aps.stand ~~                      aps.discrep   0.150 0.062   2.424
## 17         aps.stand ~~                           sample   0.214 0.060   3.568
## 18       aps.discrep ~~                           sample   0.155 0.057   2.717
## 19        competence  ~                           sample  -0.053 0.046  -1.139
## 20     pp.competence  ~                           sample   0.037 0.055   0.679
## 21       engagementR  ~                           sample  -0.045 0.050  -0.897
## 22       engagementR ~~                      engagementR   0.620 0.048  12.792
## 23     pp.competence ~~                    pp.competence   0.766 0.046  16.606
## 24        competence ~~                       competence   0.611 0.050  12.096
## 25             as.5f ~~                            as.5f   1.000 0.000      NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000      NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000      NA
## 28            sample ~~                           sample   1.000 0.000      NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.078 0.027   2.850
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.126 0.032   3.902
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.119 0.031  -3.800
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.201 0.056   3.601
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.216 0.054   4.018
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.501 0.048 -10.393
##    pvalue ci.lower ci.upper
## 1   0.001    0.074    0.300
## 2   0.004    0.054    0.290
## 3   0.021    0.018    0.229
## 4   0.124   -0.025    0.204
## 5   0.000   -0.489   -0.275
## 6   0.003    0.063    0.306
## 7   0.000    0.223    0.449
## 8   0.000   -0.374   -0.165
## 9   0.001    0.078    0.301
## 10  0.000    0.182    0.427
## 11  0.000   -0.446   -0.251
## 12  0.000    0.095    0.338
## 13  0.000    0.176    0.527
## 14  0.029    0.014    0.255
## 15  0.280   -0.063    0.219
## 16  0.015    0.029    0.271
## 17  0.000    0.097    0.332
## 18  0.007    0.043    0.267
## 19  0.255   -0.143    0.038
## 20  0.497   -0.070    0.144
## 21  0.370   -0.143    0.053
## 22  0.000    0.525    0.715
## 23  0.000    0.676    0.856
## 24  0.000    0.512    0.710
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.004    0.024    0.131
## 30  0.000    0.063    0.189
## 31  0.000   -0.180   -0.058
## 32  0.000    0.092    0.311
## 33  0.000    0.111    0.321
## 34  0.000   -0.595   -0.406
parameterEstimates(fit1.eng, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1        engagementR  ~                       competence                b1
## 2        engagementR  ~                    pp.competence                b2
## 3        engagementR  ~                            as.5f                c1
## 4        engagementR  ~                        aps.stand                c2
## 5        engagementR  ~                      aps.discrep                c3
## 6      pp.competence  ~                            as.5f                a1
## 7      pp.competence  ~                        aps.stand               aa1
## 8      pp.competence  ~                      aps.discrep              aaa1
## 9         competence  ~                    pp.competence               d21
## 10        competence  ~                        aps.stand               aa2
## 11        competence  ~                      aps.discrep              aaa2
## 12        competence  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19        competence  ~                           sample                  
## 20     pp.competence  ~                           sample                  
## 21       engagementR  ~                           sample                  
## 22       engagementR ~~                      engagementR                  
## 23     pp.competence ~~                    pp.competence                  
## 24        competence ~~                       competence                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.080 0.025  3.204  0.001    0.031    0.129
## 2   0.050 0.018  2.832  0.005    0.015    0.083
## 3   0.126 0.053  2.389  0.017    0.025    0.234
## 4   0.050 0.033  1.526  0.127   -0.012    0.117
## 5  -0.149 0.023 -6.599  0.000   -0.195   -0.107
## 6   0.654 0.207  3.164  0.002    0.255    1.061
## 7   0.653 0.116  5.611  0.000    0.431    0.886
## 8  -0.365 0.074 -4.963  0.000   -0.507   -0.221
## 9   0.128 0.039  3.267  0.001    0.051    0.207
## 10  0.399 0.076  5.250  0.000    0.241    0.539
## 11 -0.318 0.047 -6.843  0.000   -0.411   -0.226
## 12  0.517 0.140  3.688  0.000    0.238    0.791
## 13  0.190 0.069  2.777  0.005    0.088    0.366
## 14  0.034 0.017  2.032  0.042    0.004    0.070
## 15  0.060 0.060  1.010  0.312   -0.041    0.196
## 16  0.212 0.095  2.219  0.026    0.046    0.423
## 17  0.098 0.030  3.320  0.001    0.041    0.156
## 18  0.101 0.038  2.655  0.008    0.029    0.178
## 19 -0.148 0.131 -1.133  0.257   -0.410    0.108
## 20  0.156 0.229  0.678  0.498   -0.283    0.605
## 21 -0.054 0.060 -0.900  0.368   -0.173    0.068
## 22  0.192 0.015 12.762  0.000    0.168    0.226
## 23  2.846 0.293  9.721  0.000    2.350    3.507
## 24  1.030 0.082 12.585  0.000    0.897    1.220
## 25  0.297 0.054  5.509  0.000    0.217    0.443
## 26  0.986 0.121  8.128  0.000    0.784    1.276
## 27  2.024 0.134 15.158  0.000    1.778    2.305
## 28  0.212 0.011 20.132  0.000    0.190    0.231
## 29  0.082 0.028  2.925  0.003    0.035    0.148
## 30  0.076 0.021  3.671  0.000    0.039    0.121
## 31 -0.047 0.013 -3.727  0.000   -0.075   -0.025
## 32  0.209 0.052  4.016  0.000    0.107    0.309
## 33  0.127 0.032  3.896  0.000    0.065    0.192
## 34 -0.197 0.021 -9.272  0.000   -0.238   -0.156
#########################################################################################################

#Mediation model with passion as outcome controlling for perfectionistic standards and discrepancies

mmed1.p <- 

  '
passion ~ b1 * competence + b2 * pp.competence + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.competence ~ a1 * as.5f
pp.competence ~ aa1 * aps.stand
pp.competence ~ aaa1 * aps.discrep
competence ~ d21 * pp.competence
competence ~ aa2 * aps.stand
competence ~ aaa2 * aps.discrep
competence ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
competence ~ sample
pp.competence ~ sample
passion ~ sample
'

fit1.p <- sem(model = mmed1.p, data = pp)
summary(fit1.p, standardized = TRUE)
## lavaan 0.6-8 ended normally after 46 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   passion ~                                                             
##     comptnc   (b1)    0.086    0.039    2.238    0.025    0.086    0.139
##     pp.cmpt   (b2)    0.073    0.024    3.091    0.002    0.073    0.175
##     as.5f     (c1)    0.202    0.081    2.495    0.013    0.202    0.136
##     aps.stn   (c2)    0.178    0.048    3.696    0.000    0.178    0.219
##     aps.dsc   (c3)   -0.107    0.032   -3.375    0.001   -0.107   -0.189
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.191    3.424    0.001    0.654    0.185
##     aps.stn  (aa1)    0.653    0.107    6.111    0.000    0.653    0.336
##     aps.dsc (aaa1)   -0.365    0.070   -5.248    0.000   -0.365   -0.270
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.035    3.691    0.000    0.128    0.190
##     aps.stn  (aa2)    0.399    0.068    5.855    0.000    0.399    0.305
##     aps.dsc (aaa2)   -0.318    0.044   -7.279    0.000   -0.318   -0.349
##     as.5f     (a2)    0.517    0.117    4.415    0.000    0.517    0.217
##     sample           -0.148    0.131   -1.131    0.258   -0.148   -0.053
##   pp.competence ~                                                       
##     sample            0.156    0.218    0.713    0.476    0.156    0.037
##   passion ~                                                             
##     sample            0.024    0.088    0.273    0.784    0.024    0.014
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .passion           0.464    0.038   12.288    0.000    0.464    0.711
##    .pp.competence     2.846    0.232   12.288    0.000    2.846    0.766
##    .competence        1.030    0.084   12.288    0.000    1.030    0.611
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.101    0.033    3.037    0.002    0.101    0.070
##     standardsndrct    0.092    0.028    3.301    0.001    0.092    0.111
##     discrepindirct   -0.058    0.017   -3.505    0.000   -0.058   -0.108
##     total1            0.303    0.080    3.799    0.000    0.303    0.206
##     total2            0.270    0.045    5.955    0.000    0.270    0.330
##     total3           -0.166    0.029   -5.707    0.000   -0.166   -0.297
fit1.p <- sem(
  model = mmed1.p,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit1.p, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 46 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               399.685
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2698.814
##   Loglikelihood unrestricted model (H1)      -2698.814
##                                                       
##   Akaike (AIC)                                5453.628
##   Bayesian (BIC)                              5557.520
##   Sample-size adjusted Bayesian (BIC)         5468.719
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   passion ~                                                             
##     comptnc   (b1)    0.086    0.040    2.174    0.030    0.012    0.170
##     pp.cmpt   (b2)    0.073    0.026    2.846    0.004    0.022    0.122
##     as.5f     (c1)    0.202    0.095    2.132    0.033    0.008    0.382
##     aps.stn   (c2)    0.178    0.054    3.284    0.001    0.076    0.287
##     aps.dsc   (c3)   -0.107    0.032   -3.401    0.001   -0.170   -0.046
##   pp.competence ~                                                       
##     as.5f     (a1)    0.654    0.205    3.196    0.001    0.226    1.031
##     aps.stn  (aa1)    0.653    0.118    5.528    0.000    0.428    0.891
##     aps.dsc (aaa1)   -0.365    0.073   -5.021    0.000   -0.509   -0.226
##   competence ~                                                          
##     pp.cmpt  (d21)    0.128    0.039    3.301    0.001    0.053    0.205
##     aps.stn  (aa2)    0.399    0.077    5.202    0.000    0.242    0.542
##     aps.dsc (aaa2)   -0.318    0.046   -6.909    0.000   -0.403   -0.224
##     as.5f     (a2)    0.517    0.143    3.619    0.000    0.227    0.788
##     sample           -0.148    0.129   -1.149    0.250   -0.393    0.111
##   pp.competence ~                                                       
##     sample            0.156    0.232    0.670    0.503   -0.290    0.624
##   passion ~                                                             
##     sample            0.024    0.086    0.279    0.780   -0.145    0.192
##    Std.lv  Std.all
##                   
##     0.086    0.139
##     0.073    0.175
##     0.202    0.136
##     0.178    0.219
##    -0.107   -0.189
##                   
##     0.654    0.185
##     0.653    0.336
##    -0.365   -0.270
##                   
##     0.128    0.190
##     0.399    0.305
##    -0.318   -0.349
##     0.517    0.217
##    -0.148   -0.053
##                   
##     0.156    0.037
##                   
##     0.024    0.014
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.068    2.815    0.005    0.079    0.341
##     sample            0.034    0.017    2.010    0.044    0.002    0.067
##     aps.discrep       0.060    0.059    1.015    0.310   -0.046    0.189
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.098    2.159    0.031    0.030    0.414
##     sample            0.098    0.029    3.408    0.001    0.044    0.155
##   aps.discrep ~~                                                        
##     sample            0.101    0.040    2.556    0.011    0.023    0.179
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .passion           0.464    0.047    9.909    0.000    0.361    0.547
##    .pp.competence     2.846    0.297    9.585    0.000    2.250    3.406
##    .competence        1.030    0.082   12.612    0.000    0.844    1.168
##     as.5f             0.297    0.053    5.639    0.000    0.210    0.414
##     aps.stand         0.986    0.121    8.149    0.000    0.769    1.239
##     aps.discrep       2.024    0.131   15.409    0.000    1.767    2.290
##     sample            0.212    0.010   20.524    0.000    0.190    0.231
##    Std.lv  Std.all
##     0.464    0.711
##     2.846    0.766
##     1.030    0.611
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     passion           0.289
##     pp.competence     0.234
##     competence        0.389
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.101    0.034    2.932    0.003    0.039    0.173
##     standardsndrct    0.092    0.029    3.213    0.001    0.041    0.155
##     discrepindirct   -0.058    0.017   -3.415    0.001   -0.094   -0.027
##     total1            0.303    0.099    3.068    0.002    0.097    0.483
##     total2            0.270    0.055    4.905    0.000    0.171    0.384
##     total3           -0.166    0.029   -5.699    0.000   -0.223   -0.110
##    Std.lv  Std.all
##     0.101    0.070
##     0.092    0.111
##    -0.058   -0.108
##     0.303    0.206
##     0.270    0.330
##    -0.166   -0.297
standardizedSolution(fit1.p, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1            passion  ~                       competence   0.139 0.062  2.243
## 2            passion  ~                    pp.competence   0.175 0.063  2.790
## 3            passion  ~                            as.5f   0.136 0.066  2.072
## 4            passion  ~                        aps.stand   0.219 0.063  3.478
## 5            passion  ~                      aps.discrep  -0.189 0.054 -3.506
## 6      pp.competence  ~                            as.5f   0.185 0.061  3.016
## 7      pp.competence  ~                        aps.stand   0.336 0.058  5.750
## 8      pp.competence  ~                      aps.discrep  -0.270 0.053 -5.108
## 9         competence  ~                    pp.competence   0.190 0.057  3.348
## 10        competence  ~                        aps.stand   0.305 0.064  4.800
## 11        competence  ~                      aps.discrep  -0.349 0.049 -7.088
## 12        competence  ~                            as.5f   0.217 0.063  3.462
## 13             as.5f ~~                        aps.stand   0.352 0.089  3.953
## 14             as.5f ~~                           sample   0.135 0.062  2.156
## 15             as.5f ~~                      aps.discrep   0.078 0.072  1.084
## 16         aps.stand ~~                      aps.discrep   0.150 0.064  2.354
## 17         aps.stand ~~                           sample   0.214 0.059  3.658
## 18       aps.discrep ~~                           sample   0.155 0.059  2.615
## 19        competence  ~                           sample  -0.053 0.046 -1.156
## 20     pp.competence  ~                           sample   0.037 0.055  0.670
## 21           passion  ~                           sample   0.014 0.049  0.279
## 22           passion ~~                          passion   0.711 0.053 13.517
## 23     pp.competence ~~                    pp.competence   0.766 0.045 16.875
## 24        competence ~~                       competence   0.611 0.050 12.136
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.070 0.024  2.946
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.111 0.030  3.716
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.108 0.029 -3.697
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.206 0.070  2.950
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.330 0.058  5.725
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.297 0.048 -6.147
##    pvalue ci.lower ci.upper
## 1   0.025    0.018    0.260
## 2   0.005    0.052    0.298
## 3   0.038    0.007    0.265
## 4   0.001    0.096    0.343
## 5   0.000   -0.295   -0.083
## 6   0.003    0.065    0.305
## 7   0.000    0.222    0.451
## 8   0.000   -0.373   -0.166
## 9   0.001    0.079    0.301
## 10  0.000    0.180    0.429
## 11  0.000   -0.445   -0.252
## 12  0.001    0.094    0.339
## 13  0.000    0.177    0.526
## 14  0.031    0.012    0.257
## 15  0.278   -0.063    0.219
## 16  0.019    0.025    0.275
## 17  0.000    0.100    0.329
## 18  0.009    0.039    0.271
## 19  0.248   -0.142    0.037
## 20  0.503   -0.071    0.146
## 21  0.781   -0.083    0.111
## 22  0.000    0.608    0.814
## 23  0.000    0.677    0.855
## 24  0.000    0.512    0.709
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.003    0.023    0.116
## 30  0.000    0.053    0.170
## 31  0.000   -0.165   -0.051
## 32  0.003    0.069    0.343
## 33  0.000    0.217    0.444
## 34  0.000   -0.391   -0.202
parameterEstimates(fit1.p, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1            passion  ~                       competence                b1
## 2            passion  ~                    pp.competence                b2
## 3            passion  ~                            as.5f                c1
## 4            passion  ~                        aps.stand                c2
## 5            passion  ~                      aps.discrep                c3
## 6      pp.competence  ~                            as.5f                a1
## 7      pp.competence  ~                        aps.stand               aa1
## 8      pp.competence  ~                      aps.discrep              aaa1
## 9         competence  ~                    pp.competence               d21
## 10        competence  ~                        aps.stand               aa2
## 11        competence  ~                      aps.discrep              aaa2
## 12        competence  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19        competence  ~                           sample                  
## 20     pp.competence  ~                           sample                  
## 21           passion  ~                           sample                  
## 22           passion ~~                          passion                  
## 23     pp.competence ~~                    pp.competence                  
## 24        competence ~~                       competence                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.086 0.040  2.174  0.030    0.010    0.167
## 2   0.073 0.026  2.846  0.004    0.024    0.124
## 3   0.202 0.095  2.132  0.033    0.018    0.390
## 4   0.178 0.054  3.284  0.001    0.075    0.286
## 5  -0.107 0.032 -3.401  0.001   -0.169   -0.045
## 6   0.654 0.205  3.196  0.001    0.237    1.045
## 7   0.653 0.118  5.528  0.000    0.431    0.895
## 8  -0.365 0.073 -5.021  0.000   -0.506   -0.223
## 9   0.128 0.039  3.301  0.001    0.053    0.205
## 10  0.399 0.077  5.202  0.000    0.240    0.541
## 11 -0.318 0.046 -6.909  0.000   -0.405   -0.226
## 12  0.517 0.143  3.619  0.000    0.240    0.800
## 13  0.190 0.068  2.815  0.005    0.084    0.349
## 14  0.034 0.017  2.010  0.044    0.001    0.067
## 15  0.060 0.059  1.015  0.310   -0.044    0.191
## 16  0.212 0.098  2.159  0.031    0.032    0.415
## 17  0.098 0.029  3.408  0.001    0.045    0.156
## 18  0.101 0.040  2.556  0.011    0.022    0.176
## 19 -0.148 0.129 -1.149  0.250   -0.395    0.110
## 20  0.156 0.232  0.670  0.503   -0.276    0.645
## 21  0.024 0.086  0.279  0.780   -0.142    0.194
## 22  0.464 0.047  9.909  0.000    0.388    0.574
## 23  2.846 0.297  9.585  0.000    2.344    3.523
## 24  1.030 0.082 12.612  0.000    0.900    1.223
## 25  0.297 0.053  5.639  0.000    0.214    0.419
## 26  0.986 0.121  8.149  0.000    0.778    1.248
## 27  2.024 0.131 15.409  0.000    1.783    2.304
## 28  0.212 0.010 20.524  0.000    0.187    0.229
## 29  0.101 0.034  2.932  0.003    0.043    0.182
## 30  0.092 0.029  3.213  0.001    0.043    0.156
## 31 -0.058 0.017 -3.415  0.001   -0.095   -0.028
## 32  0.303 0.099  3.068  0.002    0.103    0.488
## 33  0.270 0.055  4.905  0.000    0.171    0.386
## 34 -0.166 0.029 -5.699  0.000   -0.222   -0.109
##################################################################################################################
#H2: Achievement striving leads to satisfaction of relatedness needs at both the psychological and project level, 
# which in turn leads to well-being, even when controlling for perfectionistic standards and discrepancies 
##################################################################################################################

#Mediation model with positive mental health as outcome controlling for perfectionistic standards and discrepancies


mmed2.mhcR <- 

  '
mhcR ~ b1 * relatedness + b2 * pp.support + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.support ~ a1 * as.5f
pp.support ~ aa1 * aps.stand
pp.support ~ aaa1 * aps.discrep
relatedness ~ d21 * pp.support
relatedness ~ aa2 * aps.stand
relatedness ~ aaa2 * aps.discrep
relatedness ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
relatedness ~ sample
pp.support ~ sample
mhcR ~ sample
'

fit2.mhcR <- sem(model = mmed2.mhcR, data = pp)
summary(fit2.mhcR, standardized = TRUE)
## lavaan 0.6-8 ended normally after 57 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   mhcR ~                                                                
##     rltdnss   (b1)    0.253    0.029    8.764    0.000    0.253    0.405
##     pp.sppr   (b2)    0.058    0.019    3.008    0.003    0.058    0.134
##     as.5f     (c1)    0.271    0.084    3.243    0.001    0.271    0.146
##     aps.stn   (c2)    0.155    0.047    3.284    0.001    0.155    0.153
##     aps.dsc   (c3)   -0.216    0.033   -6.654    0.000   -0.216   -0.305
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.252    2.258    0.024    0.568    0.133
##     aps.stn  (aa1)    0.452    0.141    3.209    0.001    0.452    0.192
##     aps.dsc (aaa1)   -0.118    0.092   -1.282    0.200   -0.118   -0.072
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.088    0.002    0.117    0.168
##     aps.stn  (aa2)    0.198    0.094    2.108    0.035    0.198    0.121
##     aps.dsc (aaa2)   -0.413    0.060   -6.827    0.000   -0.413   -0.362
##     as.5f     (a2)    0.258    0.166    1.550    0.121    0.258    0.087
##     sample           -0.148    0.190   -0.777    0.437   -0.148   -0.042
##   pp.support ~                                                          
##     sample            0.537    0.289    1.861    0.063    0.537    0.106
##   mhcR ~                                                                
##     sample           -0.158    0.095   -1.652    0.098   -0.158   -0.072
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.191    0.033    5.764    0.000    0.191    0.352
##     sample            0.034    0.015    2.333    0.020    0.034    0.136
##     aps.discrep       0.060    0.045    1.345    0.179    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.082    2.608    0.009    0.215    0.152
##     sample            0.097    0.027    3.597    0.000    0.097    0.212
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.738    0.006    0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .mhcR              0.532    0.043   12.268    0.000    0.532    0.521
##    .pp.support        4.944    0.403   12.268    0.000    4.944    0.907
##    .relatedness       2.127    0.173   12.268    0.000    2.127    0.809
##     as.5f             0.298    0.024   12.268    0.000    0.298    1.000
##     aps.stand         0.988    0.081   12.268    0.000    0.988    1.000
##     aps.discrep       2.026    0.165   12.268    0.000    2.026    1.000
##     sample            0.211    0.017   12.268    0.000    0.211    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.162    0.068    2.387    0.017    0.162    0.068
##     standardsndrct    0.129    0.039    3.285    0.001    0.129    0.099
##     discrepindirct   -0.054    0.025   -2.134    0.033   -0.054   -0.079
##     total1            0.433    0.106    4.086    0.000    0.433    0.215
##     total2            0.284    0.060    4.766    0.000    0.284    0.251
##     total3           -0.271    0.040   -6.718    0.000   -0.271   -0.384
fit2.mhcR <- sem(
  model = mmed2.mhcR,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit2.mhcR, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 57 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               356.606
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2902.987
##   Loglikelihood unrestricted model (H1)      -2902.987
##                                                       
##   Akaike (AIC)                                5861.973
##   Bayesian (BIC)                              5965.772
##   Sample-size adjusted Bayesian (BIC)         5876.972
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   mhcR ~                                                                
##     rltdnss   (b1)    0.253    0.029    8.825    0.000    0.195    0.307
##     pp.sppr   (b2)    0.058    0.020    2.903    0.004    0.020    0.097
##     as.5f     (c1)    0.271    0.083    3.258    0.001    0.098    0.426
##     aps.stn   (c2)    0.155    0.051    3.043    0.002    0.048    0.250
##     aps.dsc   (c3)   -0.216    0.033   -6.602    0.000   -0.281   -0.153
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.239    2.382    0.017    0.073    0.999
##     aps.stn  (aa1)    0.452    0.141    3.212    0.001    0.159    0.719
##     aps.dsc (aaa1)   -0.118    0.092   -1.279    0.201   -0.299    0.058
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.104    0.002    0.044    0.192
##     aps.stn  (aa2)    0.198    0.095    2.094    0.036    0.004    0.373
##     aps.dsc (aaa2)   -0.413    0.067   -6.142    0.000   -0.543   -0.281
##     as.5f     (a2)    0.258    0.199    1.299    0.194   -0.174    0.598
##     sample           -0.148    0.195   -0.759    0.448   -0.530    0.241
##   pp.support ~                                                          
##     sample            0.537    0.292    1.839    0.066   -0.063    1.112
##   mhcR ~                                                                
##     sample           -0.158    0.096   -1.647    0.099   -0.349    0.028
##    Std.lv  Std.all
##                   
##     0.253    0.405
##     0.058    0.134
##     0.271    0.146
##     0.155    0.153
##    -0.216   -0.305
##                   
##     0.568    0.133
##     0.452    0.192
##    -0.118   -0.072
##                   
##     0.117    0.168
##     0.198    0.121
##    -0.413   -0.362
##     0.258    0.087
##    -0.148   -0.042
##                   
##     0.537    0.106
##                   
##    -0.158   -0.072
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.191    0.068    2.804    0.005    0.081    0.342
##     sample            0.034    0.017    2.053    0.040    0.003    0.068
##     aps.discrep       0.060    0.060    1.010    0.313   -0.052    0.180
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.096    2.248    0.025    0.031    0.405
##     sample            0.097    0.029    3.362    0.001    0.043    0.156
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.726    0.006    0.029    0.180
##    Std.lv  Std.all
##                   
##     0.191    0.352
##     0.034    0.136
##     0.060    0.078
##                   
##     0.215    0.152
##     0.097    0.212
##                   
##     0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .mhcR              0.532    0.042   12.579    0.000    0.438    0.602
##    .pp.support        4.944    0.381   12.976    0.000    4.139    5.642
##    .relatedness       2.127    0.160   13.259    0.000    1.781    2.398
##     as.5f             0.298    0.053    5.580    0.000    0.211    0.417
##     aps.stand         0.988    0.123    8.036    0.000    0.762    1.244
##     aps.discrep       2.026    0.131   15.492    0.000    1.762    2.280
##     sample            0.211    0.010   20.182    0.000    0.189    0.228
##    Std.lv  Std.all
##     0.532    0.521
##     4.944    0.907
##     2.127    0.809
##     0.298    1.000
##     0.988    1.000
##     2.026    1.000
##     0.211    1.000
## 
## R-Square:
##                    Estimate
##     mhcR              0.479
##     pp.support        0.093
##     relatedness       0.191
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.162    0.067    2.425    0.015    0.026    0.287
##     standardsndrct    0.129    0.038    3.402    0.001    0.052    0.202
##     discrepindirct   -0.054    0.026   -2.065    0.039   -0.107   -0.004
##     total1            0.433    0.114    3.791    0.000    0.190    0.642
##     total2            0.284    0.063    4.490    0.000    0.150    0.398
##     total3           -0.271    0.041   -6.634    0.000   -0.351   -0.190
##    Std.lv  Std.all
##     0.162    0.068
##     0.129    0.099
##    -0.054   -0.079
##     0.433    0.215
##     0.284    0.251
##    -0.271   -0.384
standardizedSolution(fit2.mhcR, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1               mhcR  ~                      relatedness   0.405 0.043  9.326
## 2               mhcR  ~                       pp.support   0.134 0.044  3.002
## 3               mhcR  ~                            as.5f   0.146 0.050  2.931
## 4               mhcR  ~                        aps.stand   0.153 0.052  2.937
## 5               mhcR  ~                      aps.discrep  -0.305 0.046 -6.611
## 6         pp.support  ~                            as.5f   0.133 0.059  2.265
## 7         pp.support  ~                        aps.stand   0.192 0.061  3.144
## 8         pp.support  ~                      aps.discrep  -0.072 0.056 -1.277
## 9        relatedness  ~                       pp.support   0.168 0.053  3.151
## 10       relatedness  ~                        aps.stand   0.121 0.059  2.052
## 11       relatedness  ~                      aps.discrep  -0.362 0.057 -6.386
## 12       relatedness  ~                            as.5f   0.087 0.070  1.236
## 13             as.5f ~~                        aps.stand   0.352 0.089  3.945
## 14             as.5f ~~                           sample   0.136 0.062  2.199
## 15             as.5f ~~                      aps.discrep   0.078 0.072  1.077
## 16         aps.stand ~~                      aps.discrep   0.152 0.062  2.455
## 17         aps.stand ~~                           sample   0.212 0.059  3.614
## 18       aps.discrep ~~                           sample   0.160 0.057  2.791
## 19       relatedness  ~                           sample  -0.042 0.055 -0.758
## 20        pp.support  ~                           sample   0.106 0.057  1.839
## 21              mhcR  ~                           sample  -0.072 0.044 -1.642
## 22              mhcR ~~                             mhcR   0.521 0.044 11.845
## 23        pp.support ~~                       pp.support   0.907 0.040 22.584
## 24       relatedness ~~                      relatedness   0.809 0.044 18.314
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.068 0.030  2.294
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.099 0.027  3.585
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.079 0.031 -2.564
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.215 0.065  3.287
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.251 0.061  4.129
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.384 0.053 -7.211
##    pvalue ci.lower ci.upper
## 1   0.000    0.320    0.491
## 2   0.003    0.046    0.221
## 3   0.003    0.048    0.244
## 4   0.003    0.051    0.255
## 5   0.000   -0.395   -0.214
## 6   0.023    0.018    0.248
## 7   0.002    0.072    0.312
## 8   0.201   -0.182    0.038
## 9   0.002    0.064    0.273
## 10  0.040    0.005    0.237
## 11  0.000   -0.474   -0.251
## 12  0.217   -0.051    0.224
## 13  0.000    0.177    0.527
## 14  0.028    0.015    0.257
## 15  0.282   -0.064    0.219
## 16  0.014    0.031    0.273
## 17  0.000    0.097    0.327
## 18  0.005    0.048    0.272
## 19  0.448   -0.150    0.066
## 20  0.066   -0.007    0.218
## 21  0.101   -0.157    0.014
## 22  0.000    0.435    0.608
## 23  0.000    0.828    0.985
## 24  0.000    0.723    0.896
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.022    0.010    0.127
## 30  0.000    0.045    0.152
## 31  0.010   -0.140   -0.019
## 32  0.001    0.087    0.343
## 33  0.000    0.132    0.371
## 34  0.000   -0.488   -0.279
parameterEstimates(fit2.mhcR, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1               mhcR  ~                      relatedness                b1
## 2               mhcR  ~                       pp.support                b2
## 3               mhcR  ~                            as.5f                c1
## 4               mhcR  ~                        aps.stand                c2
## 5               mhcR  ~                      aps.discrep                c3
## 6         pp.support  ~                            as.5f                a1
## 7         pp.support  ~                        aps.stand               aa1
## 8         pp.support  ~                      aps.discrep              aaa1
## 9        relatedness  ~                       pp.support               d21
## 10       relatedness  ~                        aps.stand               aa2
## 11       relatedness  ~                      aps.discrep              aaa2
## 12       relatedness  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19       relatedness  ~                           sample                  
## 20        pp.support  ~                           sample                  
## 21              mhcR  ~                           sample                  
## 22              mhcR ~~                             mhcR                  
## 23        pp.support ~~                       pp.support                  
## 24       relatedness ~~                      relatedness                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.253 0.029  8.825  0.000    0.196    0.309
## 2   0.058 0.020  2.903  0.004    0.019    0.096
## 3   0.271 0.083  3.258  0.001    0.101    0.428
## 4   0.155 0.051  3.043  0.002    0.056    0.254
## 5  -0.216 0.033 -6.602  0.000   -0.279   -0.151
## 6   0.568 0.239  2.382  0.017    0.077    1.003
## 7   0.452 0.141  3.212  0.001    0.174    0.728
## 8  -0.118 0.092 -1.279  0.201   -0.293    0.065
## 9   0.117 0.038  3.104  0.002    0.045    0.194
## 10  0.198 0.095  2.094  0.036   -0.001    0.370
## 11 -0.413 0.067 -6.142  0.000   -0.541   -0.278
## 12  0.258 0.199  1.299  0.194   -0.149    0.620
## 13  0.191 0.068  2.804  0.005    0.093    0.370
## 14  0.034 0.017  2.053  0.040    0.003    0.069
## 15  0.060 0.060  1.010  0.313   -0.043    0.190
## 16  0.215 0.096  2.248  0.025    0.042    0.417
## 17  0.097 0.029  3.362  0.001    0.045    0.158
## 18  0.104 0.038  2.726  0.006    0.030    0.180
## 19 -0.148 0.195 -0.759  0.448   -0.536    0.234
## 20  0.537 0.292  1.839  0.066   -0.047    1.123
## 21 -0.158 0.096 -1.647  0.099   -0.356    0.020
## 22  0.532 0.042 12.579  0.000    0.463    0.637
## 23  4.944 0.381 12.976  0.000    4.291    5.799
## 24  2.127 0.160 13.259  0.000    1.867    2.525
## 25  0.298 0.053  5.580  0.000    0.219    0.440
## 26  0.988 0.123  8.036  0.000    0.777    1.268
## 27  2.026 0.131 15.492  0.000    1.775    2.300
## 28  0.211 0.010 20.182  0.000    0.189    0.229
## 29  0.162 0.067  2.425  0.015    0.034    0.295
## 30  0.129 0.038  3.402  0.001    0.060    0.208
## 31 -0.054 0.026 -2.065  0.039   -0.106   -0.003
## 32  0.433 0.114  3.791  0.000    0.198    0.649
## 33  0.284 0.063  4.490  0.000    0.158    0.404
## 34 -0.271 0.041 -6.634  0.000   -0.348   -0.187
#########################################################################################################

#Mediation model with zest as outcome controlling for perfectionistic standards and discrepancies

mmed2.zest <- 

  '
zestR ~ b1 * relatedness + b2 * pp.support + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.support ~ a1 * as.5f
pp.support ~ aa1 * aps.stand
pp.support ~ aaa1 * aps.discrep
relatedness ~ d21 * pp.support
relatedness ~ aa2 * aps.stand
relatedness ~ aaa2 * aps.discrep
relatedness ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
relatedness ~ sample
pp.support~ sample
zestR ~ sample
'

fit2.zest <- sem(model = mmed2.zest, data = pp)
summary(fit2.zest, standardized = TRUE)
## lavaan 0.6-8 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   zestR ~                                                               
##     rltdnss   (b1)    0.206    0.038    5.487    0.000    0.206    0.275
##     pp.sppr   (b2)    0.045    0.025    1.812    0.070    0.045    0.087
##     as.5f     (c1)    0.240    0.109    2.202    0.028    0.240    0.108
##     aps.stn   (c2)    0.107    0.062    1.731    0.083    0.107    0.087
##     aps.dsc   (c3)   -0.364    0.042   -8.611    0.000   -0.364   -0.427
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.252    2.258    0.024    0.568    0.133
##     aps.stn  (aa1)    0.452    0.141    3.209    0.001    0.452    0.192
##     aps.dsc (aaa1)   -0.118    0.092   -1.282    0.200   -0.118   -0.072
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.088    0.002    0.117    0.168
##     aps.stn  (aa2)    0.198    0.094    2.108    0.035    0.198    0.121
##     aps.dsc (aaa2)   -0.413    0.060   -6.827    0.000   -0.413   -0.362
##     as.5f     (a2)    0.258    0.166    1.550    0.121    0.258    0.087
##     sample           -0.148    0.190   -0.777    0.437   -0.148   -0.042
##   pp.support ~                                                          
##     sample            0.537    0.289    1.861    0.063    0.537    0.106
##   zestR ~                                                               
##     sample           -0.038    0.124   -0.304    0.761   -0.038   -0.014
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.191    0.033    5.764    0.000    0.191    0.352
##     sample            0.034    0.015    2.333    0.020    0.034    0.136
##     aps.discrep       0.060    0.045    1.345    0.179    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.082    2.608    0.009    0.215    0.152
##     sample            0.097    0.027    3.597    0.000    0.097    0.212
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.738    0.006    0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .zestR             0.903    0.074   12.268    0.000    0.903    0.612
##    .pp.support        4.944    0.403   12.268    0.000    4.944    0.907
##    .relatedness       2.127    0.173   12.268    0.000    2.127    0.809
##     as.5f             0.298    0.024   12.268    0.000    0.298    1.000
##     aps.stand         0.988    0.081   12.268    0.000    0.988    1.000
##     aps.discrep       2.026    0.165   12.268    0.000    2.026    1.000
##     sample            0.211    0.017   12.268    0.000    0.211    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.132    0.058    2.279    0.023    0.132    0.046
##     standardsndrct    0.104    0.035    3.025    0.002    0.104    0.066
##     discrepindirct   -0.044    0.022   -1.947    0.052   -0.044   -0.052
##     total1            0.371    0.121    3.076    0.002    0.371    0.154
##     total2            0.211    0.068    3.108    0.002    0.211    0.154
##     total3           -0.408    0.046   -8.794    0.000   -0.408   -0.479
fit2.zest <- sem(
  model = mmed2.zest,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit2.zest, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 56 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               308.591
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2982.484
##   Loglikelihood unrestricted model (H1)      -2982.484
##                                                       
##   Akaike (AIC)                                6020.969
##   Bayesian (BIC)                              6124.768
##   Sample-size adjusted Bayesian (BIC)         6035.968
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   zestR ~                                                               
##     rltdnss   (b1)    0.206    0.041    4.975    0.000    0.124    0.289
##     pp.sppr   (b2)    0.045    0.028    1.605    0.108   -0.010    0.101
##     as.5f     (c1)    0.240    0.100    2.398    0.016    0.045    0.437
##     aps.stn   (c2)    0.107    0.065    1.638    0.101   -0.024    0.235
##     aps.dsc   (c3)   -0.364    0.045   -8.061    0.000   -0.452   -0.274
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.236    2.405    0.016    0.064    1.004
##     aps.stn  (aa1)    0.452    0.140    3.235    0.001    0.178    0.730
##     aps.dsc (aaa1)   -0.118    0.092   -1.281    0.200   -0.300    0.063
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.084    0.002    0.044    0.192
##     aps.stn  (aa2)    0.198    0.095    2.092    0.036    0.001    0.377
##     aps.dsc (aaa2)   -0.413    0.066   -6.237    0.000   -0.543   -0.284
##     as.5f     (a2)    0.258    0.206    1.253    0.210   -0.186    0.618
##     sample           -0.148    0.194   -0.761    0.447   -0.525    0.233
##   pp.support ~                                                          
##     sample            0.537    0.296    1.812    0.070   -0.050    1.126
##   zestR ~                                                               
##     sample           -0.038    0.131   -0.289    0.772   -0.293    0.214
##    Std.lv  Std.all
##                   
##     0.206    0.275
##     0.045    0.087
##     0.240    0.108
##     0.107    0.087
##    -0.364   -0.427
##                   
##     0.568    0.133
##     0.452    0.192
##    -0.118   -0.072
##                   
##     0.117    0.168
##     0.198    0.121
##    -0.413   -0.362
##     0.258    0.087
##    -0.148   -0.042
##                   
##     0.537    0.106
##                   
##    -0.038   -0.014
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.191    0.070    2.733    0.006    0.078    0.349
##     sample            0.034    0.017    2.033    0.042    0.003    0.068
##     aps.discrep       0.060    0.061    0.993    0.321   -0.047    0.191
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.098    2.193    0.028    0.035    0.416
##     sample            0.097    0.029    3.342    0.001    0.042    0.157
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.721    0.007    0.029    0.180
##    Std.lv  Std.all
##                   
##     0.191    0.352
##     0.034    0.136
##     0.060    0.078
##                   
##     0.215    0.152
##     0.097    0.212
##                   
##     0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .zestR             0.903    0.077   11.795    0.000    0.734    1.031
##    .pp.support        4.944    0.376   13.157    0.000    4.127    5.613
##    .relatedness       2.127    0.161   13.232    0.000    1.771    2.403
##     as.5f             0.298    0.054    5.517    0.000    0.212    0.420
##     aps.stand         0.988    0.123    8.050    0.000    0.766    1.244
##     aps.discrep       2.026    0.134   15.164    0.000    1.767    2.291
##     sample            0.211    0.010   20.286    0.000    0.189    0.229
##    Std.lv  Std.all
##     0.903    0.612
##     4.944    0.907
##     2.127    0.809
##     0.298    1.000
##     0.988    1.000
##     2.026    1.000
##     0.211    1.000
## 
## R-Square:
##                    Estimate
##     zestR             0.388
##     pp.support        0.093
##     relatedness       0.191
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.132    0.058    2.259    0.024    0.018    0.250
##     standardsndrct    0.104    0.035    2.978    0.003    0.043    0.181
##     discrepindirct   -0.044    0.024   -1.836    0.066   -0.090    0.004
##     total1            0.371    0.112    3.308    0.001    0.147    0.588
##     total2            0.211    0.072    2.944    0.003    0.068    0.349
##     total3           -0.408    0.050   -8.144    0.000   -0.502   -0.307
##    Std.lv  Std.all
##     0.132    0.046
##     0.104    0.066
##    -0.044   -0.052
##     0.371    0.154
##     0.211    0.154
##    -0.408   -0.479
standardizedSolution(fit2.zest, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1              zestR  ~                      relatedness   0.275 0.055  5.018
## 2              zestR  ~                       pp.support   0.087 0.054  1.619
## 3              zestR  ~                            as.5f   0.108 0.045  2.385
## 4              zestR  ~                        aps.stand   0.087 0.054  1.620
## 5              zestR  ~                      aps.discrep  -0.427 0.049 -8.663
## 6         pp.support  ~                            as.5f   0.133 0.058  2.281
## 7         pp.support  ~                        aps.stand   0.192 0.061  3.172
## 8         pp.support  ~                      aps.discrep  -0.072 0.056 -1.277
## 9        relatedness  ~                       pp.support   0.168 0.054  3.119
## 10       relatedness  ~                        aps.stand   0.121 0.059  2.045
## 11       relatedness  ~                      aps.discrep  -0.362 0.056 -6.480
## 12       relatedness  ~                            as.5f   0.087 0.073  1.194
## 13             as.5f ~~                        aps.stand   0.352 0.091  3.850
## 14             as.5f ~~                           sample   0.136 0.062  2.188
## 15             as.5f ~~                      aps.discrep   0.078 0.073  1.063
## 16         aps.stand ~~                      aps.discrep   0.152 0.063  2.399
## 17         aps.stand ~~                           sample   0.212 0.059  3.594
## 18       aps.discrep ~~                           sample   0.160 0.057  2.786
## 19       relatedness  ~                           sample  -0.042 0.055 -0.759
## 20        pp.support  ~                           sample   0.106 0.058  1.811
## 21             zestR  ~                           sample  -0.014 0.049 -0.289
## 22             zestR ~~                            zestR   0.612 0.051 12.097
## 23        pp.support ~~                       pp.support   0.907 0.041 22.353
## 24       relatedness ~~                      relatedness   0.809 0.044 18.306
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.046 0.021  2.161
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.066 0.021  3.109
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.052 0.026 -1.991
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.154 0.050  3.079
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.154 0.057  2.699
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.479 0.054 -8.855
##    pvalue ci.lower ci.upper
## 1   0.000    0.168    0.382
## 2   0.106   -0.018    0.193
## 3   0.017    0.019    0.196
## 4   0.105   -0.018    0.193
## 5   0.000   -0.524   -0.330
## 6   0.023    0.019    0.247
## 7   0.002    0.074    0.311
## 8   0.202   -0.182    0.038
## 9   0.002    0.062    0.274
## 10  0.041    0.005    0.238
## 11  0.000   -0.472   -0.253
## 12  0.232   -0.056    0.229
## 13  0.000    0.173    0.532
## 14  0.029    0.014    0.257
## 15  0.288   -0.066    0.221
## 16  0.016    0.028    0.276
## 17  0.000    0.096    0.327
## 18  0.005    0.047    0.272
## 19  0.448   -0.150    0.066
## 20  0.070   -0.009    0.220
## 21  0.773   -0.111    0.083
## 22  0.000    0.512    0.711
## 23  0.000    0.827    0.986
## 24  0.000    0.723    0.896
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.031    0.004    0.088
## 30  0.002    0.024    0.108
## 31  0.047   -0.104   -0.001
## 32  0.002    0.056    0.251
## 33  0.007    0.042    0.265
## 34  0.000   -0.585   -0.373
parameterEstimates(fit2.zest, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1              zestR  ~                      relatedness                b1
## 2              zestR  ~                       pp.support                b2
## 3              zestR  ~                            as.5f                c1
## 4              zestR  ~                        aps.stand                c2
## 5              zestR  ~                      aps.discrep                c3
## 6         pp.support  ~                            as.5f                a1
## 7         pp.support  ~                        aps.stand               aa1
## 8         pp.support  ~                      aps.discrep              aaa1
## 9        relatedness  ~                       pp.support               d21
## 10       relatedness  ~                        aps.stand               aa2
## 11       relatedness  ~                      aps.discrep              aaa2
## 12       relatedness  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19       relatedness  ~                           sample                  
## 20        pp.support  ~                           sample                  
## 21             zestR  ~                           sample                  
## 22             zestR ~~                            zestR                  
## 23        pp.support ~~                       pp.support                  
## 24       relatedness ~~                      relatedness                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.206 0.041  4.975  0.000    0.124    0.289
## 2   0.045 0.028  1.605  0.108   -0.009    0.102
## 3   0.240 0.100  2.398  0.016    0.045    0.437
## 4   0.107 0.065  1.638  0.101   -0.025    0.233
## 5  -0.364 0.045 -8.061  0.000   -0.451   -0.274
## 6   0.568 0.236  2.405  0.016    0.047    0.991
## 7   0.452 0.140  3.235  0.001    0.187    0.734
## 8  -0.118 0.092 -1.281  0.200   -0.296    0.068
## 9   0.117 0.038  3.084  0.002    0.040    0.189
## 10  0.198 0.095  2.092  0.036    0.004    0.381
## 11 -0.413 0.066 -6.237  0.000   -0.544   -0.285
## 12  0.258 0.206  1.253  0.210   -0.176    0.632
## 13  0.191 0.070  2.733  0.006    0.087    0.375
## 14  0.034 0.017  2.033  0.042    0.003    0.068
## 15  0.060 0.061  0.993  0.321   -0.042    0.197
## 16  0.215 0.098  2.193  0.028    0.038    0.421
## 17  0.097 0.029  3.342  0.001    0.043    0.157
## 18  0.104 0.038  2.721  0.007    0.030    0.181
## 19 -0.148 0.194 -0.761  0.447   -0.525    0.234
## 20  0.537 0.296  1.812  0.070   -0.048    1.128
## 21 -0.038 0.131 -0.289  0.772   -0.282    0.232
## 22  0.903 0.077 11.795  0.000    0.778    1.093
## 23  4.944 0.376 13.157  0.000    4.309    5.785
## 24  2.127 0.161 13.232  0.000    1.864    2.509
## 25  0.298 0.054  5.517  0.000    0.218    0.436
## 26  0.988 0.123  8.050  0.000    0.779    1.263
## 27  2.026 0.134 15.164  0.000    1.780    2.309
## 28  0.211 0.010 20.286  0.000    0.189    0.228
## 29  0.132 0.058  2.259  0.024    0.025    0.259
## 30  0.104 0.035  2.978  0.003    0.048    0.190
## 31 -0.044 0.024 -1.836  0.066   -0.092    0.003
## 32  0.371 0.112  3.308  0.001    0.141    0.583
## 33  0.211 0.072  2.944  0.003    0.068    0.349
## 34 -0.408 0.050 -8.144  0.000   -0.502   -0.306
#########################################################################################################

#Mediation model with engagement as outcome controlling for perfectionistic standards and discrepancies


mmed2.eng <- 

  '
engagementR ~ b1 * relatedness + b2 * pp.support + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.support ~ a1 * as.5f
pp.support ~ aa1 * aps.stand
pp.support ~ aaa1 * aps.discrep
relatedness ~ d21 * pp.support
relatedness ~ aa2 * aps.stand
relatedness ~ aaa2 * aps.discrep
relatedness ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
relatedness ~ sample
pp.support ~ sample
engagementR ~ sample
'

fit2.eng <- sem(model = mmed2.eng, data = pp)
summary(fit2.eng, standardized = TRUE)
## lavaan 0.6-8 ended normally after 60 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   engagementR ~                                                         
##     rltdnss   (b1)    0.087    0.017    5.085    0.000    0.087    0.254
##     pp.sppr   (b2)    0.022    0.011    1.884    0.060    0.022    0.090
##     as.5f     (c1)    0.166    0.050    3.335    0.001    0.166    0.162
##     aps.stn   (c2)    0.090    0.028    3.204    0.001    0.090    0.161
##     aps.dsc   (c3)   -0.158    0.019   -8.148    0.000   -0.158   -0.402
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.252    2.258    0.024    0.568    0.133
##     aps.stn  (aa1)    0.452    0.141    3.209    0.001    0.452    0.192
##     aps.dsc (aaa1)   -0.118    0.092   -1.282    0.200   -0.118   -0.072
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.088    0.002    0.117    0.168
##     aps.stn  (aa2)    0.198    0.094    2.108    0.035    0.198    0.121
##     aps.dsc (aaa2)   -0.413    0.060   -6.827    0.000   -0.413   -0.362
##     as.5f     (a2)    0.258    0.166    1.550    0.121    0.258    0.087
##     sample           -0.148    0.190   -0.777    0.437   -0.148   -0.042
##   pp.support ~                                                          
##     sample            0.537    0.289    1.861    0.063    0.537    0.106
##   engagementR ~                                                         
##     sample           -0.059    0.057   -1.033    0.301   -0.059   -0.048
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.191    0.033    5.764    0.000    0.191    0.352
##     sample            0.034    0.015    2.333    0.020    0.034    0.136
##     aps.discrep       0.060    0.045    1.345    0.179    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.082    2.608    0.009    0.215    0.152
##     sample            0.097    0.027    3.597    0.000    0.097    0.212
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.738    0.006    0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .engagementR       0.188    0.015   12.268    0.000    0.188    0.606
##    .pp.support        4.944    0.403   12.268    0.000    4.944    0.907
##    .relatedness       2.127    0.173   12.268    0.000    2.127    0.809
##     as.5f             0.298    0.024   12.268    0.000    0.298    1.000
##     aps.stand         0.988    0.081   12.268    0.000    0.988    1.000
##     aps.discrep       2.026    0.165   12.268    0.000    2.026    1.000
##     sample            0.211    0.017   12.268    0.000    0.211    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.057    0.025    2.274    0.023    0.057    0.044
##     standardsndrct    0.045    0.015    2.993    0.003    0.045    0.063
##     discrepindirct   -0.019    0.010   -2.006    0.045   -0.019   -0.052
##     total1            0.222    0.054    4.084    0.000    0.222    0.206
##     total2            0.135    0.031    4.406    0.000    0.135    0.224
##     total3           -0.177    0.021   -8.451    0.000   -0.177   -0.454
fit2.eng <- sem(
  model = mmed2.eng,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit2.eng, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 60 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               311.373
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2746.629
##   Loglikelihood unrestricted model (H1)      -2746.629
##                                                       
##   Akaike (AIC)                                5549.257
##   Bayesian (BIC)                              5653.056
##   Sample-size adjusted Bayesian (BIC)         5564.256
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   engagementR ~                                                         
##     rltdnss   (b1)    0.087    0.019    4.684    0.000    0.051    0.123
##     pp.sppr   (b2)    0.022    0.012    1.734    0.083   -0.003    0.046
##     as.5f     (c1)    0.166    0.049    3.383    0.001    0.068    0.263
##     aps.stn   (c2)    0.090    0.031    2.874    0.004    0.030    0.152
##     aps.dsc   (c3)   -0.158    0.021   -7.681    0.000   -0.195   -0.115
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.238    2.389    0.017    0.053    0.998
##     aps.stn  (aa1)    0.452    0.142    3.191    0.001    0.170    0.731
##     aps.dsc (aaa1)   -0.118    0.092   -1.279    0.201   -0.296    0.060
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.037    3.147    0.002    0.047    0.191
##     aps.stn  (aa2)    0.198    0.094    2.100    0.036    0.008    0.381
##     aps.dsc (aaa2)   -0.413    0.067   -6.201    0.000   -0.543   -0.282
##     as.5f     (a2)    0.258    0.201    1.285    0.199   -0.187    0.603
##     sample           -0.148    0.190   -0.778    0.437   -0.510    0.232
##   pp.support ~                                                          
##     sample            0.537    0.294    1.826    0.068   -0.048    1.131
##   engagementR ~                                                         
##     sample           -0.059    0.062   -0.942    0.346   -0.185    0.057
##    Std.lv  Std.all
##                   
##     0.087    0.254
##     0.022    0.090
##     0.166    0.162
##     0.090    0.161
##    -0.158   -0.402
##                   
##     0.568    0.133
##     0.452    0.192
##    -0.118   -0.072
##                   
##     0.117    0.168
##     0.198    0.121
##    -0.413   -0.362
##     0.258    0.087
##    -0.148   -0.042
##                   
##     0.537    0.106
##                   
##    -0.059   -0.048
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.191    0.067    2.838    0.005    0.082    0.341
##     sample            0.034    0.017    2.019    0.044    0.001    0.067
##     aps.discrep       0.060    0.060    0.999    0.318   -0.052    0.186
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.097    2.212    0.027    0.026    0.411
##     sample            0.097    0.029    3.387    0.001    0.040    0.153
##   aps.discrep ~~                                                        
##     sample            0.104    0.039    2.705    0.007    0.030    0.180
##    Std.lv  Std.all
##                   
##     0.191    0.352
##     0.034    0.136
##     0.060    0.078
##                   
##     0.215    0.152
##     0.097    0.212
##                   
##     0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .engagementR       0.188    0.016   12.128    0.000    0.155    0.215
##    .pp.support        4.944    0.378   13.095    0.000    4.124    5.601
##    .relatedness       2.127    0.158   13.481    0.000    1.782    2.394
##     as.5f             0.298    0.053    5.652    0.000    0.213    0.413
##     aps.stand         0.988    0.122    8.128    0.000    0.767    1.248
##     aps.discrep       2.026    0.130   15.639    0.000    1.764    2.280
##     sample            0.211    0.010   20.346    0.000    0.189    0.230
##    Std.lv  Std.all
##     0.188    0.606
##     4.944    0.907
##     2.127    0.809
##     0.298    1.000
##     0.988    1.000
##     2.026    1.000
##     0.211    1.000
## 
## R-Square:
##                    Estimate
##     engagementR       0.394
##     pp.support        0.093
##     relatedness       0.191
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.057    0.025    2.255    0.024    0.008    0.107
##     standardsndrct    0.045    0.015    2.900    0.004    0.017    0.078
##     discrepindirct   -0.019    0.010   -1.942    0.052   -0.040    0.000
##     total1            0.222    0.056    3.996    0.000    0.107    0.329
##     total2            0.135    0.034    3.929    0.000    0.071    0.206
##     total3           -0.177    0.022   -7.875    0.000   -0.219   -0.130
##    Std.lv  Std.all
##     0.057    0.044
##     0.045    0.063
##    -0.019   -0.052
##     0.222    0.206
##     0.135    0.224
##    -0.177   -0.454
standardizedSolution(fit2.eng, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1        engagementR  ~                      relatedness   0.254 0.054  4.705
## 2        engagementR  ~                       pp.support   0.090 0.052  1.732
## 3        engagementR  ~                            as.5f   0.162 0.050  3.232
## 4        engagementR  ~                        aps.stand   0.161 0.055  2.941
## 5        engagementR  ~                      aps.discrep  -0.402 0.050 -8.123
## 6         pp.support  ~                            as.5f   0.133 0.059  2.261
## 7         pp.support  ~                        aps.stand   0.192 0.061  3.133
## 8         pp.support  ~                      aps.discrep  -0.072 0.056 -1.277
## 9        relatedness  ~                       pp.support   0.168 0.053  3.191
## 10       relatedness  ~                        aps.stand   0.121 0.059  2.054
## 11       relatedness  ~                      aps.discrep  -0.362 0.056 -6.478
## 12       relatedness  ~                            as.5f   0.087 0.071  1.225
## 13             as.5f ~~                        aps.stand   0.352 0.088  3.989
## 14             as.5f ~~                           sample   0.136 0.063  2.163
## 15             as.5f ~~                      aps.discrep   0.078 0.073  1.066
## 16         aps.stand ~~                      aps.discrep   0.152 0.063  2.406
## 17         aps.stand ~~                           sample   0.212 0.059  3.621
## 18       aps.discrep ~~                           sample   0.160 0.058  2.765
## 19       relatedness  ~                           sample  -0.042 0.054 -0.777
## 20        pp.support  ~                           sample   0.106 0.058  1.826
## 21       engagementR  ~                           sample  -0.048 0.051 -0.940
## 22       engagementR ~~                      engagementR   0.606 0.049 12.282
## 23        pp.support ~~                       pp.support   0.907 0.039 23.051
## 24       relatedness ~~                      relatedness   0.809 0.044 18.557
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.044 0.020  2.147
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.063 0.020  3.084
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.052 0.024 -2.130
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.206 0.056  3.648
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.224 0.057  3.955
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.454 0.054 -8.426
##    pvalue ci.lower ci.upper
## 1   0.000    0.148    0.359
## 2   0.083   -0.012    0.192
## 3   0.001    0.064    0.261
## 4   0.003    0.054    0.268
## 5   0.000   -0.499   -0.305
## 6   0.024    0.018    0.248
## 7   0.002    0.072    0.313
## 8   0.202   -0.182    0.038
## 9   0.001    0.065    0.271
## 10  0.040    0.006    0.237
## 11  0.000   -0.472   -0.253
## 12  0.220   -0.052    0.226
## 13  0.000    0.179    0.525
## 14  0.031    0.013    0.259
## 15  0.287   -0.065    0.221
## 16  0.016    0.028    0.276
## 17  0.000    0.097    0.327
## 18  0.006    0.047    0.273
## 19  0.437   -0.148    0.064
## 20  0.068   -0.008    0.219
## 21  0.347   -0.149    0.052
## 22  0.000    0.509    0.703
## 23  0.000    0.830    0.984
## 24  0.000    0.724    0.895
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.032    0.004    0.083
## 30  0.002    0.023    0.102
## 31  0.033   -0.100   -0.004
## 32  0.000    0.095    0.316
## 33  0.000    0.113    0.334
## 34  0.000   -0.560   -0.348
parameterEstimates(fit2.eng, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1        engagementR  ~                      relatedness                b1
## 2        engagementR  ~                       pp.support                b2
## 3        engagementR  ~                            as.5f                c1
## 4        engagementR  ~                        aps.stand                c2
## 5        engagementR  ~                      aps.discrep                c3
## 6         pp.support  ~                            as.5f                a1
## 7         pp.support  ~                        aps.stand               aa1
## 8         pp.support  ~                      aps.discrep              aaa1
## 9        relatedness  ~                       pp.support               d21
## 10       relatedness  ~                        aps.stand               aa2
## 11       relatedness  ~                      aps.discrep              aaa2
## 12       relatedness  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19       relatedness  ~                           sample                  
## 20        pp.support  ~                           sample                  
## 21       engagementR  ~                           sample                  
## 22       engagementR ~~                      engagementR                  
## 23        pp.support ~~                       pp.support                  
## 24       relatedness ~~                      relatedness                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.087 0.019  4.684  0.000    0.050    0.122
## 2   0.022 0.012  1.734  0.083   -0.002    0.047
## 3   0.166 0.049  3.383  0.001    0.072    0.266
## 4   0.090 0.031  2.874  0.004    0.030    0.153
## 5  -0.158 0.021 -7.681  0.000   -0.196   -0.116
## 6   0.568 0.238  2.389  0.017    0.053    0.997
## 7   0.452 0.142  3.191  0.001    0.164    0.724
## 8  -0.118 0.092 -1.279  0.201   -0.292    0.065
## 9   0.117 0.037  3.147  0.002    0.046    0.190
## 10  0.198 0.094  2.100  0.036    0.008    0.380
## 11 -0.413 0.067 -6.201  0.000   -0.538   -0.277
## 12  0.258 0.201  1.285  0.199   -0.164    0.617
## 13  0.191 0.067  2.838  0.005    0.092    0.363
## 14  0.034 0.017  2.019  0.044    0.002    0.068
## 15  0.060 0.060  0.999  0.318   -0.046    0.195
## 16  0.215 0.097  2.212  0.027    0.036    0.418
## 17  0.097 0.029  3.387  0.001    0.042    0.155
## 18  0.104 0.039  2.705  0.007    0.031    0.180
## 19 -0.148 0.190 -0.778  0.437   -0.514    0.229
## 20  0.537 0.294  1.826  0.068   -0.049    1.130
## 21 -0.059 0.062 -0.942  0.346   -0.182    0.059
## 22  0.188 0.016 12.128  0.000    0.164    0.226
## 23  4.944 0.378 13.095  0.000    4.295    5.761
## 24  2.127 0.158 13.481  0.000    1.873    2.513
## 25  0.298 0.053  5.652  0.000    0.220    0.435
## 26  0.988 0.122  8.128  0.000    0.782    1.266
## 27  2.026 0.130 15.639  0.000    1.782    2.296
## 28  0.211 0.010 20.346  0.000    0.189    0.229
## 29  0.057 0.025  2.255  0.024    0.012    0.111
## 30  0.045 0.015  2.900  0.004    0.019    0.081
## 31 -0.019 0.010 -1.942  0.052   -0.040    0.000
## 32  0.222 0.056  3.996  0.000    0.111    0.334
## 33  0.135 0.034  3.929  0.000    0.072    0.207
## 34 -0.177 0.022 -7.875  0.000   -0.219   -0.130
#########################################################################################################

#Mediation model with passion as outcome controlling for perfectionistic standards and discrepancies


mmed2.p <- 

  '
passion ~ b1 * relatedness + b2 * pp.support + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.support ~ a1 * as.5f
pp.support ~ aa1 * aps.stand
pp.support ~ aaa1 * aps.discrep
relatedness ~ d21 * pp.support
relatedness ~ aa2 * aps.stand
relatedness ~ aaa2 * aps.discrep
relatedness ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
relatedness ~ sample
pp.support ~ sample
passion ~ sample
'

fit2.p <- sem(model = mmed2.p, data = pp)
summary(fit2.p, standardized = TRUE)
## lavaan 0.6-8 ended normally after 57 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   passion ~                                                             
##     rltdnss   (b1)    0.081    0.027    3.005    0.003    0.081    0.163
##     pp.sppr   (b2)    0.031    0.018    1.743    0.081    0.031    0.091
##     as.5f     (c1)    0.256    0.079    3.260    0.001    0.256    0.173
##     aps.stn   (c2)    0.234    0.044    5.272    0.000    0.234    0.288
##     aps.dsc   (c3)   -0.129    0.031   -4.221    0.000   -0.129   -0.227
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.252    2.258    0.024    0.568    0.133
##     aps.stn  (aa1)    0.452    0.141    3.209    0.001    0.452    0.192
##     aps.dsc (aaa1)   -0.118    0.092   -1.282    0.200   -0.118   -0.072
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.088    0.002    0.117    0.168
##     aps.stn  (aa2)    0.198    0.094    2.108    0.035    0.198    0.121
##     aps.dsc (aaa2)   -0.413    0.060   -6.827    0.000   -0.413   -0.362
##     as.5f     (a2)    0.258    0.166    1.550    0.121    0.258    0.087
##     sample           -0.148    0.190   -0.777    0.437   -0.148   -0.042
##   pp.support ~                                                          
##     sample            0.537    0.289    1.861    0.063    0.537    0.106
##   passion ~                                                             
##     sample            0.021    0.090    0.239    0.811    0.021    0.012
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.191    0.033    5.764    0.000    0.191    0.352
##     sample            0.034    0.015    2.333    0.020    0.034    0.136
##     aps.discrep       0.060    0.045    1.345    0.179    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.082    2.608    0.009    0.215    0.152
##     sample            0.097    0.027    3.597    0.000    0.097    0.212
##   aps.discrep ~~                                                        
##     sample            0.104    0.038    2.738    0.006    0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .passion           0.470    0.038   12.268    0.000    0.470    0.718
##    .pp.support        4.944    0.403   12.268    0.000    4.944    0.907
##    .relatedness       2.127    0.173   12.268    0.000    2.127    0.809
##     as.5f             0.298    0.024   12.268    0.000    0.298    1.000
##     aps.stand         0.988    0.081   12.268    0.000    0.988    1.000
##     aps.discrep       2.026    0.165   12.268    0.000    2.026    1.000
##     sample            0.211    0.017   12.268    0.000    0.211    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.056    0.027    2.097    0.036    0.056    0.032
##     standardsndrct    0.045    0.017    2.567    0.010    0.045    0.045
##     discrepindirct   -0.023    0.011   -2.053    0.040   -0.023   -0.046
##     total1            0.312    0.081    3.854    0.000    0.312    0.204
##     total2            0.279    0.046    6.112    0.000    0.279    0.334
##     total3           -0.152    0.031   -4.840    0.000   -0.152   -0.273
fit2.p <- sem(
  model = mmed2.p,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit2.p, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 57 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           301         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               260.197
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2884.162
##   Loglikelihood unrestricted model (H1)      -2884.162
##                                                       
##   Akaike (AIC)                                5824.324
##   Bayesian (BIC)                              5928.124
##   Sample-size adjusted Bayesian (BIC)         5839.323
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   passion ~                                                             
##     rltdnss   (b1)    0.081    0.030    2.751    0.006    0.024    0.141
##     pp.sppr   (b2)    0.031    0.021    1.479    0.139   -0.010    0.073
##     as.5f     (c1)    0.256    0.093    2.756    0.006    0.065    0.431
##     aps.stn   (c2)    0.234    0.052    4.519    0.000    0.134    0.338
##     aps.dsc   (c3)   -0.129    0.029   -4.416    0.000   -0.186   -0.072
##   pp.support ~                                                          
##     as.5f     (a1)    0.568    0.240    2.369    0.018    0.057    1.003
##     aps.stn  (aa1)    0.452    0.142    3.184    0.001    0.160    0.715
##     aps.dsc (aaa1)   -0.118    0.093   -1.272    0.203   -0.306    0.059
##   relatedness ~                                                         
##     pp.sppr  (d21)    0.117    0.038    3.103    0.002    0.042    0.191
##     aps.stn  (aa2)    0.198    0.095    2.095    0.036    0.005    0.374
##     aps.dsc (aaa2)   -0.413    0.067   -6.182    0.000   -0.543   -0.281
##     as.5f     (a2)    0.258    0.201    1.283    0.200   -0.184    0.605
##     sample           -0.148    0.190   -0.779    0.436   -0.512    0.229
##   pp.support ~                                                          
##     sample            0.537    0.285    1.886    0.059   -0.025    1.103
##   passion ~                                                             
##     sample            0.021    0.090    0.239    0.811   -0.153    0.196
##    Std.lv  Std.all
##                   
##     0.081    0.163
##     0.031    0.091
##     0.256    0.173
##     0.234    0.288
##    -0.129   -0.227
##                   
##     0.568    0.133
##     0.452    0.192
##    -0.118   -0.072
##                   
##     0.117    0.168
##     0.198    0.121
##    -0.413   -0.362
##     0.258    0.087
##    -0.148   -0.042
##                   
##     0.537    0.106
##                   
##     0.021    0.012
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.191    0.067    2.870    0.004    0.081    0.337
##     sample            0.034    0.016    2.071    0.038    0.002    0.067
##     aps.discrep       0.060    0.059    1.030    0.303   -0.045    0.183
##   aps.stand ~~                                                          
##     aps.discrep       0.215    0.095    2.253    0.024    0.033    0.412
##     sample            0.097    0.028    3.398    0.001    0.041    0.152
##   aps.discrep ~~                                                        
##     sample            0.104    0.039    2.712    0.007    0.027    0.180
##    Std.lv  Std.all
##                   
##     0.191    0.352
##     0.034    0.136
##     0.060    0.078
##                   
##     0.215    0.152
##     0.097    0.212
##                   
##     0.104    0.160
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .passion           0.470    0.046   10.263    0.000    0.370    0.550
##    .pp.support        4.944    0.377   13.103    0.000    4.153    5.607
##    .relatedness       2.127    0.159   13.383    0.000    1.774    2.397
##     as.5f             0.298    0.052    5.745    0.000    0.211    0.408
##     aps.stand         0.988    0.119    8.295    0.000    0.770    1.236
##     aps.discrep       2.026    0.128   15.771    0.000    1.773    2.270
##     sample            0.211    0.010   20.356    0.000    0.189    0.229
##    Std.lv  Std.all
##     0.470    0.718
##     4.944    0.907
##     2.127    0.809
##     0.298    1.000
##     0.988    1.000
##     2.026    1.000
##     0.211    1.000
## 
## R-Square:
##                    Estimate
##     passion           0.282
##     pp.support        0.093
##     relatedness       0.191
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.056    0.029    1.975    0.048    0.007    0.116
##     standardsndrct    0.045    0.019    2.364    0.018    0.013    0.086
##     discrepindirct   -0.023    0.013   -1.833    0.067   -0.049    0.002
##     total1            0.312    0.097    3.214    0.001    0.114    0.489
##     total2            0.279    0.054    5.187    0.000    0.177    0.387
##     total3           -0.152    0.031   -4.959    0.000   -0.210   -0.090
##    Std.lv  Std.all
##     0.056    0.032
##     0.045    0.045
##    -0.023   -0.046
##     0.312    0.204
##     0.279    0.334
##    -0.152   -0.273
standardizedSolution(fit2.p, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1            passion  ~                      relatedness   0.163 0.058  2.801
## 2            passion  ~                       pp.support   0.091 0.061  1.479
## 3            passion  ~                            as.5f   0.173 0.065  2.667
## 4            passion  ~                        aps.stand   0.288 0.059  4.877
## 5            passion  ~                      aps.discrep  -0.227 0.049 -4.612
## 6         pp.support  ~                            as.5f   0.133 0.059  2.256
## 7         pp.support  ~                        aps.stand   0.192 0.062  3.120
## 8         pp.support  ~                      aps.discrep  -0.072 0.057 -1.270
## 9        relatedness  ~                       pp.support   0.168 0.054  3.138
## 10       relatedness  ~                        aps.stand   0.121 0.059  2.048
## 11       relatedness  ~                      aps.discrep  -0.362 0.056 -6.457
## 12       relatedness  ~                            as.5f   0.087 0.071  1.227
## 13             as.5f ~~                        aps.stand   0.352 0.088  4.000
## 14             as.5f ~~                           sample   0.136 0.061  2.220
## 15             as.5f ~~                      aps.discrep   0.078 0.071  1.097
## 16         aps.stand ~~                      aps.discrep   0.152 0.062  2.451
## 17         aps.stand ~~                           sample   0.212 0.058  3.627
## 18       aps.discrep ~~                           sample   0.160 0.058  2.775
## 19       relatedness  ~                           sample  -0.042 0.054 -0.778
## 20        pp.support  ~                           sample   0.106 0.056  1.883
## 21           passion  ~                           sample   0.012 0.051  0.238
## 22           passion ~~                          passion   0.718 0.052 13.729
## 23        pp.support ~~                       pp.support   0.907 0.040 22.540
## 24       relatedness ~~                      relatedness   0.809 0.044 18.334
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.032 0.016  1.941
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.045 0.018  2.535
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.046 0.025 -1.820
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.204 0.068  3.002
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.334 0.059  5.636
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.273 0.053 -5.132
##    pvalue ci.lower ci.upper
## 1   0.005    0.049    0.277
## 2   0.139   -0.030    0.211
## 3   0.008    0.046    0.300
## 4   0.000    0.172    0.404
## 5   0.000   -0.323   -0.130
## 6   0.024    0.017    0.248
## 7   0.002    0.072    0.313
## 8   0.204   -0.183    0.039
## 9   0.002    0.063    0.273
## 10  0.041    0.005    0.238
## 11  0.000   -0.472   -0.252
## 12  0.220   -0.052    0.225
## 13  0.000    0.180    0.525
## 14  0.026    0.016    0.255
## 15  0.273   -0.061    0.217
## 16  0.014    0.030    0.274
## 17  0.000    0.097    0.326
## 18  0.006    0.047    0.273
## 19  0.437   -0.148    0.064
## 20  0.060   -0.004    0.216
## 21  0.812   -0.088    0.112
## 22  0.000    0.616    0.821
## 23  0.000    0.828    0.986
## 24  0.000    0.723    0.896
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.052    0.000    0.063
## 30  0.011    0.010    0.080
## 31  0.069   -0.095    0.004
## 32  0.003    0.071    0.338
## 33  0.000    0.218    0.450
## 34  0.000   -0.377   -0.168
parameterEstimates(fit2.p, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1            passion  ~                      relatedness                b1
## 2            passion  ~                       pp.support                b2
## 3            passion  ~                            as.5f                c1
## 4            passion  ~                        aps.stand                c2
## 5            passion  ~                      aps.discrep                c3
## 6         pp.support  ~                            as.5f                a1
## 7         pp.support  ~                        aps.stand               aa1
## 8         pp.support  ~                      aps.discrep              aaa1
## 9        relatedness  ~                       pp.support               d21
## 10       relatedness  ~                        aps.stand               aa2
## 11       relatedness  ~                      aps.discrep              aaa2
## 12       relatedness  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19       relatedness  ~                           sample                  
## 20        pp.support  ~                           sample                  
## 21           passion  ~                           sample                  
## 22           passion ~~                          passion                  
## 23        pp.support ~~                       pp.support                  
## 24       relatedness ~~                      relatedness                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.081 0.030  2.751  0.006    0.026    0.142
## 2   0.031 0.021  1.479  0.139   -0.009    0.074
## 3   0.256 0.093  2.756  0.006    0.077    0.442
## 4   0.234 0.052  4.519  0.000    0.136    0.339
## 5  -0.129 0.029 -4.416  0.000   -0.187   -0.073
## 6   0.568 0.240  2.369  0.018    0.057    1.003
## 7   0.452 0.142  3.184  0.001    0.157    0.713
## 8  -0.118 0.093 -1.272  0.203   -0.297    0.066
## 9   0.117 0.038  3.103  0.002    0.042    0.190
## 10  0.198 0.095  2.095  0.036    0.008    0.378
## 11 -0.413 0.067 -6.182  0.000   -0.540   -0.278
## 12  0.258 0.201  1.283  0.200   -0.157    0.628
## 13  0.191 0.067  2.870  0.004    0.092    0.363
## 14  0.034 0.016  2.071  0.038    0.004    0.068
## 15  0.060 0.059  1.030  0.303   -0.039    0.191
## 16  0.215 0.095  2.253  0.024    0.041    0.423
## 17  0.097 0.028  3.398  0.001    0.040    0.152
## 18  0.104 0.039  2.712  0.007    0.026    0.179
## 19 -0.148 0.190 -0.779  0.436   -0.527    0.215
## 20  0.537 0.285  1.886  0.059   -0.026    1.099
## 21  0.021 0.090  0.239  0.811   -0.151    0.198
## 22  0.470 0.046 10.263  0.000    0.397    0.586
## 23  4.944 0.377 13.103  0.000    4.283    5.734
## 24  2.127 0.159 13.383  0.000    1.867    2.516
## 25  0.298 0.052  5.745  0.000    0.220    0.431
## 26  0.988 0.119  8.295  0.000    0.787    1.260
## 27  2.026 0.128 15.771  0.000    1.789    2.290
## 28  0.211 0.010 20.356  0.000    0.189    0.229
## 29  0.056 0.029  1.975  0.048    0.011    0.126
## 30  0.045 0.019  2.364  0.018    0.015    0.091
## 31 -0.023 0.013 -1.833  0.067   -0.049    0.001
## 32  0.312 0.097  3.214  0.001    0.128    0.507
## 33  0.279 0.054  5.187  0.000    0.180    0.390
## 34 -0.152 0.031 -4.959  0.000   -0.211   -0.091
###############################################################################################################
#H3: Achievement striving leads to satisfaction of autonomy needs at both the psychological and project level, 
# which in turn leads to well-being, even when controlling for perfectionistic standards and discrepancies 
###############################################################################################################

#Mediation model with positive mental health as outcome controlling for perfectionistic standards and discrepancies

mmed3.mhcR <- 

  '
mhcR ~ b1 * autonomy + b2 * pp.autonomy + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.autonomy ~ a1 * as.5f
pp.autonomy ~ aa1 * aps.stand
pp.autonomy ~ aaa1 * aps.discrep
autonomy ~ d21 * pp.autonomy
autonomy ~ aa2 * aps.stand
autonomy ~ aaa2 * aps.discrep
autonomy ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
autonomy ~ sample
pp.autonomy ~ sample
mhcR ~ sample
'

fit3.mhcR <- sem(model = mmed3.mhcR, data = pp)
summary(fit3.mhcR, standardized = TRUE)
## lavaan 0.6-8 ended normally after 51 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   mhcR ~                                                                
##     autonmy   (b1)    0.257    0.040    6.485    0.000    0.257    0.321
##     pp.tnmy   (b2)    0.012    0.026    0.462    0.644    0.012    0.023
##     as.5f     (c1)    0.279    0.091    3.070    0.002    0.279    0.150
##     aps.stn   (c2)    0.160    0.054    2.959    0.003    0.160    0.157
##     aps.dsc   (c3)   -0.261    0.034   -7.667    0.000   -0.261   -0.367
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.197    1.820    0.069    0.358    0.103
##     aps.stn  (aa1)    0.704    0.110    6.400    0.000    0.704    0.368
##     aps.dsc (aaa1)   -0.042    0.072   -0.584    0.559   -0.042   -0.031
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.038    1.777    0.076    0.067    0.101
##     aps.stn  (aa2)    0.240    0.077    3.112    0.002    0.240    0.189
##     aps.dsc (aaa2)   -0.254    0.047   -5.386    0.000   -0.254   -0.287
##     as.5f     (a2)    0.390    0.130    2.991    0.003    0.390    0.168
##     sample            0.051    0.148    0.346    0.729    0.051    0.019
##   pp.autonomy ~                                                         
##     sample           -0.221    0.225   -0.981    0.327   -0.221   -0.053
##   mhcR ~                                                                
##     sample           -0.170    0.102   -1.663    0.096   -0.170   -0.077
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .mhcR              0.620    0.050   12.288    0.000    0.620    0.608
##    .pp.autonomy       3.024    0.246   12.288    0.000    3.024    0.837
##    .autonomy          1.310    0.107   12.288    0.000    1.310    0.823
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.097    0.053    1.814    0.070    0.097    0.037
##     standardsndrct    0.184    0.040    4.614    0.000    0.184    0.123
##     discrepindirct   -0.014    0.020   -0.705    0.481   -0.014   -0.017
##     total1            0.376    0.103    3.666    0.000    0.376    0.187
##     total2            0.344    0.061    5.643    0.000    0.344    0.280
##     total3           -0.275    0.039   -7.068    0.000   -0.275   -0.384
fit3.mhcR <- sem(
  model = mmed3.mhcR,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit3.mhcR, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 51 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               330.336
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2788.208
##   Loglikelihood unrestricted model (H1)      -2788.208
##                                                       
##   Akaike (AIC)                                5632.416
##   Bayesian (BIC)                              5736.308
##   Sample-size adjusted Bayesian (BIC)         5647.507
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   mhcR ~                                                                
##     autonmy   (b1)    0.257    0.040    6.398    0.000    0.180    0.336
##     pp.tnmy   (b2)    0.012    0.028    0.430    0.667   -0.042    0.068
##     as.5f     (c1)    0.279    0.094    2.973    0.003    0.079    0.448
##     aps.stn   (c2)    0.160    0.055    2.920    0.004    0.049    0.260
##     aps.dsc   (c3)   -0.261    0.037   -7.095    0.000   -0.333   -0.188
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.207    1.734    0.083   -0.076    0.734
##     aps.stn  (aa1)    0.704    0.134    5.238    0.000    0.459    0.986
##     aps.dsc (aaa1)   -0.042    0.070   -0.595    0.552   -0.184    0.091
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.042    1.591    0.112   -0.016    0.150
##     aps.stn  (aa2)    0.240    0.112    2.151    0.031    0.019    0.456
##     aps.dsc (aaa2)   -0.254    0.052   -4.924    0.000   -0.356   -0.153
##     as.5f     (a2)    0.390    0.160    2.434    0.015    0.057    0.682
##     sample            0.051    0.166    0.310    0.757   -0.253    0.393
##   pp.autonomy ~                                                         
##     sample           -0.221    0.223   -0.990    0.322   -0.649    0.226
##   mhcR ~                                                                
##     sample           -0.170    0.107   -1.583    0.113   -0.374    0.044
##    Std.lv  Std.all
##                   
##     0.257    0.321
##     0.012    0.023
##     0.279    0.150
##     0.160    0.157
##    -0.261   -0.367
##                   
##     0.358    0.103
##     0.704    0.368
##    -0.042   -0.031
##                   
##     0.067    0.101
##     0.240    0.189
##    -0.254   -0.287
##     0.390    0.168
##     0.051    0.019
##                   
##    -0.221   -0.053
##                   
##    -0.170   -0.077
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.069    2.748    0.006    0.082    0.349
##     sample            0.034    0.017    2.033    0.042    0.002    0.068
##     aps.discrep       0.060    0.060    1.004    0.315   -0.048    0.188
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.096    2.215    0.027    0.033    0.408
##     sample            0.098    0.029    3.376    0.001    0.041    0.157
##   aps.discrep ~~                                                        
##     sample            0.101    0.039    2.607    0.009    0.025    0.177
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .mhcR              0.620    0.049   12.554    0.000    0.512    0.705
##    .pp.autonomy       3.024    0.346    8.729    0.000    2.321    3.662
##    .autonomy          1.310    0.143    9.192    0.000    1.009    1.563
##     as.5f             0.297    0.053    5.561    0.000    0.209    0.419
##     aps.stand         0.986    0.122    8.109    0.000    0.764    1.233
##     aps.discrep       2.024    0.131   15.488    0.000    1.763    2.268
##     sample            0.212    0.010   20.195    0.000    0.188    0.230
##    Std.lv  Std.all
##     0.620    0.608
##     3.024    0.837
##     1.310    0.823
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     mhcR              0.392
##     pp.autonomy       0.163
##     autonomy          0.177
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.097    0.058    1.677    0.094   -0.013    0.217
##     standardsndrct    0.184    0.045    4.137    0.000    0.108    0.284
##     discrepindirct   -0.014    0.020   -0.695    0.487   -0.055    0.024
##     total1            0.376    0.111    3.386    0.001    0.138    0.569
##     total2            0.344    0.061    5.611    0.000    0.220    0.465
##     total3           -0.275    0.040   -6.846    0.000   -0.354   -0.195
##    Std.lv  Std.all
##     0.097    0.037
##     0.184    0.123
##    -0.014   -0.017
##     0.376    0.187
##     0.344    0.280
##    -0.275   -0.384
standardizedSolution(fit3.mhcR, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1               mhcR  ~                         autonomy   0.321 0.050  6.431
## 2               mhcR  ~                      pp.autonomy   0.023 0.053  0.432
## 3               mhcR  ~                            as.5f   0.150 0.056  2.686
## 4               mhcR  ~                        aps.stand   0.157 0.055  2.879
## 5               mhcR  ~                      aps.discrep  -0.367 0.050 -7.308
## 6        pp.autonomy  ~                            as.5f   0.103 0.061  1.679
## 7        pp.autonomy  ~                        aps.stand   0.368 0.061  6.081
## 8        pp.autonomy  ~                      aps.discrep  -0.031 0.053 -0.595
## 9           autonomy  ~                      pp.autonomy   0.101 0.064  1.574
## 10          autonomy  ~                        aps.stand   0.189 0.090  2.105
## 11          autonomy  ~                      aps.discrep  -0.287 0.058 -4.911
## 12          autonomy  ~                            as.5f   0.168 0.075  2.234
## 13             as.5f ~~                        aps.stand   0.352 0.091  3.874
## 14             as.5f ~~                           sample   0.135 0.062  2.179
## 15             as.5f ~~                      aps.discrep   0.078 0.073  1.072
## 16         aps.stand ~~                      aps.discrep   0.150 0.062  2.420
## 17         aps.stand ~~                           sample   0.214 0.059  3.632
## 18       aps.discrep ~~                           sample   0.155 0.058  2.674
## 19          autonomy  ~                           sample   0.019 0.060  0.311
## 20       pp.autonomy  ~                           sample  -0.053 0.054 -0.994
## 21              mhcR  ~                           sample  -0.077 0.049 -1.571
## 22              mhcR ~~                             mhcR   0.608 0.046 13.071
## 23       pp.autonomy ~~                      pp.autonomy   0.837 0.053 15.902
## 24          autonomy ~~                         autonomy   0.823 0.049 16.871
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.037 0.023  1.605
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.123 0.029  4.304
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.017 0.023 -0.721
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.187 0.064  2.937
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.280 0.054  5.192
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.384 0.054 -7.126
##    pvalue ci.lower ci.upper
## 1   0.000    0.223    0.419
## 2   0.666   -0.081    0.126
## 3   0.007    0.041    0.260
## 4   0.004    0.050    0.264
## 5   0.000   -0.466   -0.269
## 6   0.093   -0.017    0.222
## 7   0.000    0.249    0.487
## 8   0.552   -0.135    0.072
## 9   0.116   -0.025    0.228
## 10  0.035    0.013    0.365
## 11  0.000   -0.401   -0.172
## 12  0.025    0.021    0.315
## 13  0.000    0.174    0.530
## 14  0.029    0.014    0.256
## 15  0.284   -0.065    0.220
## 16  0.016    0.028    0.271
## 17  0.000    0.099    0.330
## 18  0.008    0.041    0.268
## 19  0.756   -0.099    0.137
## 20  0.320   -0.159    0.052
## 21  0.116   -0.174    0.019
## 22  0.000    0.517    0.699
## 23  0.000    0.734    0.940
## 24  0.000    0.727    0.918
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.108   -0.008    0.082
## 30  0.000    0.067    0.179
## 31  0.471   -0.062    0.029
## 32  0.003    0.062    0.312
## 33  0.000    0.174    0.386
## 34  0.000   -0.490   -0.278
parameterEstimates(fit3.mhcR, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1               mhcR  ~                         autonomy                b1
## 2               mhcR  ~                      pp.autonomy                b2
## 3               mhcR  ~                            as.5f                c1
## 4               mhcR  ~                        aps.stand                c2
## 5               mhcR  ~                      aps.discrep                c3
## 6        pp.autonomy  ~                            as.5f                a1
## 7        pp.autonomy  ~                        aps.stand               aa1
## 8        pp.autonomy  ~                      aps.discrep              aaa1
## 9           autonomy  ~                      pp.autonomy               d21
## 10          autonomy  ~                        aps.stand               aa2
## 11          autonomy  ~                      aps.discrep              aaa2
## 12          autonomy  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19          autonomy  ~                           sample                  
## 20       pp.autonomy  ~                           sample                  
## 21              mhcR  ~                           sample                  
## 22              mhcR ~~                             mhcR                  
## 23       pp.autonomy ~~                      pp.autonomy                  
## 24          autonomy ~~                         autonomy                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.257 0.040  6.398  0.000    0.179    0.335
## 2   0.012 0.028  0.430  0.667   -0.041    0.068
## 3   0.279 0.094  2.973  0.003    0.088    0.454
## 4   0.160 0.055  2.920  0.004    0.054    0.267
## 5  -0.261 0.037 -7.095  0.000   -0.330   -0.185
## 6   0.358 0.207  1.734  0.083   -0.050    0.749
## 7   0.704 0.134  5.238  0.000    0.459    0.986
## 8  -0.042 0.070 -0.595  0.552   -0.176    0.097
## 9   0.067 0.042  1.591  0.112   -0.015    0.150
## 10  0.240 0.112  2.151  0.031    0.034    0.471
## 11 -0.254 0.052 -4.924  0.000   -0.355   -0.151
## 12  0.390 0.160  2.434  0.015    0.056    0.679
## 13  0.190 0.069  2.748  0.006    0.089    0.367
## 14  0.034 0.017  2.033  0.042    0.003    0.069
## 15  0.060 0.060  1.004  0.315   -0.043    0.197
## 16  0.212 0.096  2.215  0.027    0.041    0.420
## 17  0.098 0.029  3.376  0.001    0.044    0.160
## 18  0.101 0.039  2.607  0.009    0.026    0.178
## 19  0.051 0.166  0.310  0.757   -0.257    0.391
## 20 -0.221 0.223 -0.990  0.322   -0.656    0.222
## 21 -0.170 0.107 -1.583  0.113   -0.383    0.034
## 22  0.620 0.049 12.554  0.000    0.539    0.743
## 23  3.024 0.346  8.729  0.000    2.429    3.803
## 24  1.310 0.143  9.192  0.000    1.082    1.659
## 25  0.297 0.053  5.561  0.000    0.216    0.434
## 26  0.986 0.122  8.109  0.000    0.775    1.268
## 27  2.024 0.131 15.488  0.000    1.777    2.289
## 28  0.212 0.010 20.195  0.000    0.188    0.230
## 29  0.097 0.058  1.677  0.094   -0.005    0.227
## 30  0.184 0.045  4.137  0.000    0.110    0.288
## 31 -0.014 0.020 -0.695  0.487   -0.053    0.027
## 32  0.376 0.111  3.386  0.001    0.144    0.576
## 33  0.344 0.061  5.611  0.000    0.225    0.469
## 34 -0.275 0.040 -6.846  0.000   -0.348   -0.189
#########################################################################################################

#Mediation model with zest as outcome controlling for perfectionistic standards and discrepancies


mmed3.zest <- 

  '
zestR ~ b1 * autonomy + b2 * pp.autonomy + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.autonomy ~ a1 * as.5f
pp.autonomy ~ aa1 * aps.stand
pp.autonomy ~ aaa1 * aps.discrep
autonomy ~ d21 * pp.autonomy
autonomy ~ aa2 * aps.stand
autonomy ~ aaa2 * aps.discrep
autonomy ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
autonomy ~ sample
pp.autonomy ~ sample
zestR ~ sample
'

fit3.zest <- sem(model = mmed3.zest, data = pp)
summary(fit3.zest, standardized = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   zestR ~                                                               
##     autonmy   (b1)    0.260    0.048    5.398    0.000    0.260    0.270
##     pp.tnmy   (b2)    0.037    0.032    1.170    0.242    0.037    0.058
##     as.5f     (c1)    0.212    0.110    1.916    0.055    0.212    0.095
##     aps.stn   (c2)    0.078    0.066    1.187    0.235    0.078    0.064
##     aps.dsc   (c3)   -0.389    0.041   -9.408    0.000   -0.389   -0.456
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.197    1.820    0.069    0.358    0.103
##     aps.stn  (aa1)    0.704    0.110    6.400    0.000    0.704    0.368
##     aps.dsc (aaa1)   -0.042    0.072   -0.584    0.559   -0.042   -0.031
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.038    1.777    0.076    0.067    0.101
##     aps.stn  (aa2)    0.240    0.077    3.112    0.002    0.240    0.189
##     aps.dsc (aaa2)   -0.254    0.047   -5.386    0.000   -0.254   -0.287
##     as.5f     (a2)    0.390    0.130    2.991    0.003    0.390    0.168
##     sample            0.051    0.148    0.346    0.729    0.051    0.019
##   pp.autonomy ~                                                         
##     sample           -0.221    0.225   -0.981    0.327   -0.221   -0.053
##   zestR ~                                                               
##     sample           -0.033    0.124   -0.265    0.791   -0.033   -0.012
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .zestR             0.916    0.075   12.288    0.000    0.916    0.622
##    .pp.autonomy       3.024    0.246   12.288    0.000    3.024    0.837
##    .autonomy          1.310    0.107   12.288    0.000    1.310    0.823
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.108    0.056    1.945    0.052    0.108    0.038
##     standardsndrct    0.194    0.045    4.320    0.000    0.194    0.113
##     discrepindirct   -0.020    0.021   -0.993    0.321   -0.020   -0.025
##     total1            0.320    0.120    2.665    0.008    0.320    0.133
##     total2            0.271    0.072    3.786    0.000    0.271    0.176
##     total3           -0.410    0.046   -8.970    0.000   -0.410   -0.482
fit3.zest <- sem(
  model = mmed3.zest,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit3.zest, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               323.288
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2847.166
##   Loglikelihood unrestricted model (H1)      -2847.166
##                                                       
##   Akaike (AIC)                                5750.332
##   Bayesian (BIC)                              5854.224
##   Sample-size adjusted Bayesian (BIC)         5765.423
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   zestR ~                                                               
##     autonmy   (b1)    0.260    0.053    4.859    0.000    0.154    0.365
##     pp.tnmy   (b2)    0.037    0.040    0.942    0.346   -0.037    0.120
##     as.5f     (c1)    0.212    0.103    2.064    0.039    0.010    0.416
##     aps.stn   (c2)    0.078    0.064    1.208    0.227   -0.052    0.203
##     aps.dsc   (c3)   -0.389    0.044   -8.755    0.000   -0.475   -0.300
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.207    1.733    0.083   -0.078    0.740
##     aps.stn  (aa1)    0.704    0.133    5.303    0.000    0.457    0.975
##     aps.dsc (aaa1)   -0.042    0.070   -0.598    0.550   -0.185    0.092
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.043    1.577    0.115   -0.018    0.151
##     aps.stn  (aa2)    0.240    0.110    2.177    0.030    0.025    0.452
##     aps.dsc (aaa2)   -0.254    0.051   -4.988    0.000   -0.356   -0.156
##     as.5f     (a2)    0.390    0.164    2.373    0.018    0.056    0.693
##     sample            0.051    0.166    0.308    0.758   -0.270    0.384
##   pp.autonomy ~                                                         
##     sample           -0.221    0.224   -0.985    0.325   -0.664    0.218
##   zestR ~                                                               
##     sample           -0.033    0.129   -0.255    0.799   -0.289    0.211
##    Std.lv  Std.all
##                   
##     0.260    0.270
##     0.037    0.058
##     0.212    0.095
##     0.078    0.064
##    -0.389   -0.456
##                   
##     0.358    0.103
##     0.704    0.368
##    -0.042   -0.031
##                   
##     0.067    0.101
##     0.240    0.189
##    -0.254   -0.287
##     0.390    0.168
##     0.051    0.019
##                   
##    -0.221   -0.053
##                   
##    -0.033   -0.012
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.068    2.779    0.005    0.082    0.345
##     sample            0.034    0.017    2.037    0.042    0.002    0.068
##     aps.discrep       0.060    0.060    1.004    0.315   -0.047    0.189
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.096    2.215    0.027    0.035    0.406
##     sample            0.098    0.029    3.412    0.001    0.044    0.155
##   aps.discrep ~~                                                        
##     sample            0.101    0.039    2.607    0.009    0.026    0.179
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .zestR             0.916    0.077   11.913    0.000    0.747    1.050
##    .pp.autonomy       3.024    0.345    8.773    0.000    2.316    3.686
##    .autonomy          1.310    0.141    9.311    0.000    1.013    1.559
##     as.5f             0.297    0.053    5.562    0.000    0.211    0.419
##     aps.stand         0.986    0.122    8.061    0.000    0.768    1.249
##     aps.discrep       2.024    0.132   15.340    0.000    1.763    2.279
##     sample            0.212    0.010   20.307    0.000    0.190    0.230
##    Std.lv  Std.all
##     0.916    0.622
##     3.024    0.837
##     1.310    0.823
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     zestR             0.378
##     pp.autonomy       0.163
##     autonomy          0.177
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.108    0.062    1.763    0.078   -0.008    0.235
##     standardsndrct    0.194    0.052    3.707    0.000    0.104    0.308
##     discrepindirct   -0.020    0.023   -0.879    0.380   -0.070    0.021
##     total1            0.320    0.108    2.968    0.003    0.101    0.517
##     total2            0.271    0.074    3.678    0.000    0.129    0.429
##     total3           -0.410    0.049   -8.366    0.000   -0.508   -0.312
##    Std.lv  Std.all
##     0.108    0.038
##     0.194    0.113
##    -0.020   -0.025
##     0.320    0.133
##     0.271    0.176
##    -0.410   -0.482
standardizedSolution(fit3.zest, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1              zestR  ~                         autonomy   0.270 0.056  4.797
## 2              zestR  ~                      pp.autonomy   0.058 0.061  0.961
## 3              zestR  ~                            as.5f   0.095 0.046  2.046
## 4              zestR  ~                        aps.stand   0.064 0.053  1.201
## 5              zestR  ~                      aps.discrep  -0.456 0.048 -9.500
## 6        pp.autonomy  ~                            as.5f   0.103 0.061  1.675
## 7        pp.autonomy  ~                        aps.stand   0.368 0.060  6.093
## 8        pp.autonomy  ~                      aps.discrep  -0.031 0.052 -0.598
## 9           autonomy  ~                      pp.autonomy   0.101 0.065  1.566
## 10          autonomy  ~                        aps.stand   0.189 0.089  2.129
## 11          autonomy  ~                      aps.discrep  -0.287 0.057 -4.990
## 12          autonomy  ~                            as.5f   0.168 0.077  2.182
## 13             as.5f ~~                        aps.stand   0.352 0.090  3.916
## 14             as.5f ~~                           sample   0.135 0.062  2.184
## 15             as.5f ~~                      aps.discrep   0.078 0.073  1.071
## 16         aps.stand ~~                      aps.discrep   0.150 0.062  2.409
## 17         aps.stand ~~                           sample   0.214 0.058  3.674
## 18       aps.discrep ~~                           sample   0.155 0.058  2.659
## 19          autonomy  ~                           sample   0.019 0.061  0.309
## 20       pp.autonomy  ~                           sample  -0.053 0.054 -0.989
## 21             zestR  ~                           sample  -0.012 0.049 -0.255
## 22             zestR ~~                            zestR   0.622 0.051 12.244
## 23       pp.autonomy ~~                      pp.autonomy   0.837 0.053 15.763
## 24          autonomy ~~                         autonomy   0.823 0.049 16.959
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.038 0.022  1.729
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.113 0.029  3.949
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.025 0.025 -1.015
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.133 0.049  2.717
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.176 0.052  3.373
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.482 0.052 -9.232
##    pvalue ci.lower ci.upper
## 1   0.000    0.160    0.381
## 2   0.337   -0.061    0.177
## 3   0.041    0.004    0.186
## 4   0.230   -0.040    0.168
## 5   0.000   -0.550   -0.362
## 6   0.094   -0.017    0.223
## 7   0.000    0.250    0.486
## 8   0.550   -0.134    0.071
## 9   0.117   -0.025    0.228
## 10  0.033    0.015    0.363
## 11  0.000   -0.400   -0.174
## 12  0.029    0.017    0.319
## 13  0.000    0.176    0.528
## 14  0.029    0.014    0.256
## 15  0.284   -0.065    0.221
## 16  0.016    0.028    0.272
## 17  0.000    0.100    0.329
## 18  0.008    0.041    0.269
## 19  0.757   -0.100    0.137
## 20  0.323   -0.159    0.052
## 21  0.799   -0.108    0.084
## 22  0.000    0.523    0.722
## 23  0.000    0.733    0.941
## 24  0.000    0.728    0.918
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.084   -0.005    0.081
## 30  0.000    0.057    0.169
## 31  0.310   -0.074    0.024
## 32  0.007    0.037    0.229
## 33  0.001    0.074    0.279
## 34  0.000   -0.584   -0.379
parameterEstimates(fit3.zest, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1              zestR  ~                         autonomy                b1
## 2              zestR  ~                      pp.autonomy                b2
## 3              zestR  ~                            as.5f                c1
## 4              zestR  ~                        aps.stand                c2
## 5              zestR  ~                      aps.discrep                c3
## 6        pp.autonomy  ~                            as.5f                a1
## 7        pp.autonomy  ~                        aps.stand               aa1
## 8        pp.autonomy  ~                      aps.discrep              aaa1
## 9           autonomy  ~                      pp.autonomy               d21
## 10          autonomy  ~                        aps.stand               aa2
## 11          autonomy  ~                      aps.discrep              aaa2
## 12          autonomy  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19          autonomy  ~                           sample                  
## 20       pp.autonomy  ~                           sample                  
## 21             zestR  ~                           sample                  
## 22             zestR ~~                            zestR                  
## 23       pp.autonomy ~~                      pp.autonomy                  
## 24          autonomy ~~                         autonomy                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.260 0.053  4.859  0.000    0.155    0.365
## 2   0.037 0.040  0.942  0.346   -0.042    0.116
## 3   0.212 0.103  2.064  0.039    0.014    0.422
## 4   0.078 0.064  1.208  0.227   -0.052    0.203
## 5  -0.389 0.044 -8.755  0.000   -0.474   -0.298
## 6   0.358 0.207  1.733  0.083   -0.049    0.766
## 7   0.704 0.133  5.303  0.000    0.456    0.975
## 8  -0.042 0.070 -0.598  0.550   -0.179    0.098
## 9   0.067 0.043  1.577  0.115   -0.019    0.150
## 10  0.240 0.110  2.177  0.030    0.041    0.471
## 11 -0.254 0.051 -4.988  0.000   -0.352   -0.152
## 12  0.390 0.164  2.373  0.018    0.048    0.677
## 13  0.190 0.068  2.779  0.005    0.089    0.364
## 14  0.034 0.017  2.037  0.042    0.002    0.068
## 15  0.060 0.060  1.004  0.315   -0.044    0.194
## 16  0.212 0.096  2.215  0.027    0.041    0.412
## 17  0.098 0.029  3.412  0.001    0.045    0.157
## 18  0.101 0.039  2.607  0.009    0.028    0.182
## 19  0.051 0.166  0.308  0.758   -0.280    0.373
## 20 -0.221 0.224 -0.985  0.325   -0.660    0.222
## 21 -0.033 0.129 -0.255  0.799   -0.284    0.215
## 22  0.916 0.077 11.913  0.000    0.796    1.111
## 23  3.024 0.345  8.773  0.000    2.434    3.839
## 24  1.310 0.141  9.311  0.000    1.082    1.665
## 25  0.297 0.053  5.562  0.000    0.217    0.436
## 26  0.986 0.122  8.061  0.000    0.778    1.268
## 27  2.024 0.132 15.340  0.000    1.783    2.298
## 28  0.212 0.010 20.307  0.000    0.192    0.231
## 29  0.108 0.062  1.763  0.078    0.005    0.251
## 30  0.194 0.052  3.707  0.000    0.106    0.313
## 31 -0.020 0.023 -0.879  0.380   -0.067    0.023
## 32  0.320 0.108  2.968  0.003    0.103    0.520
## 33  0.271 0.074  3.678  0.000    0.132    0.432
## 34 -0.410 0.049 -8.366  0.000   -0.503   -0.304
#########################################################################################################

#Mediation model with engagement as outcome controlling for perfectionistic standards and discrepancies


mmed3.eng <- 

  '
engagementR ~ b1 * autonomy + b2 * pp.autonomy + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.autonomy ~ a1 * as.5f
pp.autonomy ~ aa1 * aps.stand
pp.autonomy ~ aaa1 * aps.discrep
autonomy ~ d21 * pp.autonomy
autonomy ~ aa2 * aps.stand
autonomy ~ aaa2 * aps.discrep
autonomy ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
autonomy ~ sample
pp.autonomy ~ sample
engagementR ~ sample
'

fit3.eng <- sem(model = mmed3.eng, data = pp)
summary(fit3.eng, standardized = TRUE)
## lavaan 0.6-8 ended normally after 52 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   engagementR ~                                                         
##     autonmy   (b1)    0.075    0.022    3.361    0.001    0.075    0.170
##     pp.tnmy   (b2)    0.035    0.015    2.355    0.019    0.035    0.119
##     as.5f     (c1)    0.163    0.051    3.193    0.001    0.163    0.160
##     aps.stn   (c2)    0.075    0.030    2.477    0.013    0.075    0.134
##     aps.dsc   (c3)   -0.176    0.019   -9.179    0.000   -0.176   -0.450
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.197    1.820    0.069    0.358    0.103
##     aps.stn  (aa1)    0.704    0.110    6.400    0.000    0.704    0.368
##     aps.dsc (aaa1)   -0.042    0.072   -0.584    0.559   -0.042   -0.031
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.038    1.777    0.076    0.067    0.101
##     aps.stn  (aa2)    0.240    0.077    3.112    0.002    0.240    0.189
##     aps.dsc (aaa2)   -0.254    0.047   -5.386    0.000   -0.254   -0.287
##     as.5f     (a2)    0.390    0.130    2.991    0.003    0.390    0.168
##     sample            0.051    0.148    0.346    0.729    0.051    0.019
##   pp.autonomy ~                                                         
##     sample           -0.221    0.225   -0.981    0.327   -0.221   -0.053
##   engagementR ~                                                         
##     sample           -0.052    0.057   -0.905    0.366   -0.052   -0.043
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .engagementR       0.197    0.016   12.288    0.000    0.197    0.635
##    .pp.autonomy       3.024    0.246   12.288    0.000    3.024    0.837
##    .autonomy          1.310    0.107   12.288    0.000    1.310    0.823
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.041    0.019    2.227    0.026    0.041    0.039
##     standardsndrct    0.063    0.018    3.457    0.001    0.063    0.089
##     discrepindirct   -0.012    0.007   -1.744    0.081   -0.012   -0.040
##     total1            0.205    0.053    3.887    0.000    0.205    0.199
##     total2            0.138    0.032    4.361    0.000    0.138    0.224
##     total3           -0.188    0.020   -9.348    0.000   -0.188   -0.489
fit3.eng <- sem(
  model = mmed3.eng,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit3.eng, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 52 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               317.022
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2614.950
##   Loglikelihood unrestricted model (H1)      -2614.950
##                                                       
##   Akaike (AIC)                                5285.900
##   Bayesian (BIC)                              5389.792
##   Sample-size adjusted Bayesian (BIC)         5300.992
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   engagementR ~                                                         
##     autonmy   (b1)    0.075    0.026    2.884    0.004    0.024    0.125
##     pp.tnmy   (b2)    0.035    0.016    2.142    0.032    0.005    0.067
##     as.5f     (c1)    0.163    0.053    3.102    0.002    0.057    0.262
##     aps.stn   (c2)    0.075    0.034    2.204    0.028    0.010    0.143
##     aps.dsc   (c3)   -0.176    0.021   -8.348    0.000   -0.217   -0.134
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.211    1.696    0.090   -0.088    0.738
##     aps.stn  (aa1)    0.704    0.135    5.217    0.000    0.458    0.982
##     aps.dsc (aaa1)   -0.042    0.072   -0.582    0.561   -0.189    0.095
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.042    1.596    0.111   -0.016    0.149
##     aps.stn  (aa2)    0.240    0.111    2.160    0.031    0.023    0.455
##     aps.dsc (aaa2)   -0.254    0.051   -4.946    0.000   -0.357   -0.157
##     as.5f     (a2)    0.390    0.163    2.383    0.017    0.040    0.693
##     sample            0.051    0.163    0.314    0.753   -0.261    0.380
##   pp.autonomy ~                                                         
##     sample           -0.221    0.221   -0.997    0.319   -0.645    0.223
##   engagementR ~                                                         
##     sample           -0.052    0.060   -0.864    0.387   -0.172    0.065
##    Std.lv  Std.all
##                   
##     0.075    0.170
##     0.035    0.119
##     0.163    0.160
##     0.075    0.134
##    -0.176   -0.450
##                   
##     0.358    0.103
##     0.704    0.368
##    -0.042   -0.031
##                   
##     0.067    0.101
##     0.240    0.189
##    -0.254   -0.287
##     0.390    0.168
##     0.051    0.019
##                   
##    -0.221   -0.053
##                   
##    -0.052   -0.043
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.067    2.840    0.005    0.083    0.342
##     sample            0.034    0.017    2.009    0.044    0.001    0.068
##     aps.discrep       0.060    0.059    1.030    0.303   -0.046    0.185
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.096    2.199    0.028    0.033    0.410
##     sample            0.098    0.029    3.418    0.001    0.042    0.154
##   aps.discrep ~~                                                        
##     sample            0.101    0.039    2.624    0.009    0.024    0.176
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .engagementR       0.197    0.015   12.731    0.000    0.163    0.224
##    .pp.autonomy       3.024    0.348    8.685    0.000    2.335    3.698
##    .autonomy          1.310    0.142    9.255    0.000    1.011    1.562
##     as.5f             0.297    0.053    5.635    0.000    0.210    0.416
##     aps.stand         0.986    0.120    8.194    0.000    0.774    1.243
##     aps.discrep       2.024    0.134   15.086    0.000    1.758    2.288
##     sample            0.212    0.010   20.401    0.000    0.190    0.230
##    Std.lv  Std.all
##     0.197    0.635
##     3.024    0.837
##     1.310    0.823
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     engagementR       0.365
##     pp.autonomy       0.163
##     autonomy          0.177
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.041    0.022    1.833    0.067    0.002    0.088
##     standardsndrct    0.063    0.022    2.818    0.005    0.025    0.113
##     discrepindirct   -0.012    0.007   -1.612    0.107   -0.028    0.002
##     total1            0.205    0.054    3.777    0.000    0.090    0.302
##     total2            0.138    0.035    3.906    0.000    0.075    0.213
##     total3           -0.188    0.022   -8.604    0.000   -0.231   -0.145
##    Std.lv  Std.all
##     0.041    0.039
##     0.063    0.089
##    -0.012   -0.040
##     0.205    0.199
##     0.138    0.224
##    -0.188   -0.489
standardizedSolution(fit3.eng, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1        engagementR  ~                         autonomy   0.170 0.059  2.889
## 2        engagementR  ~                      pp.autonomy   0.119 0.054  2.195
## 3        engagementR  ~                            as.5f   0.160 0.054  2.958
## 4        engagementR  ~                        aps.stand   0.134 0.060  2.233
## 5        engagementR  ~                      aps.discrep  -0.450 0.050 -8.918
## 6        pp.autonomy  ~                            as.5f   0.103 0.062  1.644
## 7        pp.autonomy  ~                        aps.stand   0.368 0.061  6.075
## 8        pp.autonomy  ~                      aps.discrep  -0.031 0.054 -0.582
## 9           autonomy  ~                      pp.autonomy   0.101 0.064  1.580
## 10          autonomy  ~                        aps.stand   0.189 0.089  2.114
## 11          autonomy  ~                      aps.discrep  -0.287 0.058 -4.931
## 12          autonomy  ~                            as.5f   0.168 0.077  2.193
## 13             as.5f ~~                        aps.stand   0.352 0.088  3.987
## 14             as.5f ~~                           sample   0.135 0.063  2.153
## 15             as.5f ~~                      aps.discrep   0.078 0.071  1.100
## 16         aps.stand ~~                      aps.discrep   0.150 0.062  2.398
## 17         aps.stand ~~                           sample   0.214 0.059  3.654
## 18       aps.discrep ~~                           sample   0.155 0.058  2.683
## 19          autonomy  ~                           sample   0.019 0.059  0.315
## 20       pp.autonomy  ~                           sample  -0.053 0.053 -1.001
## 21       engagementR  ~                           sample  -0.043 0.050 -0.861
## 22       engagementR ~~                      engagementR   0.635 0.047 13.641
## 23       pp.autonomy ~~                      pp.autonomy   0.837 0.052 16.123
## 24          autonomy ~~                         autonomy   0.823 0.049 16.904
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.039 0.020  1.890
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.089 0.028  3.170
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.040 0.020 -2.029
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.199 0.057  3.464
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.224 0.055  4.081
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.489 0.052 -9.421
##    pvalue ci.lower ci.upper
## 1   0.004    0.055    0.285
## 2   0.028    0.013    0.225
## 3   0.003    0.054    0.266
## 4   0.026    0.016    0.252
## 5   0.000   -0.549   -0.351
## 6   0.100   -0.020    0.225
## 7   0.000    0.249    0.487
## 8   0.561   -0.137    0.074
## 9   0.114   -0.024    0.227
## 10  0.034    0.014    0.364
## 11  0.000   -0.401   -0.173
## 12  0.028    0.018    0.318
## 13  0.000    0.179    0.525
## 14  0.031    0.012    0.257
## 15  0.271   -0.061    0.217
## 16  0.016    0.027    0.272
## 17  0.000    0.099    0.329
## 18  0.007    0.042    0.268
## 19  0.753   -0.098    0.135
## 20  0.317   -0.158    0.051
## 21  0.389   -0.141    0.055
## 22  0.000    0.544    0.726
## 23  0.000    0.735    0.939
## 24  0.000    0.727    0.918
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.059   -0.001    0.079
## 30  0.002    0.034    0.145
## 31  0.042   -0.078   -0.001
## 32  0.001    0.086    0.311
## 33  0.000    0.116    0.331
## 34  0.000   -0.591   -0.388
parameterEstimates(fit3.eng, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1        engagementR  ~                         autonomy                b1
## 2        engagementR  ~                      pp.autonomy                b2
## 3        engagementR  ~                            as.5f                c1
## 4        engagementR  ~                        aps.stand                c2
## 5        engagementR  ~                      aps.discrep                c3
## 6        pp.autonomy  ~                            as.5f                a1
## 7        pp.autonomy  ~                        aps.stand               aa1
## 8        pp.autonomy  ~                      aps.discrep              aaa1
## 9           autonomy  ~                      pp.autonomy               d21
## 10          autonomy  ~                        aps.stand               aa2
## 11          autonomy  ~                      aps.discrep              aaa2
## 12          autonomy  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19          autonomy  ~                           sample                  
## 20       pp.autonomy  ~                           sample                  
## 21       engagementR  ~                           sample                  
## 22       engagementR ~~                      engagementR                  
## 23       pp.autonomy ~~                      pp.autonomy                  
## 24          autonomy ~~                         autonomy                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.075 0.026  2.884  0.004    0.025    0.126
## 2   0.035 0.016  2.142  0.032    0.005    0.067
## 3   0.163 0.053  3.102  0.002    0.060    0.265
## 4   0.075 0.034  2.204  0.028    0.009    0.143
## 5  -0.176 0.021 -8.348  0.000   -0.218   -0.135
## 6   0.358 0.211  1.696  0.090   -0.054    0.775
## 7   0.704 0.135  5.217  0.000    0.462    0.988
## 8  -0.042 0.072 -0.582  0.561   -0.183    0.104
## 9   0.067 0.042  1.596  0.111   -0.017    0.148
## 10  0.240 0.111  2.160  0.031    0.037    0.466
## 11 -0.254 0.051 -4.946  0.000   -0.354   -0.153
## 12  0.390 0.163  2.383  0.017    0.051    0.698
## 13  0.190 0.067  2.840  0.005    0.090    0.364
## 14  0.034 0.017  2.009  0.044    0.001    0.068
## 15  0.060 0.059  1.030  0.303   -0.041    0.193
## 16  0.212 0.096  2.199  0.028    0.038    0.416
## 17  0.098 0.029  3.418  0.001    0.043    0.154
## 18  0.101 0.039  2.624  0.009    0.024    0.175
## 19  0.051 0.163  0.314  0.753   -0.267    0.372
## 20 -0.221 0.221 -0.997  0.319   -0.653    0.220
## 21 -0.052 0.060 -0.864  0.387   -0.170    0.067
## 22  0.197 0.015 12.731  0.000    0.172    0.236
## 23  3.024 0.348  8.685  0.000    2.449    3.858
## 24  1.310 0.142  9.255  0.000    1.082    1.666
## 25  0.297 0.053  5.635  0.000    0.218    0.430
## 26  0.986 0.120  8.194  0.000    0.789    1.269
## 27  2.024 0.134 15.086  0.000    1.770    2.305
## 28  0.212 0.010 20.401  0.000    0.188    0.229
## 29  0.041 0.022  1.833  0.067    0.006    0.097
## 30  0.063 0.022  2.818  0.005    0.027    0.116
## 31 -0.012 0.007 -1.612  0.107   -0.028    0.002
## 32  0.205 0.054  3.777  0.000    0.095    0.305
## 33  0.138 0.035  3.906  0.000    0.075    0.213
## 34 -0.188 0.022 -8.604  0.000   -0.231   -0.144
#########################################################################################################

#Mediation model with passion as outcome controlling for perfectionistic standards and discrepancies


mmed3.p <- 

  '
passion ~ b1 * autonomy + b2 * pp.autonomy + c1 * as.5f + c2 * aps.stand + c3 * aps.discrep
pp.autonomy ~ a1 * as.5f
pp.autonomy ~ aa1 * aps.stand
pp.autonomy ~ aaa1 * aps.discrep
autonomy ~ d21 * pp.autonomy
autonomy ~ aa2 * aps.stand
autonomy ~ aaa2 * aps.discrep
autonomy ~ a2 * as.5f
ach striv indirect := a1*b1 + a2*b2 + a1*d21*b2
standards indirect := aa1*b1 + aa2*b2 + aa1*d21*b2
discrep indirect  := aaa1*b1 + aaa2*b2 + aaa1*d21*b2
total1 := c1 + (a1*b1 + a2*b2 + a1*d21*b2)
total2 := c2 + (aa1*b1 + aa2*b2 + aa1*d21*b2)
total3 := c3 + (aaa1*b1 + aaa2*b2 + aaa1*d21*b2)
as.5f ~~ aps.stand + sample 
as.5f ~~ aps.discrep
aps.stand ~~ aps.discrep + sample
aps.discrep ~~ sample
autonomy ~ sample
pp.autonomy ~ sample
passion ~ sample
'

fit3.p <- sem(model = mmed3.p, data = pp)
summary(fit3.p, standardized = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Expected
##   Information saturated (h1) model          Structured
## 
## Regressions:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   passion ~                                                             
##     autonmy   (b1)    0.128    0.034    3.787    0.000    0.128    0.200
##     pp.tnmy   (b2)    0.069    0.022    3.064    0.002    0.069    0.161
##     as.5f     (c1)    0.224    0.078    2.892    0.004    0.224    0.151
##     aps.stn   (c2)    0.183    0.046    3.963    0.000    0.183    0.225
##     aps.dsc   (c3)   -0.130    0.029   -4.470    0.000   -0.130   -0.229
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.197    1.820    0.069    0.358    0.103
##     aps.stn  (aa1)    0.704    0.110    6.400    0.000    0.704    0.368
##     aps.dsc (aaa1)   -0.042    0.072   -0.584    0.559   -0.042   -0.031
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.038    1.777    0.076    0.067    0.101
##     aps.stn  (aa2)    0.240    0.077    3.112    0.002    0.240    0.189
##     aps.dsc (aaa2)   -0.254    0.047   -5.386    0.000   -0.254   -0.287
##     as.5f     (a2)    0.390    0.130    2.991    0.003    0.390    0.168
##     sample            0.051    0.148    0.346    0.729    0.051    0.019
##   pp.autonomy ~                                                         
##     sample           -0.221    0.225   -0.981    0.327   -0.221   -0.053
##   passion ~                                                             
##     sample            0.035    0.087    0.401    0.689    0.035    0.020
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   as.5f ~~                                                              
##     aps.stand         0.190    0.033    5.766    0.000    0.190    0.352
##     sample            0.034    0.015    2.320    0.020    0.034    0.135
##     aps.discrep       0.060    0.045    1.350    0.177    0.060    0.078
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.082    2.575    0.010    0.212    0.150
##     sample            0.098    0.027    3.643    0.000    0.098    0.214
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.659    0.008    0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .passion           0.452    0.037   12.288    0.000    0.452    0.694
##    .pp.autonomy       3.024    0.246   12.288    0.000    3.024    0.837
##    .autonomy          1.310    0.107   12.288    0.000    1.310    0.823
##     as.5f             0.297    0.024   12.288    0.000    0.297    1.000
##     aps.stand         0.986    0.080   12.288    0.000    0.986    1.000
##     aps.discrep       2.024    0.165   12.288    0.000    2.024    1.000
##     sample            0.212    0.017   12.288    0.000    0.212    1.000
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     achstrivindrct    0.074    0.031    2.383    0.017    0.074    0.049
##     standardsndrct    0.110    0.029    3.850    0.000    0.110    0.110
##     discrepindirct   -0.023    0.012   -1.983    0.047   -0.023   -0.053
##     total1            0.299    0.081    3.689    0.000    0.299    0.201
##     total2            0.293    0.049    6.020    0.000    0.293    0.335
##     total3           -0.153    0.031   -4.950    0.000   -0.153   -0.282
fit3.p <- sem(
  model = mmed3.p,
  data  = pp,
  se = "bootstrap",
  bootstrap = 5000)

summary(fit3.p, fit.measures=TRUE, standardize=TRUE, rsquare=TRUE,
        estimates = TRUE, ci = TRUE)
## lavaan 0.6-8 ended normally after 49 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        28
##                                                       
##                                                   Used       Total
##   Number of observations                           302         327
##                                                                   
## Model Test User Model:
##                                                       
##   Test statistic                                 0.000
##   Degrees of freedom                                 0
## 
## Model Test Baseline Model:
## 
##   Test statistic                               290.487
##   Degrees of freedom                                21
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000
##   Tucker-Lewis Index (TLI)                       1.000
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -2740.561
##   Loglikelihood unrestricted model (H1)      -2740.561
##                                                       
##   Akaike (AIC)                                5537.123
##   Bayesian (BIC)                              5641.015
##   Sample-size adjusted Bayesian (BIC)         5552.214
## 
## 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 RMSEA <= 0.05                             NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.000
## 
## 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
##   passion ~                                                             
##     autonmy   (b1)    0.128    0.038    3.336    0.001    0.058    0.210
##     pp.tnmy   (b2)    0.069    0.023    2.963    0.003    0.022    0.115
##     as.5f     (c1)    0.224    0.093    2.403    0.016    0.033    0.399
##     aps.stn   (c2)    0.183    0.054    3.354    0.001    0.079    0.293
##     aps.dsc   (c3)   -0.130    0.031   -4.183    0.000   -0.192   -0.069
##   pp.autonomy ~                                                         
##     as.5f     (a1)    0.358    0.206    1.739    0.082   -0.082    0.728
##     aps.stn  (aa1)    0.704    0.135    5.206    0.000    0.454    0.986
##     aps.dsc (aaa1)   -0.042    0.070   -0.598    0.550   -0.186    0.089
##   autonomy ~                                                            
##     pp.tnmy  (d21)    0.067    0.042    1.588    0.112   -0.015    0.151
##     aps.stn  (aa2)    0.240    0.109    2.200    0.028    0.028    0.450
##     aps.dsc (aaa2)   -0.254    0.052   -4.885    0.000   -0.364   -0.155
##     as.5f     (a2)    0.390    0.165    2.362    0.018    0.049    0.688
##     sample            0.051    0.165    0.311    0.756   -0.264    0.380
##   pp.autonomy ~                                                         
##     sample           -0.221    0.222   -0.992    0.321   -0.660    0.210
##   passion ~                                                             
##     sample            0.035    0.088    0.395    0.693   -0.142    0.205
##    Std.lv  Std.all
##                   
##     0.128    0.200
##     0.069    0.161
##     0.224    0.151
##     0.183    0.225
##    -0.130   -0.229
##                   
##     0.358    0.103
##     0.704    0.368
##    -0.042   -0.031
##                   
##     0.067    0.101
##     0.240    0.189
##    -0.254   -0.287
##     0.390    0.168
##     0.051    0.019
##                   
##    -0.221   -0.053
##                   
##     0.035    0.020
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##   as.5f ~~                                                              
##     aps.stand         0.190    0.067    2.829    0.005    0.079    0.340
##     sample            0.034    0.017    2.039    0.041    0.002    0.067
##     aps.discrep       0.060    0.059    1.017    0.309   -0.047    0.186
##   aps.stand ~~                                                          
##     aps.discrep       0.212    0.096    2.213    0.027    0.028    0.407
##     sample            0.098    0.029    3.382    0.001    0.041    0.155
##   aps.discrep ~~                                                        
##     sample            0.101    0.038    2.635    0.008    0.027    0.177
##    Std.lv  Std.all
##                   
##     0.190    0.352
##     0.034    0.135
##     0.060    0.078
##                   
##     0.212    0.150
##     0.098    0.214
##                   
##     0.101    0.155
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##    .passion           0.452    0.044   10.236    0.000    0.356    0.531
##    .pp.autonomy       3.024    0.344    8.780    0.000    2.332    3.684
##    .autonomy          1.310    0.142    9.241    0.000    1.004    1.563
##     as.5f             0.297    0.053    5.626    0.000    0.211    0.415
##     aps.stand         0.986    0.117    8.421    0.000    0.774    1.228
##     aps.discrep       2.024    0.132   15.379    0.000    1.764    2.277
##     sample            0.212    0.010   20.434    0.000    0.190    0.230
##    Std.lv  Std.all
##     0.452    0.694
##     3.024    0.837
##     1.310    0.823
##     0.297    1.000
##     0.986    1.000
##     2.024    1.000
##     0.212    1.000
## 
## R-Square:
##                    Estimate
##     passion           0.306
##     pp.autonomy       0.163
##     autonomy          0.177
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
##     achstrivindrct    0.074    0.036    2.071    0.038    0.005    0.145
##     standardsndrct    0.110    0.035    3.166    0.002    0.054    0.189
##     discrepindirct   -0.023    0.012   -1.878    0.060   -0.049   -0.000
##     total1            0.299    0.100    2.995    0.003    0.086    0.478
##     total2            0.293    0.063    4.611    0.000    0.183    0.430
##     total3           -0.153    0.033   -4.691    0.000   -0.216   -0.090
##    Std.lv  Std.all
##     0.074    0.049
##     0.110    0.110
##    -0.023   -0.053
##     0.299    0.201
##     0.293    0.335
##    -0.153   -0.282
standardizedSolution(fit3.p, type = "std.all", se = TRUE, pvalue = TRUE, ci = TRUE)
##                  lhs op                              rhs est.std    se      z
## 1            passion  ~                         autonomy   0.200 0.056  3.579
## 2            passion  ~                      pp.autonomy   0.161 0.054  2.996
## 3            passion  ~                            as.5f   0.151 0.065  2.336
## 4            passion  ~                        aps.stand   0.225 0.064  3.526
## 5            passion  ~                      aps.discrep  -0.229 0.052 -4.368
## 6        pp.autonomy  ~                            as.5f   0.103 0.061  1.680
## 7        pp.autonomy  ~                        aps.stand   0.368 0.061  6.078
## 8        pp.autonomy  ~                      aps.discrep  -0.031 0.052 -0.598
## 9           autonomy  ~                      pp.autonomy   0.101 0.064  1.572
## 10          autonomy  ~                        aps.stand   0.189 0.088  2.155
## 11          autonomy  ~                      aps.discrep  -0.287 0.059 -4.874
## 12          autonomy  ~                            as.5f   0.168 0.077  2.177
## 13             as.5f ~~                        aps.stand   0.352 0.089  3.971
## 14             as.5f ~~                           sample   0.135 0.062  2.181
## 15             as.5f ~~                      aps.discrep   0.078 0.072  1.087
## 16         aps.stand ~~                      aps.discrep   0.150 0.062  2.406
## 17         aps.stand ~~                           sample   0.214 0.059  3.624
## 18       aps.discrep ~~                           sample   0.155 0.057  2.695
## 19          autonomy  ~                           sample   0.019 0.060  0.311
## 20       pp.autonomy  ~                           sample  -0.053 0.054 -0.998
## 21           passion  ~                           sample   0.020 0.050  0.394
## 22           passion ~~                          passion   0.694 0.053 13.137
## 23       pp.autonomy ~~                      pp.autonomy   0.837 0.052 16.061
## 24          autonomy ~~                         autonomy   0.823 0.047 17.344
## 25             as.5f ~~                            as.5f   1.000 0.000     NA
## 26         aps.stand ~~                        aps.stand   1.000 0.000     NA
## 27       aps.discrep ~~                      aps.discrep   1.000 0.000     NA
## 28            sample ~~                           sample   1.000 0.000     NA
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2   0.049 0.023  2.162
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2   0.110 0.029  3.817
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2  -0.053 0.021 -2.473
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)   0.201 0.070  2.851
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)   0.335 0.061  5.479
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)  -0.282 0.055 -5.125
##    pvalue ci.lower ci.upper
## 1   0.000    0.091    0.310
## 2   0.003    0.056    0.267
## 3   0.019    0.024    0.278
## 4   0.000    0.100    0.349
## 5   0.000   -0.332   -0.126
## 6   0.093   -0.017    0.222
## 7   0.000    0.249    0.487
## 8   0.550   -0.134    0.071
## 9   0.116   -0.025    0.228
## 10  0.031    0.017    0.361
## 11  0.000   -0.402   -0.172
## 12  0.029    0.017    0.319
## 13  0.000    0.178    0.525
## 14  0.029    0.014    0.256
## 15  0.277   -0.063    0.218
## 16  0.016    0.028    0.272
## 17  0.000    0.098    0.330
## 18  0.007    0.042    0.267
## 19  0.755   -0.099    0.137
## 20  0.318   -0.158    0.052
## 21  0.694   -0.079    0.119
## 22  0.000    0.590    0.797
## 23  0.000    0.735    0.939
## 24  0.000    0.730    0.916
## 25     NA    1.000    1.000
## 26     NA    1.000    1.000
## 27     NA    1.000    1.000
## 28     NA    1.000    1.000
## 29  0.031    0.005    0.094
## 30  0.000    0.054    0.167
## 31  0.013   -0.095   -0.011
## 32  0.004    0.063    0.339
## 33  0.000    0.215    0.455
## 34  0.000   -0.390   -0.174
parameterEstimates(fit3.p, boot.ci.type="bca.simple")
##                  lhs op                              rhs             label
## 1            passion  ~                         autonomy                b1
## 2            passion  ~                      pp.autonomy                b2
## 3            passion  ~                            as.5f                c1
## 4            passion  ~                        aps.stand                c2
## 5            passion  ~                      aps.discrep                c3
## 6        pp.autonomy  ~                            as.5f                a1
## 7        pp.autonomy  ~                        aps.stand               aa1
## 8        pp.autonomy  ~                      aps.discrep              aaa1
## 9           autonomy  ~                      pp.autonomy               d21
## 10          autonomy  ~                        aps.stand               aa2
## 11          autonomy  ~                      aps.discrep              aaa2
## 12          autonomy  ~                            as.5f                a2
## 13             as.5f ~~                        aps.stand                  
## 14             as.5f ~~                           sample                  
## 15             as.5f ~~                      aps.discrep                  
## 16         aps.stand ~~                      aps.discrep                  
## 17         aps.stand ~~                           sample                  
## 18       aps.discrep ~~                           sample                  
## 19          autonomy  ~                           sample                  
## 20       pp.autonomy  ~                           sample                  
## 21           passion  ~                           sample                  
## 22           passion ~~                          passion                  
## 23       pp.autonomy ~~                      pp.autonomy                  
## 24          autonomy ~~                         autonomy                  
## 25             as.5f ~~                            as.5f                  
## 26         aps.stand ~~                        aps.stand                  
## 27       aps.discrep ~~                      aps.discrep                  
## 28            sample ~~                           sample                  
## 29  achstrivindirect :=            a1*b1+a2*b2+a1*d21*b2  achstrivindirect
## 30 standardsindirect :=         aa1*b1+aa2*b2+aa1*d21*b2 standardsindirect
## 31   discrepindirect :=      aaa1*b1+aaa2*b2+aaa1*d21*b2   discrepindirect
## 32            total1 :=       c1+(a1*b1+a2*b2+a1*d21*b2)            total1
## 33            total2 :=    c2+(aa1*b1+aa2*b2+aa1*d21*b2)            total2
## 34            total3 := c3+(aaa1*b1+aaa2*b2+aaa1*d21*b2)            total3
##       est    se      z pvalue ci.lower ci.upper
## 1   0.128 0.038  3.336  0.001    0.058    0.210
## 2   0.069 0.023  2.963  0.003    0.024    0.116
## 3   0.224 0.093  2.403  0.016    0.051    0.414
## 4   0.183 0.054  3.354  0.001    0.074    0.288
## 5  -0.130 0.031 -4.183  0.000   -0.192   -0.070
## 6   0.358 0.206  1.739  0.082   -0.042    0.764
## 7   0.704 0.135  5.206  0.000    0.454    0.986
## 8  -0.042 0.070 -0.598  0.550   -0.183    0.091
## 9   0.067 0.042  1.588  0.112   -0.016    0.150
## 10  0.240 0.109  2.200  0.028    0.038    0.464
## 11 -0.254 0.052 -4.885  0.000   -0.359   -0.151
## 12  0.390 0.165  2.362  0.018    0.048    0.688
## 13  0.190 0.067  2.829  0.005    0.092    0.369
## 14  0.034 0.017  2.039  0.041    0.003    0.069
## 15  0.060 0.059  1.017  0.309   -0.044    0.192
## 16  0.212 0.096  2.213  0.027    0.034    0.416
## 17  0.098 0.029  3.382  0.001    0.042    0.157
## 18  0.101 0.038  2.635  0.008    0.028    0.179
## 19  0.051 0.165  0.311  0.756   -0.269    0.372
## 20 -0.221 0.222 -0.992  0.321   -0.657    0.213
## 21  0.035 0.088  0.395  0.693   -0.137    0.210
## 22  0.452 0.044 10.236  0.000    0.379    0.553
## 23  3.024 0.344  8.780  0.000    2.434    3.804
## 24  1.310 0.142  9.241  0.000    1.078    1.636
## 25  0.297 0.053  5.626  0.000    0.220    0.435
## 26  0.986 0.117  8.421  0.000    0.791    1.256
## 27  2.024 0.132 15.379  0.000    1.785    2.295
## 28  0.212 0.010 20.434  0.000    0.190    0.231
## 29  0.074 0.036  2.071  0.038    0.016    0.161
## 30  0.110 0.035  3.166  0.002    0.054    0.189
## 31 -0.023 0.012 -1.878  0.060   -0.050   -0.001
## 32  0.299 0.100  2.995  0.003    0.108    0.492
## 33  0.293 0.063  4.611  0.000    0.181    0.425
## 34 -0.153 0.033 -4.691  0.000   -0.214   -0.088