This function takes an object returned from the lavaan package's sem or cfa functions and produces a nicely formatted HTML table summarizing the model parameters and fit measures. It allows customization of displayed columns, inclusion of confidence intervals, and choice between standardized and unstandardized estimates.

nice_sem(
  x,
  standardized = TRUE,
  show_fitmeasures = c(CFI = "cfi", TLI = "tli", RMSEA = "rmsea", `RMSEA ci lower` =
    "rmsea.ci.lower", SRMR = "srmr", AIC = "aic", BIC = "bic"),
  remove_cols = NULL,
  show_ci = TRUE,
  round = 2,
  ...
)

Arguments

x

An object returned from the lavaan sem or cfa function.

standardized

If TRUE, standardized estimates are shown.

show_fitmeasures

A named vector with fit measures.

remove_cols

Either column number or column names to be removed.

show_ci

If TRUE, adds columns with 95% confidence intervals.

round

Number of digits to round numeric values.

...

Further arguments passed to the nice_table() function.

Value

An HTML table summarizing the structure equation model.

Details

The function organizes the output into sections for latent variables, regressions, covariances , variances, and intercepts. It also appends key fit measures at the end of the table. Users can specify which columns to remove, whether to show confidence intervals, and whether to display standardized estimates. It leverages the nice_table() function for final formatting, allowing further customization through additional arguments.

The resulting table includes a title and footnote that provide context about the estimation method, optimization algorithm, handling of missing data, and citation information for the lavaan package.

Author

Juergen Wilbert

Examples

nice_sem(lavaan_fit)
Table
Structure equation model
parameter Beta se z p
95% CI
lower upper
Latent variables
remediation → RU_02 0.90 0.01 91.87 <.001 0.88 0.92
remediation → RM_01 0.90 0.01 91.94 <.001 0.88 0.92
remediation → RU_03 0.87 0.01 73.12 <.001 0.85 0.90
remediation → RM_02 0.89 0.01 83.82 <.001 0.87 0.91
development → RE_01 0.91 0.02 59.10 <.001 0.88 0.94
development → RE_02 0.91 0.02 59.26 <.001 0.88 0.94
goal → RZ_02 0.88 0.01 63.27 <.001 0.85 0.90
goal → RZ_01 0.91 0.01 72.00 <.001 0.88 0.93
Covariances
remediation ↔ development 0.59 0.03 18.43 <.001 0.52 0.65
remediation ↔ goal 0.80 0.02 40.24 <.001 0.76 0.84
development ↔ goal 0.74 0.02 30.32 <.001 0.70 0.79
Variances
RU_02 0.19 0.02 10.58 <.001 0.15 0.22
RM_01 0.19 0.02 10.57 <.001 0.15 0.22
RU_03 0.24 0.02 11.55 <.001 0.20 0.28
RM_02 0.21 0.02 10.94 <.001 0.17 0.24
RE_01 0.18 0.03 6.39 <.001 0.12 0.23
RE_02 0.18 0.03 6.33 <.001 0.12 0.23
RZ_02 0.23 0.02 9.59 <.001 0.19 0.28
RZ_01 0.18 0.02 7.84 <.001 0.13 0.22
remediation 1.00 0.00

1.00 1.00
development 1.00 0.00

1.00 1.00
goal 1.00 0.00

1.00 1.00
Intercepts
RU_02 2.94 0.10 30.00 <.001 2.75 3.13
RM_01 2.72 0.09 29.54 <.001 2.54 2.90
RU_03 2.69 0.09 29.45 <.001 2.51 2.87
RM_02 2.48 0.09 28.93 <.001 2.32 2.65
RE_01 3.01 0.10 30.13 <.001 2.82 3.21
RE_02 2.83 0.09 29.77 <.001 2.64 3.01
RZ_02 2.72 0.09 29.54 <.001 2.54 2.90
RZ_01 3.00 0.10 30.11 <.001 2.81 3.20
remediation 0.00 0.00

0.00 0.00
development 0.00 0.00

0.00 0.00
goal 0.00 0.00

0.00 0.00
Modelfit
N parameters 27.00




Observations 554.00




Χ²(17) / p-value 142.89 0.00



CFI 0.97




TLI 0.95




RMSEA 0.12




RMSEA ci lower 0.10




SRMR 0.03




AIC 9644.88




BIC 9761.44




Note. The estimation method employed in this analysis is Maximum Likelihood (ML). The Non-Linear Minimization, Bounded (nlminb) algorithm was applied for optimization. Missing data were addressed using the Full Information Maximum Likelihood (FIML) approach. The analysis was performed with the lavaan package in R (Yves Rosseel, Terrence D. Jorgensen, Luc De Wilde, 2025).
nice_sem(lavaan_fit, standardized = FALSE, show_ci = FALSE)
Table
Structure equation model
parameter est se z p
Latent variables
remediation → RU_02 1.00 0.04 27.13 <.001
remediation → RM_01 1.01 0.04 27.13 <.001
remediation → RU_03 0.94 0.04 25.62 <.001
remediation → RM_02 1.07 0.04 26.55 <.001
development → RE_01 0.99 0.04 25.74 <.001
development → RE_02 0.99 0.04 25.78 <.001
goal → RZ_02 0.99 0.04 25.22 <.001
goal → RZ_01 0.95 0.04 26.55 <.001
Covariances
remediation ↔ development 0.59 0.03 18.43 <.001
remediation ↔ goal 0.80 0.02 40.24 <.001
development ↔ goal 0.74 0.02 30.32 <.001
Variances
RU_02 0.23 0.02 12.25 <.001
RM_01 0.23 0.02 12.23 <.001
RU_03 0.28 0.02 13.34 <.001
RM_02 0.30 0.02 12.66 <.001
RE_01 0.21 0.03 6.71 <.001
RE_02 0.21 0.03 6.65 <.001
RZ_02 0.30 0.03 10.57 <.001
RZ_01 0.20 0.02 8.47 <.001
remediation 1.00 0.00

development 1.00 0.00

goal 1.00 0.00

Intercepts
RU_02 3.27 0.05 69.18 <.001
RM_01 3.03 0.05 64.07 <.001
RU_03 2.89 0.05 63.23 <.001
RM_02 2.98 0.05 58.49 <.001
RE_01 3.30 0.05 70.93 <.001
RE_02 3.07 0.05 66.50 <.001
RZ_02 3.08 0.05 64.09 <.001
RZ_01 3.16 0.04 70.62 <.001
remediation 0.00 0.00

development 0.00 0.00

goal 0.00 0.00

Modelfit
N parameters 27.00


Observations 554.00


Χ²(17) / p-value 142.89 0.00

CFI 0.97


TLI 0.95


RMSEA 0.12


RMSEA ci lower 0.10


SRMR 0.03


AIC 9644.88


BIC 9761.44


Note. The estimation method employed in this analysis is Maximum Likelihood (ML). The Non-Linear Minimization, Bounded (nlminb) algorithm was applied for optimization. Missing data were addressed using the Full Information Maximum Likelihood (FIML) approach. The analysis was performed with the lavaan package in R (Yves Rosseel, Terrence D. Jorgensen, Luc De Wilde, 2025).
nice_sem( lavaan_fit, show_fitmeasures = c( FI = "cfi", TLI = "tli", RMSEA = "rmsea", "SRMR" = "srmr" ), remove_cols = c("se", "z") )
Table
Structure equation model
parameter Beta p
95% CI
lower upper
Latent variables
remediation → RU_02 0.90 <.001 0.88 0.92
remediation → RM_01 0.90 <.001 0.88 0.92
remediation → RU_03 0.87 <.001 0.85 0.90
remediation → RM_02 0.89 <.001 0.87 0.91
development → RE_01 0.91 <.001 0.88 0.94
development → RE_02 0.91 <.001 0.88 0.94
goal → RZ_02 0.88 <.001 0.85 0.90
goal → RZ_01 0.91 <.001 0.88 0.93
Covariances
remediation ↔ development 0.59 <.001 0.52 0.65
remediation ↔ goal 0.80 <.001 0.76 0.84
development ↔ goal 0.74 <.001 0.70 0.79
Variances
RU_02 0.19 <.001 0.15 0.22
RM_01 0.19 <.001 0.15 0.22
RU_03 0.24 <.001 0.20 0.28
RM_02 0.21 <.001 0.17 0.24
RE_01 0.18 <.001 0.12 0.23
RE_02 0.18 <.001 0.12 0.23
RZ_02 0.23 <.001 0.19 0.28
RZ_01 0.18 <.001 0.13 0.22
remediation 1.00
1.00 1.00
development 1.00
1.00 1.00
goal 1.00
1.00 1.00
Intercepts
RU_02 2.94 <.001 2.75 3.13
RM_01 2.72 <.001 2.54 2.90
RU_03 2.69 <.001 2.51 2.87
RM_02 2.48 <.001 2.32 2.65
RE_01 3.01 <.001 2.82 3.21
RE_02 2.83 <.001 2.64 3.01
RZ_02 2.72 <.001 2.54 2.90
RZ_01 3.00 <.001 2.81 3.20
remediation 0.00
0.00 0.00
development 0.00
0.00 0.00
goal 0.00
0.00 0.00
Modelfit
N parameters 27.00


Observations 554.00


Χ²(17) / p-value 142.89 0

FI 0.97


TLI 0.95


RMSEA 0.12


SRMR 0.03


Note. The estimation method employed in this analysis is Maximum Likelihood (ML). The Non-Linear Minimization, Bounded (nlminb) algorithm was applied for optimization. Missing data were addressed using the Full Information Maximum Likelihood (FIML) approach. The analysis was performed with the lavaan package in R (Yves Rosseel, Terrence D. Jorgensen, Luc De Wilde, 2025).