plot_models_fm {semhelpinghands} | R Documentation |
Plot Models on a Chi-Squares-vs-Dfs Graph
Description
Plot models on a graph with model chi-square against model the degrees of freedom, with lines for equal fit measures.
Usage
plot_models_fm(
...,
fit_measure = c("cfi", "tli", "rmsea"),
fit_values,
line_size = 1,
label_size = 8,
point_size = 5,
position_dodge = 0.5,
include_model_values = FALSE,
include_baseline = FALSE
)
Arguments
... |
The lavaan::lavaan objects to be plotted. Can also be a named list of the lavaan::lavaan objects. If it is as list, it must be named and the names will be used in the plot. |
fit_measure |
A length-one
character vector of the fit measures
to use to plot the lines. Only
supports |
fit_values |
A numeric vector
of the values of the fit measure
used to plot the lines. The default
values are |
line_size |
The size of the lines. Default is 1. |
label_size |
The size of the model names. Default is 8. |
point_size |
The size of the point representing a model. Default is 2. |
position_dodge |
Offsetting the
label of a model from the point.
Default is .5. Used by
|
include_model_values |
If |
include_baseline |
If |
Details
This function plots models based on their model chi-squares and model degrees of freedoms.It can also add lines for chi-square-df combination with equal values on selected fit measures. Currently supports CFI, TLI, and RMSEA.
Value
Return a ggplot2::ggplot()
output that can be further modified.
Author(s)
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
See Also
Examples
library(lavaan)
# From the help page of modificationIndices
HS.model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
fit <- cfa(HS.model, data = HolzingerSwineford1939)
modindices(fit, sort = TRUE, op = "=~")
fit2 <- update(fit, add = "visual =~ x9")
fit3 <- update(fit, add = "textual =~ x3\nvisual =~ x7")
models <- list(Initial = fit,
Model_2 = fit2,
Model_3 = fit3)
fit_cfi <- sapply(models, fitMeasures, fit.measures = "cfi")
fit_tli <- sapply(models, fitMeasures, fit.measures = "tli")
fit_rmsea <- sapply(models, fitMeasures, fit.measures = "rmsea")
# Supply the models as arguments
plot_models_fm(fit, fit2, fit3)
# Plot lines for selected values on a fit measure (CFI by default)
plot_models_fm(fit, fit2, fit3, fit_values = c(.90, .925, .95, fit_cfi))
# Plot the models' values on the fit measures
plot_models_fm(fit, fit2, fit3, include_model_values = TRUE)
# Supply the models as a named list
plot_models_fm(list(A = fit, B = fit2, C = fit3),
fit_values = c(.90, .925, .95))
# Plot the models, fit measure set to TLI
plot_models_fm(fit, fit2, fit3, fit_measure = "tli")
plot_models_fm(fit, fit2, fit3, fit_measure = "tli",
fit_values = c(.90, .925, .95, fit_tli))
plot_models_fm(fit, fit2, fit3, fit_measure = "tli",
include_model_values = TRUE)
# Plot the models, fit measure set to RMSEA
plot_models_fm(fit, fit2, fit3, fit_measure = "rmsea")
plot_models_fm(fit, fit2, fit3, fit_measure = "rmsea",
include_model_values = TRUE)