sem-in-r / seminr

Natural feeling domain-specific language for building structural equation models in R for estimation by covariance-based methods (like LISREL/Lavaan) or partial least squares (like SmartPLS)
58 stars 19 forks source link

Error in generating the seminr model for CFA #304

Closed SatishAmbhore closed 2 years ago

SatishAmbhore commented 2 years ago

1660823724007blob

Dear sir, Greetings!

Kindly peruse the above screenshot. I am consistently receiving these errors. Kindly advice the solution please.

Warm regards, Satish Ambhore

PhD (Psychology), NET, SET, DSE(HI) Scientific Officer (Psychology)
Central Railway Headquarter, Office of Chief Safety Officer, Chhatrapati Shivaji Maharaj Terminus, Mumbai-400 001.

NicholasDanks commented 2 years ago

Dear Satish,

Thank you for notifying us of the challenges that you have encountered. So far, it seems that you might be encountering two separate challenges.

  1. When you are attempting to estimate the CFA model using estimate_cfa() it seems that your data do not correspond to a common-factor type. The warning that you are receiving is that the covariance matrix is not positive definite. This means you likely do not have convergent factors within the data. You may consult here for assistance. As an example, consider the following:

    reflective("Cort", multi_items("IMAG", 1:2)),
    reflective("Coga", multi_items("CUEX", 1:3)),
    reflective("Coaaii", multi_items("CUSL", 1:3)),
    reflective("Coai", multi_items("PERV", 1:2))
    )
    cfamodel1 <- estimate_cfa(data = mobi, 
                          measurement_model = sdhabb, item_associations = NULL)

    This example can run fine and converges on a result, while:

    colnames(mobi2) <- sample(colnames(mobi2), 24, replace = F)
    cfamodel2 <- estimate_cfa(data = mobi2, 
                          measurement_model = sdhabb, item_associations = NULL)

    No longer has accurately specified constructs that converge and thus the covariance matrix is not positive definite. Thus I would suggest looking deeper into your data and deciding if this in fact belongs to a common-factor data model.

  2. When attempting to estimate the PLS model using estimate_pls() you are not specifying a structural model detailing the inter-construct relations. You have only specified a measurement model. Note the following example has both a mm and sm:

    
    library(seminr)

Creating measurement model

- note: composite() has a default parameter setting of mode A

- note: items can be a list of names: c("CUEX1", "CUEX2", "CUEX3")

which can be constructed quickly as: multi_items("CUEX", 1:3)

mobi_mm <- constructs( composite("Image", multi_items("IMAG", 1:5)), composite("Expectation", multi_items("CUEX", 1:3)), composite("Quality", multi_items("PERQ", 1:7)), composite("Value", multi_items("PERV", 1:2)), composite("Satisfaction", multi_items("CUSA", 1:3)), composite("Complaints", single_item("CUSCO")), composite("Loyalty", multi_items("CUSL", 1:3)) )

Creating structural model

- note, multiple paths can be created in each line

mobi_sm <- relationships( paths(from = "Image", to = c("Expectation", "Satisfaction", "Loyalty")), paths(from = "Expectation", to = c("Quality", "Value", "Satisfaction")), paths(from = "Quality", to = c("Value", "Satisfaction")), paths(from = "Value", to = c("Satisfaction")), paths(from = "Satisfaction", to = c("Complaints", "Loyalty")), paths(from = "Complaints", to = "Loyalty") )

Estimating the model

- note, the mobi dataset is bundled with seminr

mobi_pls <- estimate_pls(data = mobi, measurement_model = mobi_mm, structural_model = mobi_sm)



Thus you have two avenues for further investigation of your data - why does it not conform to a common-factor model. And what is the structural model in your PLS (composite) model. 

I hope this helps.

Kind regards,
Nick
NicholasDanks commented 2 years ago

See the response on Github issues: https://github.com/sem-in-r/seminr/issues/304

On 19 Aug 2022, at 14:04, SatishAmbhore @.**@.>> wrote:

[1660823724007blob]https://user-images.githubusercontent.com/111578134/185624132-ddfa6e60-b073-4e55-8e8e-73166f4bd452.jpg

Dear sir, Greetings!

Kindly peruse the above screenshot. I am consistently receiving these errors. Kindly advice the solution please.

Warm regards, Satish Ambhore

PhD (Psychology), NET, SET, DSE(HI) Scientific Officer (Psychology) Central Railway Headquarter, Office of Chief Safety Officer, Chhatrapati Shivaji Maharaj Terminus, Mumbai-400 001.

— Reply to this email directly, view it on GitHubhttps://github.com/sem-in-r/seminr/issues/304, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AECEM44MVGFCLA6LPEPCFETVZ6A7PANCNFSM57AVTWLQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

NicholasDanks commented 2 years ago

Dear Satish,

Please do close the issue if it has answered your questions.

SatishAmbhore commented 2 years ago

Thanks a lot sir.