So far, this is the code I have for my structural equation model:
#### Libraries ####
library(lavaan)
library(semPlot)
#### Cov Matrix ####
# Load
lower <- "
2.60
0.74 1.20
0.66 0.52 4.50
0.64 0.57 2.46 4.54
0.64 0.61 1.22 1.33 2.28
0.84 0.68 1.01 0.91 1.68 2.44
0.63 0.59 0.81 0.89 1.42 1.82 3.11
"
# Save
cov <- getCov(lower, lower=T)
#### Model ####
model <- "
# Latent variables:
Happy =~ V5 V6 V7
Prosoc =~ V1 V2
Recog =~ V3 V4
# Regressions:
Happy ~ a*Recog
Happy ~ b*Prosoc
Recog ~ c*Prosoc
# Indirects:
Direct := a
Indirect := a*c
Total := Direct Indirect
"
#### Fit ####
fit <- sem(model, sample.cov = cov, sample.nobs = 243)
#### Summary ####
summary(fit, fit.measures = T, standardized =T)
#### Plot ####
# Labels:
label <- c("H1","H2","H3","P1","P2","R1","R2","Happy","Prosoc","Recog")
semPaths(fit,
color = "lightblue",
theme="colorblind",
whatLabels = "std",
style = "lisrel",
sizeLat = 10,
sizeLat2 = 10,
sizeMan = 7,
edge.color = "steelblue",
edge.label.cex = 1.5,
rotation = 2,
layout = "tree2",
intercepts = T,
residuals = T,
curve = 2,
title = T,
title.color = "black",
cardinal = "lat cov",
residScale = 15,
curvePivot = T,
nodeLabels = label,
mar = c(2,5,2,5.5))
#### Title ####
title("DF = 11, Chi = 22.641, P < 0.02
CFI: .979, TLI: .959, RMSEA: .066, SRMR: .035")
Which gives me this passable, but not perfect path diagram. You can see here that despite resizing the latents and manifests, you can barely read them if at all:
My question is: how can I resize the text so it can better fit in each node? Is that even possible? My problem is that the R help page isn't always clear what can and can't be included in semPaths, as it seems at least loosely based off qgraphs from what I gather.
CodePudding user response:
label.cex controls size of text in nodes. You try
label.cex = 1.5
or resize to see what fits