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 when summarizing the estimate_pls() #289

Closed alibezzaa closed 1 year ago

alibezzaa commented 2 years ago

Hello,

When summarizing a PLS model, I get the following error: Error in if (construct[[1]] %in% unique(as.vector(orig_sm))) { : argument is of length zero

The bootstrap works fine and I can plot the model. However, I can not summarize the model to assess validity. Here's the code I used:

`mm3 = constructs( composite("Overload", single_item("TS_2")), composite("Invasion", multiitems("TS", 4:5)), composite("Complexity", c("TS_6", "TS_8")), higher_composite("Technostress", c("Overload", "Invasion", "Complexity"), weights=mode_B), composite("InterWB", multiitems("WB", 1:4)), composite("IntraWB", multiitems("WB", 5:8)), higher_composite("Wellbeing", c("IntraWB", "InterWB")), composite("Engagement", multiitems("Eng", 2:9)) )

sm3 = relationships( paths("Technostress", "Wellbeing"), paths("Wellbeing", "Engagement") )

eng_model3 = estimate_pls(new_data, mm3, sm3)
sum_eng3 = summary(eng_model3)`

Any help will be appreciated.

yanxiang-yang commented 2 years ago

Got the same problem, have you solved this? @NicholasDanks @soumyaray @Sumidu Could you please help provide some suggestions? Thank you all very much.

soumyaray commented 2 years ago

@NicholasDanks is this related to the HOC code issue you mentioned to me recently?

NicholasDanks commented 2 years ago

This is another edge case :)

So I identified the bug in the code and I have committed a bug fix

Dear @yanxiang-yang and @alibezzaa

Thank you very much for pointing out a bug in our code. I believe that I now have resolved the bug. It had to do with the calculation of fSquared on HOc models which consisted of only single paths. Please do run the following code:

devtools::install_github(repo = "https://github.com/sem-in-r/seminr", ref = "bugfixes_aug_2022")

Then test your model and confirm that the bug is resolved and then let us know.

If the issue is resolved, please do close the issue. Many thanks and happy modelling!

Nicholas

FranDot commented 1 year ago

Hello, I'm new to seminr and getting the following summary error Error in if ((mmMatrix[mmMatrix[, "construct"] == construct, "type"][1] == : missing value where TRUE/FALSE needed

I don't know how to resolve the error and any help is appreciated.

Here's my code. corp_rep_mm <- constructs( composite("Empowerment", multiitems("Empower",1:5)))

corp_rep_sm <- relationships( paths(from = "Empowerment", to = c("Satisfaction", "OrgCommit", "Leadership")), paths(from = "Satisfaction", to = c("Leadership")), paths(from = "OrgCommit", to = c("PersonEffort")), paths(from = "Leadership", to = c("PersonEffort")))

corp_rep_pls_model <- estimate_pls(data = Datafile, measurement_model = corp_rep_mm, structural_model = corp_rep_sm, inner_weights = path_weighting)

soumyaray commented 1 year ago

Hi @FranDot are you missing some code above? It seems you have never defined the measurement of all the constructs except for Empowerment. All constructs used in your structural model must be defined in the constructs() list.

Also, I believe this is a separate issue -- so if the problem lingers, please open a new issue. Alternatively, you can also share your code (upon fixing my above suggestions) in our Facebook group where more users can help you with your syntax: https://www.facebook.com/groups/seminr

Best of luck!