Description Usage Arguments Value Examples
This function plots a classic coefficient plot for a structural equation model. More ggplot functions (e.g., theme, labs, etc.) can be passed to the resulting object.
1 2 3 4 5 6 7 8 |
object |
An object of class |
effect |
Vector of specific effects in the model (need to be labelled in the original model) |
labels |
A logical value specifying whether only effects with labels should be plotted |
y_limits |
Change the limits of the x-axis. |
y_intercept |
Defaults to a dashed vertical line at y = 0. |
regression |
A logical value specifying whether only regressions should be plotted |
A ggplot object that can be further customized using standard ggplot elements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(lavaan)
model <- '
# latent variables
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
# regressions
dem60 ~ a*ind60
dem65 ~ b*ind60 + c*dem60
# residual covariances
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8
'
fit <- sem(model,
data = PoliticalDemocracy)
# Creating output table
coeff_plot(fit, regression = T, y_limits = c(-1,2.5)) + theme_minimal()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.