Inspects the RAM matrices (A, S, M) of an MxModel and generates the
extended lavaan syntax string that fastsem_fit() expects. This is
called internally by run_fastsem() but is also useful for inspection
or for further hand-editing before fitting.
Arguments
- model
- include_map
Logical (default
FALSE). WhenTRUEreturns a list with two elements:syntaxThe lavaan syntax string.
param_mapNamed character vector mapping fastsem structural names (e.g.
"f->y1") to OpenMx free-parameter labels (e.g."g_to_y1"). Used byrun_fastsem()for inject-back.
Translations performed
- A matrix (directional)
Latent → manifest paths become
factor =~ indicatorlines. Latent → latent become~regression lines. Manifest → manifest become~regression lines. A label starting with"data."is treated as a definition variable and emitted asdata.colname * indicator.- S matrix (symmetric)
Free diagonal entries →
var ~~ var(withstart()or label if set). Fixed non-zero diagonal entries →var ~~ value*var. Free off-diagonal →a ~~ bcovariance.- M matrix (means)
Free entries →
var ~ 1(withstart()if the starting value is non-zero). Fixed non-zero entries →var ~ value*1.- Bounds
S@lbound/S@ubound/A@lbound/A@ubound→label > lo/label < hilines. Variance lower bounds of 0 are suppressed because fastsem's log-variance parameterisation already prevents negative variances.- Equality constraints
Labels appearing on more than one free parameter are emitted as
label*var, which fastsem treats as an equality constraint.
See also
run_fastsem() to fit and inject back in one step.
Examples
if (FALSE) { # \dontrun{
library(umx)
df <- as.data.frame(scale(iris[, c(1, 3, 4)]))
names(df) <- c("sl", "pl", "pw")
m <- umxRAM("CFA",
umxPath(from = "g", to = c("sl", "pl", "pw")),
umxPath(v1m0 = "g"),
umxPath(var = c("sl", "pl", "pw")),
data = df, autoRun = FALSE
)
# Inspect the generated syntax
cat(umx_to_lavaan(m))
# Include the parameter map for custom inject-back
out <- umx_to_lavaan(m, include_map = TRUE)
str(out$param_map)
} # }