I’m trying to do a confirmatory factor analysis using lavaan, but I’m running into issues. I’ve set up my model like this:
model_spec <- '
Factor1: F1_1, F1_2, F1_3, F1_4, F1_5
Factor2: F2_1, F2_2, F2_3, F2_4, F2_5
Factor3: F3_1, F3_2, F3_3, F3_4, F3_5
'
result <- cfa(model_spec, auto.var = TRUE)
But when I try to run it, I get an error saying ‘unused arguments’. I’ve already installed the lavaan package, but it’s still not working. Am I missing something in my syntax or setup? I thought this would automatically add variances and covariances. Any help would be great!
I’ve encountered similar issues with lavaan before. One thing to check is whether you’re using the correct operator for specifying factor loadings. In lavaan, the ‘=~’ operator is typically used for this purpose, not ‘:’.
Try modifying your model specification like this:
model_spec <- '
Factor1 =~ F1_1 + F1_2 + F1_3 + F1_4 + F1_5
Factor2 =~ F2_1 + F2_2 + F2_3 + F2_4 + F2_5
Factor3 =~ F3_1 + F3_2 + F3_3 + F3_4 + F3_5
'
Also, ensure you’re passing your data to the cfa() function:
result <- cfa(model_spec, data = your_data, auto.var = TRUE)
If the issue persists, it might be worth checking for any missing data or inconsistencies in variable names between your model specification and dataset. The ‘unused arguments’ error often points to a mismatch in function parameters or data structure.
Hey ExploringOcean! 
I feel ya on the CFA struggles - those errors can be super frustrating! Have you tried running summary() on your dataset to make sure all the variables are there and named correctly? Sometimes R can be picky about exact matches.
Also, curious if you’ve considered using the lavaan syntax for factor loadings instead? It might give you more control. Something like:
model_spec <- '
Factor1 =~ F1_1 + F1_2 + F1_3 + F1_4 + F1_5
Factor2 =~ F2_1 + F2_2 + F2_3 + F2_4 + F2_5
Factor3 =~ F3_1 + F3_2 + F3_3 + F3_4 + F3_5
'
What kind of data are you working with, by the way? CFA can be tricky with certain types. Let me know if you figure it out - always eager to learn new lavaan tricks!
hey there, ran into similar issues before. make sure you’re passing your data to the cfa() function.
try somethin like:
result ← cfa(model_spec, data = your_data_frame, auto.var = TRUE)
if that dont work, double check ur variable names match whats in ur dataset. good luck!