10

How can I get a table with all of the latent factors and the loading of each measurement item on all factors? I can't seem to find a way to pull this out of a fit lavaan model. Here is the general code I'm using to generate the model fit.

library(lavaan)
fit <- sem(mySemModel, data=df, std.ov=TRUE, std.lv=TRUE)
summary(fit, fit.measures=TRUE, rsq=TRUE, standardized=TRUE)

I'm looking for the same kind of output that you'd get from an EFA. For example, if I ran the code:

library(psych)
myFA <- fa(tpblatentData, 2)
print(myFA)

I would get something like this:

               PA1   PA2
Qitem1              0.74
Qitem2              0.82
Qitem3              0.87
Qitem4        0.98      
Qitem5        0.94      
Qitem6        0.89      
3
  • You can pull the estimates out using parameterEstimates(fit)
    – user20650
    Commented Feb 25, 2014 at 20:26
  • parameterEstimates(fit) shows me the estimates of the items on the factors that I specified in the model, but it doesn't show me how items load on the other factors (unless I'm missing something).
    – Jim
    Commented Feb 25, 2014 at 21:29
  • More likely i am missing something. Yes you will only get loadings for the factors and items you specify. But I am assuming that you are doing an EFA (in a CFA framework) as you are comparing to fa in the psych package. So in lavaan i assume you will specify each item on each factor. So each estimate in the parameterEstimates returns the loadings on each factor. They are displayed long ways. This is how i would do an esem in Mplus - which is similar. Can you show your model
    – user20650
    Commented Feb 25, 2014 at 22:34

2 Answers 2

22

You can get the standardized loadings of the model in matrix form by using the inspect function from the lavaan package. The following code will return the lambda (factor loadings), theta (observed error covariance matrix), psi (latent covariance matrix), and beta (latent paths) matrices.

inspect(fit,what="std")

It appears from your example that you are looking for the factor loadings, which are in the lambda matrix:

inspect(fit,what="std")$lambda

In like manner, you can extract unstandardized parameters by specifying "est" instead of "std".

6
  • Thanks, i've tried your suggestion, but i found the lambda value is an integer. It should be a decimal number. Commented May 28, 2017 at 3:24
  • All variables in my model are observed, no have laten variable. Commented May 28, 2017 at 4:31
  • 1
    If all your variables are observed, the lambda matrix is irrelevant. Instead, look up the beta matrix: inspect(fit,what = "std")$beta Commented May 29, 2017 at 11:24
  • Thank's Joel, I have a SEM model without latent variable, but I have a problem to find a MLE or lambda, do you have solution for me? :D Commented May 29, 2017 at 11:35
  • I am not sure what you mean. In the context of SEM with lavaan, lambda refers to the matrix of the observed variables' loadings on the latent variables. Because you have no latent variables, the lambda matrix should not matter. Perhaps you are referring to a different meaning of lambda? Commented May 30, 2017 at 11:54
2

I found Joel's answer helpful. Another thing that might help is attributing the loadings result to a variable.

Since the inspect() function returns a list, this for me was useful:

model_loadings <- inspect(model_fit, what = "std")[["lambda"]]

Now I can use these values to calculate other interesting stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.