Search code examples
rr-lavaan

How do I get the estimator and optimization method of a lavaan model as a variable?


I have some data to which I have fitted a model in lavaan

fit <- sem(model, full_data)

The summary (summary(fit)) shows the used solver (optimization method as well as estimator), but I can't figure out how to extract that information and store it into a variable; I can only manage to print it as part of the summary. How can I access these two values and store them in a variable?

Any help is appreciated.


Solution

  • If you run str(fit) you can see the structure of fit and all the informations which are saved in the object. In lavaan it is a lot of information, so it is not so easy to find, but in your case you can find your informations in Options, so

    fit@Options$optim.method
    fit@Options$estimator
    

    should give you the information you need and you can store them in a variable.