library(flextable)
library(DiagrammeR)
library(lavaan)
library(tidyverse)
At this point, I will construct an overall mediation model.
Let’s take a look at the boxes-and-arrows.
grViz("
digraph mediation {
graph [overlap = true,
rankdir = LR,
bgcolor = '#222222']
node [shape = box,
color = wheat,
fontcolor = wheat]
edge [color = wheat,
fontcolor = wheat]
disclosure->'affective trust' [label = <a<SUB>aff</SUB>>]
disclosure->liking [label = 'c′']
disclosure->'cognitive trust' [label = <a<SUB>cog</SUB>>]
'affective trust'->liking [label = <b<SUB>aff</SUB>>]
'cognitive trust'->liking [label = <b<SUB>cog</SUB>>]
}
")
Now, I’ll build the actual data model. My understanding is that I can follow the classic procedure, but control for cognitive trust when testing affective trust—and vice versa.
<- readRDS(file.path("..", "data", "hq-data.rds"))
data <- readRDS("format.rds") formatAsTable
<- "# measurement model
model.aff aff =~ aff1 + aff2 + aff3 + aff4
lik =~ lik1 + lik2 + lik3.r + lik4.r
# structural model
aff ~ affa*disclose
lik ~ affb*aff
lik ~ cprime*disclose
ind_fx := affa*affb
tot_fx := affa*affb + cprime"
<- model.aff %>%
fit.aff sem(data)
%>%
fit.aff %>%
parameterEstimates filter(op %in% c("~", ":=")) %>%
formatAsTable
lhs | op | rhs | label | est | se | z | pvalue | ci.lower | ci.upper |
aff | ~ | disclose | affa | 0.65 | 0.08 | 7.72 | 0.00 | 0.49 | 0.82 |
lik | ~ | aff | affb | 0.90 | 0.04 | 21.84 | 0.00 | 0.82 | 0.98 |
lik | ~ | disclose | cprime | -0.07 | 0.09 | -0.80 | 0.43 | -0.24 | 0.10 |
ind_fx | := | affa*affb | ind_fx | 0.58 | 0.08 | 7.66 | 0.00 | 0.44 | 0.73 |
tot_fx | := | affa*affb+cprime | tot_fx | 0.51 | 0.11 | 4.75 | 0.00 | 0.30 | 0.73 |
\(c\prime\) goes to zero…looks like full mediation!
<- "# measurement model
model.cog cog =~ cog1 + cog2 + cog3
lik =~ lik1 + lik2 + lik3.r + lik4.r
# structural model
cog ~ coga*disclose
lik ~ cogb*cog
lik ~ cprime*disclose
ind_fx := coga*cogb
tot_fx := coga*cogb + cprime"
<- model.cog %>%
fit.cog sem(data)
%>%
fit.cog %>%
parameterEstimates filter(op %in% c("~", ":=")) %>%
formatAsTable
lhs | op | rhs | label | est | se | z | pvalue | ci.lower | ci.upper |
cog | ~ | disclose | coga | 0.38 | 0.11 | 3.57 | 0.00 | 0.17 | 0.59 |
lik | ~ | cog | cogb | 0.70 | 0.04 | 15.62 | 0.00 | 0.61 | 0.79 |
lik | ~ | disclose | cprime | 0.19 | 0.09 | 2.29 | 0.02 | 0.03 | 0.36 |
ind_fx | := | coga*cogb | ind_fx | 0.27 | 0.08 | 3.50 | 0.00 | 0.12 | 0.42 |
tot_fx | := | coga*cogb+cprime | tot_fx | 0.46 | 0.10 | 4.69 | 0.00 | 0.27 | 0.65 |
\(c\prime\) doesn’t go to zero, so we can’t say we have full mediation. But \(a_{cog}\) and \(b_{cog}\) are significant, so I think that means partial mediation.
<- "# measurement model
model.tru aff =~ aff1 + aff2 + aff3 + aff4
cog =~ cog1 + cog2 + cog3
lik =~ lik1 + lik2 + lik3.r + lik4.r
# structural model
aff ~ affa*disclose
cog ~ coga*disclose
lik ~ affb*aff + cogb*cog
lik ~ cprime*disclose
ind_fx := affa*affb + coga*cogb
tot_fx := affa*affb + coga*cogb + cprime"
<- model.tru %>%
fit.tru sem(data)
%>%
fit.tru %>%
parameterEstimates filter(op %in% c("~", ":=")) %>%
formatAsTable
lhs | op | rhs | label | est | se | z | pvalue | ci.lower | ci.upper |
aff | ~ | disclose | affa | 0.65 | 0.08 | 7.71 | 0.00 | 0.49 | 0.82 |
cog | ~ | disclose | coga | 0.38 | 0.11 | 3.57 | 0.00 | 0.17 | 0.59 |
lik | ~ | aff | affb | 0.88 | 0.04 | 21.65 | 0.00 | 0.80 | 0.96 |
lik | ~ | cog | cogb | 0.76 | 0.05 | 16.37 | 0.00 | 0.67 | 0.85 |
lik | ~ | disclose | cprime | -0.36 | 0.11 | -3.33 | 0.00 | -0.57 | -0.15 |
ind_fx | := | affa*affb+coga*cogb | ind_fx | 0.86 | 0.14 | 6.20 | 0.00 | 0.59 | 1.14 |
tot_fx | := | affa*affb+coga*cogb+cprime | tot_fx | 0.51 | 0.11 | 4.74 | 0.00 | 0.30 | 0.71 |
That’s interesting! Trust doesn’t fully mediate the effect of disclosure on liking—it inconsistently mediates it. That is, disclosure has a significantly negative effect on liking when controlling for trust.
I’m not sure what would explain that. Maybe something like my hypothesis (that disclosure calls attention to negative aspects of ADHD) is true, but cognitive trust was the wrong construct to use. Or it could be that disclosure makes someone trustworthy, but otherwise makes them look bad (annoying, poor social skills, oversharing, that kind of thing). There’s no way to know for sure without more studies.
Also, as predicted, affective trust is a stronger mediator than cognitive trust.
<- "# measurement model
model.com tru =~ aff1 + aff2 + aff3 + aff4 + cog1 + cog2 + cog3
lik =~ lik1 + lik2 + lik3.r + lik4.r
# structural model
tru ~ a*disclose
lik ~ b*tru
lik ~ cprime*disclose
ind_fx := a*b
tot_fx := a*b + cprime"
<- model.com %>%
fit.com sem(data)
%>%
fit.com %>%
parameterEstimates formatAsTable
lhs | op | rhs | label | est | se | z | pvalue | ci.lower | ci.upper |
tru | =~ | aff1 | 1.00 | 0.00 | 1.00 | 1.00 | |||
tru | =~ | aff2 | 1.10 | 0.04 | 26.43 | 0.00 | 1.02 | 1.18 | |
tru | =~ | aff3 | 1.19 | 0.04 | 26.78 | 0.00 | 1.10 | 1.27 | |
tru | =~ | aff4 | 1.12 | 0.04 | 27.23 | 0.00 | 1.03 | 1.20 | |
tru | =~ | cog1 | 1.05 | 0.04 | 23.55 | 0.00 | 0.97 | 1.14 | |
tru | =~ | cog2 | 0.78 | 0.06 | 13.77 | 0.00 | 0.67 | 0.89 | |
tru | =~ | cog3 | 0.66 | 0.06 | 11.88 | 0.00 | 0.55 | 0.77 | |
lik | =~ | lik1 | 1.00 | 0.00 | 1.00 | 1.00 | |||
lik | =~ | lik2 | 0.81 | 0.03 | 23.60 | 0.00 | 0.74 | 0.88 | |
lik | =~ | lik3.r | 0.46 | 0.05 | 9.88 | 0.00 | 0.37 | 0.55 | |
lik | =~ | lik4.r | 0.76 | 0.04 | 17.44 | 0.00 | 0.68 | 0.85 | |
tru | ~ | disclose | a | 0.55 | 0.08 | 7.00 | 0.00 | 0.40 | 0.70 |
lik | ~ | tru | b | 1.00 | 0.04 | 23.23 | 0.00 | 0.92 | 1.09 |
lik | ~ | disclose | cprime | -0.05 | 0.08 | -0.57 | 0.57 | -0.21 | 0.11 |
aff1 | | | t1 | -0.94 | 0.09 | -9.96 | 0.00 | -1.12 | -0.75 | |
aff1 | | | t2 | -0.47 | 0.08 | -5.56 | 0.00 | -0.63 | -0.30 | |
aff1 | | | t3 | 0.27 | 0.08 | 3.31 | 0.00 | 0.11 | 0.43 | |
aff1 | | | t4 | 1.29 | 0.09 | 14.62 | 0.00 | 1.12 | 1.47 | |
aff2 | | | t1 | -1.49 | 0.12 | -12.19 | 0.00 | -1.73 | -1.25 | |
aff2 | | | t2 | -0.90 | 0.10 | -9.43 | 0.00 | -1.08 | -0.71 | |
aff2 | | | t3 | -0.05 | 0.08 | -0.60 | 0.55 | -0.21 | 0.11 | |
aff2 | | | t4 | 1.08 | 0.09 | 11.82 | 0.00 | 0.90 | 1.26 | |
aff3 | | | t1 | -1.43 | 0.12 | -11.61 | 0.00 | -1.67 | -1.19 | |
aff3 | | | t2 | -0.62 | 0.09 | -6.87 | 0.00 | -0.80 | -0.45 | |
aff3 | | | t3 | 0.23 | 0.09 | 2.69 | 0.01 | 0.06 | 0.40 | |
aff3 | | | t4 | 1.35 | 0.10 | 13.82 | 0.00 | 1.16 | 1.55 | |
aff4 | | | t1 | -1.62 | 0.14 | -11.67 | 0.00 | -1.89 | -1.35 | |
aff4 | | | t2 | -0.84 | 0.10 | -8.75 | 0.00 | -1.03 | -0.65 | |
aff4 | | | t3 | 0.23 | 0.09 | 2.65 | 0.01 | 0.06 | 0.40 | |
aff4 | | | t4 | 1.24 | 0.10 | 12.78 | 0.00 | 1.05 | 1.43 | |
cog1 | | | t1 | -2.26 | 0.22 | -10.23 | 0.00 | -2.69 | -1.82 | |
cog1 | | | t2 | -1.27 | 0.11 | -11.85 | 0.00 | -1.48 | -1.06 | |
cog1 | | | t3 | -0.12 | 0.08 | -1.40 | 0.16 | -0.28 | 0.05 | |
cog1 | | | t4 | 0.98 | 0.09 | 10.38 | 0.00 | 0.79 | 1.16 | |
cog2 | | | t1 | -1.81 | 0.14 | -13.13 | 0.00 | -2.08 | -1.54 | |
cog2 | | | t2 | -0.80 | 0.09 | -9.15 | 0.00 | -0.97 | -0.63 | |
cog2 | | | t3 | -0.25 | 0.08 | -2.96 | 0.00 | -0.41 | -0.08 | |
cog2 | | | t4 | 0.75 | 0.09 | 8.52 | 0.00 | 0.58 | 0.93 | |
cog3 | | | t1 | -1.41 | 0.11 | -12.45 | 0.00 | -1.64 | -1.19 | |
cog3 | | | t2 | -0.53 | 0.09 | -6.14 | 0.00 | -0.70 | -0.36 | |
cog3 | | | t3 | 0.25 | 0.08 | 2.98 | 0.00 | 0.09 | 0.42 | |
cog3 | | | t4 | 1.16 | 0.10 | 11.65 | 0.00 | 0.96 | 1.36 | |
lik1 | | | t1 | -2.25 | 0.22 | -10.30 | 0.00 | -2.68 | -1.82 | |
lik1 | | | t2 | -1.57 | 0.13 | -12.48 | 0.00 | -1.81 | -1.32 | |
lik1 | | | t3 | -0.16 | 0.08 | -1.85 | 0.06 | -0.32 | 0.01 | |
lik1 | | | t4 | 1.01 | 0.09 | 10.86 | 0.00 | 0.83 | 1.20 | |
lik2 | | | t1 | -1.84 | 0.16 | -11.68 | 0.00 | -2.15 | -1.53 | |
lik2 | | | t2 | -1.30 | 0.11 | -11.63 | 0.00 | -1.52 | -1.08 | |
lik2 | | | t3 | -0.02 | 0.08 | -0.30 | 0.77 | -0.19 | 0.14 | |
lik2 | | | t4 | 1.12 | 0.09 | 12.03 | 0.00 | 0.94 | 1.31 | |
lik3.r | | | t1 | -1.84 | 0.16 | -11.76 | 0.00 | -2.14 | -1.53 | |
lik3.r | | | t2 | -1.11 | 0.10 | -10.93 | 0.00 | -1.30 | -0.91 | |
lik3.r | | | t3 | -0.47 | 0.09 | -5.34 | 0.00 | -0.65 | -0.30 | |
lik3.r | | | t4 | 0.59 | 0.09 | 6.54 | 0.00 | 0.41 | 0.76 | |
lik4.r | | | t1 | -1.83 | 0.15 | -12.27 | 0.00 | -2.12 | -1.54 | |
lik4.r | | | t2 | -0.84 | 0.09 | -9.26 | 0.00 | -1.02 | -0.67 | |
lik4.r | | | t3 | 0.01 | 0.09 | 0.12 | 0.90 | -0.16 | 0.18 | |
aff1 | ~~ | aff1 | 0.47 | 0.00 | 0.47 | 0.47 | |||
aff2 | ~~ | aff2 | 0.36 | 0.00 | 0.36 | 0.36 | |||
aff3 | ~~ | aff3 | 0.25 | 0.00 | 0.25 | 0.25 | |||
aff4 | ~~ | aff4 | 0.34 | 0.00 | 0.34 | 0.34 | |||
cog1 | ~~ | cog1 | 0.41 | 0.00 | 0.41 | 0.41 | |||
cog2 | ~~ | cog2 | 0.68 | 0.00 | 0.68 | 0.68 | |||
cog3 | ~~ | cog3 | 0.77 | 0.00 | 0.77 | 0.77 | |||
lik1 | ~~ | lik1 | 0.19 | 0.00 | 0.19 | 0.19 | |||
lik2 | ~~ | lik2 | 0.46 | 0.00 | 0.46 | 0.46 | |||
lik3.r | ~~ | lik3.r | 0.83 | 0.00 | 0.83 | 0.83 | |||
lik4.r | ~~ | lik4.r | 0.53 | 0.00 | 0.53 | 0.53 | |||
tru | ~~ | tru | 0.53 | 0.04 | 13.85 | 0.00 | 0.45 | 0.60 | |
lik | ~~ | lik | 0.28 | 0.04 | 8.05 | 0.00 | 0.21 | 0.35 | |
disclose | ~~ | disclose | 0.25 | 0.00 | 0.25 | 0.25 | |||
aff1 | ~*~ | aff1 | 1.00 | 0.00 | 1.00 | 1.00 | |||
aff2 | ~*~ | aff2 | 1.00 | 0.00 | 1.00 | 1.00 | |||
aff3 | ~*~ | aff3 | 1.00 | 0.00 | 1.00 | 1.00 | |||
aff4 | ~*~ | aff4 | 1.00 | 0.00 | 1.00 | 1.00 | |||
cog1 | ~*~ | cog1 | 1.00 | 0.00 | 1.00 | 1.00 | |||
cog2 | ~*~ | cog2 | 1.00 | 0.00 | 1.00 | 1.00 | |||
cog3 | ~*~ | cog3 | 1.00 | 0.00 | 1.00 | 1.00 | |||
lik1 | ~*~ | lik1 | 1.00 | 0.00 | 1.00 | 1.00 | |||
lik2 | ~*~ | lik2 | 1.00 | 0.00 | 1.00 | 1.00 | |||
lik3.r | ~*~ | lik3.r | 1.00 | 0.00 | 1.00 | 1.00 | |||
lik4.r | ~*~ | lik4.r | 1.00 | 0.00 | 1.00 | 1.00 | |||
aff1 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
aff2 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
aff3 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
aff4 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
cog1 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
cog2 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
cog3 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
lik1 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
lik2 | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
lik3.r | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
lik4.r | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
disclose | ~1 | 0.52 | 0.00 | 0.52 | 0.52 | ||||
tru | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
lik | ~1 | 0.00 | 0.00 | 0.00 | 0.00 | ||||
ind_fx | := | a*b | ind_fx | 0.55 | 0.08 | 6.90 | 0.00 | 0.40 | 0.71 |
tot_fx | := | a*b+cprime | tot_fx | 0.50 | 0.11 | 4.74 | 0.00 | 0.30 | 0.71 |
<- 'tru1 =~ aff1 + aff2 + 0*aff3 + aff4 + cog1 + cog2 + cog3 + cog4.r
model.efa tru2 =~ aff1 + aff2 + aff3 + aff4 + cog1 + 0*cog2 + cog3 + cog4.r'
<- model.efa %>%
fit.efa cfa(data, std.lv=T, std.ov=T)
%>%
fit.efa summary
## lavaan 0.6-8 ended normally after 32 iterations
##
## Estimator DWLS
## Optimization method NLMINB
## Number of model parameters 47
##
## Number of observations 403
##
## Model Test User Model:
## Standard Robust
## Test Statistic 6.570 22.623
## Degrees of freedom 13 13
## P-value (Chi-square) 0.923 0.046
## Scaling correction factor 0.310
## Shift parameter 1.417
## simple second-order correction
##
## Parameter Estimates:
##
## Standard errors Robust.sem
## Information Expected
## Information saturated (h1) model Unstructured
##
## Latent Variables:
## Estimate Std.Err z-value P(>|z|)
## tru1 =~
## aff1 -0.188 0.050 -3.773 0.000
## aff2 -0.012 0.045 -0.256 0.798
## aff3 0.000
## aff4 0.047 0.047 1.018 0.309
## cog1 0.456 0.048 9.412 0.000
## cog2 0.954 0.045 21.214 0.000
## cog3 0.327 0.045 7.274 0.000
## cog4.r 0.455 0.056 8.190 0.000
## tru2 =~
## aff1 0.900 0.028 32.287 0.000
## aff2 0.840 0.025 34.002 0.000
## aff3 0.904 0.012 74.995 0.000
## aff4 0.804 0.026 30.657 0.000
## cog1 0.468 0.042 11.153 0.000
## cog2 0.000
## cog3 0.295 0.044 6.679 0.000
## cog4.r -0.250 0.053 -4.695 0.000
##
## Covariances:
## Estimate Std.Err z-value P(>|z|)
## tru1 ~~
## tru2 0.442 0.052 8.424 0.000
##
## Intercepts:
## Estimate Std.Err z-value P(>|z|)
## .aff1 0.000
## .aff2 0.000
## .aff3 0.000
## .aff4 0.000
## .cog1 0.000
## .cog2 0.000
## .cog3 0.000
## .cog4.r 0.000
## tru1 0.000
## tru2 0.000
##
## Thresholds:
## Estimate Std.Err z-value P(>|z|)
## aff1|t1 -1.231 0.083 -14.800 0.000
## aff1|t2 -0.803 0.070 -11.406 0.000
## aff1|t3 -0.134 0.063 -2.139 0.032
## aff1|t4 0.829 0.071 11.683 0.000
## aff2|t1 -1.726 0.111 -15.488 0.000
## aff2|t2 -1.143 0.080 -14.310 0.000
## aff2|t3 -0.333 0.064 -5.214 0.000
## aff2|t4 0.753 0.069 10.848 0.000
## aff3|t1 -1.726 0.111 -15.488 0.000
## aff3|t2 -0.959 0.074 -12.932 0.000
## aff3|t3 -0.172 0.063 -2.735 0.006
## aff3|t4 0.856 0.072 11.956 0.000
## aff4|t1 -1.884 0.125 -15.029 0.000
## aff4|t2 -1.119 0.079 -14.160 0.000
## aff4|t3 -0.103 0.063 -1.642 0.101
## aff4|t4 0.847 0.071 11.865 0.000
## cog1|t1 -2.435 0.208 -11.686 0.000
## cog1|t2 -1.480 0.095 -15.576 0.000
## cog1|t3 -0.359 0.064 -5.610 0.000
## cog1|t4 0.704 0.068 10.281 0.000
## cog2|t1 -1.884 0.125 -15.029 0.000
## cog2|t2 -0.874 0.072 -12.137 0.000
## cog2|t3 -0.326 0.064 -5.115 0.000
## cog2|t4 0.673 0.068 9.901 0.000
## cog3|t1 -1.518 0.097 -15.617 0.000
## cog3|t2 -0.642 0.067 -9.518 0.000
## cog3|t3 0.140 0.063 2.238 0.025
## cog3|t4 1.041 0.077 13.606 0.000
## cog4.r|t1 -1.131 0.079 -14.235 0.000
## cog4.r|t2 -0.009 0.063 -0.149 0.881
## cog4.r|t3 0.560 0.066 8.455 0.000
## cog4.r|t4 1.480 0.095 15.576 0.000
##
## Variances:
## Estimate Std.Err z-value P(>|z|)
## .aff1 0.305
## .aff2 0.302
## .aff3 0.183
## .aff4 0.317
## .cog1 0.385
## .cog2 0.091
## .cog3 0.721
## .cog4.r 0.831
## tru1 1.000
## tru2 1.000
##
## Scales y*:
## Estimate Std.Err z-value P(>|z|)
## aff1 1.000
## aff2 1.000
## aff3 1.000
## aff4 1.000
## cog1 1.000
## cog2 1.000
## cog3 1.000
## cog4.r 1.000
<- "aff =~ aff1 + aff2 + aff3 + aff4
model.cor cog =~ cog1 + cog2 + cog3 + cog4
aff ~ cog"
<- model.cor %>%
fit.cor cfa(data)
%>%
fit.cor standardizedSolution
## lhs op rhs est.std se z pvalue ci.lower ci.upper
## 1 aff =~ aff1 0.795 0.022 36.076 0.000 0.752 0.838
## 2 aff =~ aff2 0.839 0.017 49.129 0.000 0.805 0.872
## 3 aff =~ aff3 0.907 0.012 72.631 0.000 0.883 0.932
## 4 aff =~ aff4 0.834 0.016 50.642 0.000 0.801 0.866
## 5 cog =~ cog1 0.930 0.028 33.291 0.000 0.875 0.985
## 6 cog =~ cog2 0.660 0.036 18.199 0.000 0.589 0.731
## 7 cog =~ cog3 0.575 0.041 13.967 0.000 0.494 0.655
## 8 cog =~ cog4 -0.107 0.049 -2.190 0.029 -0.203 -0.011
## 9 aff ~ cog 0.687 0.033 20.663 0.000 0.622 0.752
## 10 aff1 | t1 -1.231 0.083 -14.800 0.000 -1.394 -1.068
## 11 aff1 | t2 -0.803 0.070 -11.406 0.000 -0.941 -0.665
## 12 aff1 | t3 -0.134 0.063 -2.139 0.032 -0.257 -0.011
## 13 aff1 | t4 0.829 0.071 11.683 0.000 0.690 0.968
## 14 aff2 | t1 -1.726 0.111 -15.488 0.000 -1.944 -1.507
## 15 aff2 | t2 -1.143 0.080 -14.310 0.000 -1.299 -0.986
## 16 aff2 | t3 -0.333 0.064 -5.214 0.000 -0.458 -0.208
## 17 aff2 | t4 0.753 0.069 10.848 0.000 0.617 0.889
## 18 aff3 | t1 -1.726 0.111 -15.488 0.000 -1.944 -1.507
## 19 aff3 | t2 -0.959 0.074 -12.932 0.000 -1.105 -0.814
## 20 aff3 | t3 -0.172 0.063 -2.735 0.006 -0.295 -0.049
## 21 aff3 | t4 0.856 0.072 11.956 0.000 0.716 0.996
## 22 aff4 | t1 -1.884 0.125 -15.029 0.000 -2.130 -1.638
## 23 aff4 | t2 -1.119 0.079 -14.160 0.000 -1.274 -0.964
## 24 aff4 | t3 -0.103 0.063 -1.642 0.101 -0.226 0.020
## 25 aff4 | t4 0.847 0.071 11.865 0.000 0.707 0.987
## 26 cog1 | t1 -2.435 0.208 -11.686 0.000 -2.844 -2.027
## 27 cog1 | t2 -1.480 0.095 -15.576 0.000 -1.666 -1.293
## 28 cog1 | t3 -0.359 0.064 -5.610 0.000 -0.484 -0.234
## 29 cog1 | t4 0.704 0.068 10.281 0.000 0.570 0.838
## 30 cog2 | t1 -1.884 0.125 -15.029 0.000 -2.130 -1.638
## 31 cog2 | t2 -0.874 0.072 -12.137 0.000 -1.015 -0.733
## 32 cog2 | t3 -0.326 0.064 -5.115 0.000 -0.451 -0.201
## 33 cog2 | t4 0.673 0.068 9.901 0.000 0.539 0.806
## 34 cog3 | t1 -1.518 0.097 -15.617 0.000 -1.708 -1.327
## 35 cog3 | t2 -0.642 0.067 -9.518 0.000 -0.774 -0.510
## 36 cog3 | t3 0.140 0.063 2.238 0.025 0.017 0.263
## 37 cog3 | t4 1.041 0.077 13.606 0.000 0.891 1.191
## 38 cog4 | t1 -1.480 0.095 -15.576 0.000 -1.666 -1.293
## 39 cog4 | t2 -0.560 0.066 -8.455 0.000 -0.689 -0.430
## 40 cog4 | t3 0.009 0.063 0.149 0.881 -0.113 0.132
## 41 cog4 | t4 1.131 0.079 14.235 0.000 0.975 1.287
## 42 aff1 ~~ aff1 0.368 0.035 10.485 0.000 0.299 0.436
## 43 aff2 ~~ aff2 0.297 0.029 10.354 0.000 0.240 0.353
## 44 aff3 ~~ aff3 0.177 0.023 7.789 0.000 0.132 0.221
## 45 aff4 ~~ aff4 0.305 0.027 11.113 0.000 0.251 0.359
## 46 cog1 ~~ cog1 0.135 0.052 2.590 0.010 0.033 0.237
## 47 cog2 ~~ cog2 0.564 0.048 11.777 0.000 0.470 0.658
## 48 cog3 ~~ cog3 0.670 0.047 14.174 0.000 0.577 0.763
## 49 cog4 ~~ cog4 0.989 0.010 94.258 0.000 0.968 1.009
## 50 aff ~~ aff 0.528 0.046 11.553 0.000 0.438 0.617
## 51 cog ~~ cog 1.000 0.000 NA NA 1.000 1.000
## 52 aff1 ~*~ aff1 1.000 0.000 NA NA 1.000 1.000
## 53 aff2 ~*~ aff2 1.000 0.000 NA NA 1.000 1.000
## 54 aff3 ~*~ aff3 1.000 0.000 NA NA 1.000 1.000
## 55 aff4 ~*~ aff4 1.000 0.000 NA NA 1.000 1.000
## 56 cog1 ~*~ cog1 1.000 0.000 NA NA 1.000 1.000
## 57 cog2 ~*~ cog2 1.000 0.000 NA NA 1.000 1.000
## 58 cog3 ~*~ cog3 1.000 0.000 NA NA 1.000 1.000
## 59 cog4 ~*~ cog4 1.000 0.000 NA NA 1.000 1.000
## 60 aff1 ~1 0.000 0.000 NA NA 0.000 0.000
## 61 aff2 ~1 0.000 0.000 NA NA 0.000 0.000
## 62 aff3 ~1 0.000 0.000 NA NA 0.000 0.000
## 63 aff4 ~1 0.000 0.000 NA NA 0.000 0.000
## 64 cog1 ~1 0.000 0.000 NA NA 0.000 0.000
## 65 cog2 ~1 0.000 0.000 NA NA 0.000 0.000
## 66 cog3 ~1 0.000 0.000 NA NA 0.000 0.000
## 67 cog4 ~1 0.000 0.000 NA NA 0.000 0.000
## 68 aff ~1 0.000 0.000 NA NA 0.000 0.000
## 69 cog ~1 0.000 0.000 NA NA 0.000 0.000
<- "aff =~ aff1 + aff2 + aff3 + aff4
model.cfa cog =~ cog1 + cog2 + cog3 + cog4.r
lik =~ lik1 + lik2 + lik3.r + lik4.r"
<- model.cfa %>%
fit.cfa cfa(data)
<- fit.cfa %>%
data %>%
lavPredict %>%
as_tibble mutate(id = row_number()) %>%
inner_join(data, "id")
%>%
data saveRDS(file.path("..", "data", "pred-data.rds"))
<- lm(lik ~ disclose + aff + cog, data)
fit.vif
library(car)
%>%
fit.vif vif
## disclose aff cog
## 1.001949 2.538526 2.539831
Output document:
options(knitr.duplicate.label = "allow")
::render("mediation.Rmd",
rmarkdownoutput_dir = file.path("..", "github", "thesis"))