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

Third-order construct not running #321

Open zizzo opened 1 year ago

zizzo commented 1 year ago

Hello seminr community, I'm trying to run a third order construct but I constantly get this error message: "Error in if ((mmMatrix[mmMatrix[, "construct"] == construct, "type"][1] == : missing value where TRUE/FALSE needed". As far as I understand, third-order constructs, and higher, are supported in seminr, but I have not been able to find an example to work with. After validating lower-order constructs, my code for the final structural model is:

MEASUREMENT MODEL

tensions_mm <- constructs( composite("INT1", multi_items("SUS_CONSIM", 1:3)), composite("INT2", multi_items("SUS_CONSIP", 1:3)), higher_composite("INT", c("INT1","INT2"), method = "two stage"), composite("EXT1", multi_items("SUS_CONSE", 1:2)), composite("EXT2", multi_items("RESSCAR", 1:2)), higher_composite("EXT", c("EXT1","EXT2"), method = "two stage"), higher_composite("SUS", c("INT","EXT"), method = "two stage"), composite("BOUND", multiitems("OB", 1:11), weights = mode_B), composite("TENS", single_item("TENSIONS")))

STRUCUTRAL MODEL

tensions_sm <- relationships( paths(from = c("BOUND"), to = c("TENS", "SUS")), paths(from = c("TENS"), to = c("SUS")))

ESTIMATION

tensions_pls_model <- estimate_pls(data = survey_data, measurement_model = tensions_mm, structural_model = tensions_sm, inner_weights = path_weighting, missing = na.omit, #mean_replacement is default missing_value = "99")

Is there something I am missing? Thanks for your help.

soumyaray commented 1 year ago

Dear @zizzo I don't think seminr can handle third-order constructs at the moment. It would require two two-stage estimations, and all the complexity inherent in that. I regret we don't have immediate plans to support this in near future. However, I am willing to help you implement it by hand (by code) if you wish to try it.

zizzo commented 1 year ago

Dear @soumyaray, thanks for your reply. I'd be keen on trying and, if possible, learning, how to implement third-order constructs in seminr. I'd also like to ask if you have some advice to apply PLS_predict on a model with a third-order construct and a moderator. The message on screen says there is no published solution for that, but possibly under the hoods something can be done. Thanks for your availability and for this great free software package.

soumyaray commented 1 year ago

@zizzo for estimating such a model you can start by identifying the 2nd order sub-constructs (2OC) of your 3rd order construct (3OC). Then create the full PLS model and replace the 3OC by its 2OCs, where each of its 2OCs has the same antecedents and outcomes as the 3OC. Estimate this model and save all the construct scores of the 2OCs into new variables. Then, create the full model again, but this time use the construct scores of the 2OCs as the items of the 3OC (the 3OC is now a first order construct whose items are the 2OC scores). Re-estimate this model and you should get the results as if you had a 3OC model. The problem now will be bootstrapping this whole thing, which you would have to do by hand.

Doing PLSpredict on higher order constructs is not straightforward and a simple solution will not suffice I'm afraid.

zizzo commented 1 year ago

Dear @soumyaray, thanks for the explanation. I think it's relatively easy to implement. As you said, bootstrapping is not straightforward though. Do you have any "simple" explanation for the procedure, like the one you gave me for testing the construct? Again, thanks for your time.

soumyaray commented 1 year ago

Hi Zizzo, to implement the bootstrap, you'd have to repeat the above procedure k number of times (where k=1000 or 2000, etc.), each time replacing the original data (of n rows) with a randomly drawn rows (with replacement) from the original data (such that the number of rows is still n). I think you should try to find some tutorials on bootstrapping to get a full description. I'm afraid thats all I can help for now. I will keep this issue open as a reminder for a while to remind that we do not yet implement arbitrarily higher order constructs

zizzo commented 1 year ago

Hi @soumyaray. Thank you very much for the explanation and for all your work with SEMinR. I'll have a look at it. Best