semPaths 的节点名称大小有问题
Having trouble with node name sizes for semPaths
到目前为止,这是我的结构方程模型的代码:
#### 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")
这给了我这个尚可但不完美的路径图。你可以在这里看到,尽管调整了潜在和清单的大小,但你几乎无法阅读它们:
我的问题是:如何调整文本大小以使其更好地适应每个节点?这可能吗?我的问题是 R 帮助页面并不总是清楚什么可以和不能包含在 semPaths 中,因为它似乎至少松散地基于我收集的 qgraphs。
label.cex 控制节点中文本的大小。你试试
label.cex = 1.5
或调整大小以查看适合
到目前为止,这是我的结构方程模型的代码:
#### 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")
这给了我这个尚可但不完美的路径图。你可以在这里看到,尽管调整了潜在和清单的大小,但你几乎无法阅读它们:
我的问题是:如何调整文本大小以使其更好地适应每个节点?这可能吗?我的问题是 R 帮助页面并不总是清楚什么可以和不能包含在 semPaths 中,因为它似乎至少松散地基于我收集的 qgraphs。
label.cex 控制节点中文本的大小。你试试
label.cex = 1.5
或调整大小以查看适合