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)
60 stars 20 forks source link

Problem with estimate_pls I got an Error #328

Open caterinagf opened 1 year ago

caterinagf commented 1 year ago

I'm doing modeling, but I can't use the estimate_pls function, it returns an error. in data[, all_loc_non_int_items(measurement_model)]: Can't subset columns with all_loc_non_int_items(measurement_model). Subscript all_loc_non_int_items(measurement_model) must be a simple vector, not a matrix.

Here is my code;

Compile measurement model

mm_IMC = constructs( composite("USBLT", multi_items("USBLT", 1:3)), composite("USEFS", multi_items("USEFS", 4:6)), composite("TRST", multi_items("TRST", 7:9)), composite("PRSN", multi_items("PRSN", 10:12)), composite("SATIS", multi_items("SATIS", 13:15)), composite("PINTN", multi_items("PINTN", 16:18)) )

Build structural model

sm_IMC = relationships( paths(from = c("USBLT"), to = c("SATIS")), paths(from = c("USEFS"), to = c("SATIS")), paths(from = c("TRST"), to = c("SATIS")), paths(from = c("PRSN"), to = c("SATIS")), paths(from = c("SATIS"), to = c("PINTN")) )

Estimate the model

IMCmod_est = estimate_pls( data = data_sem, measurement_model = mm_IMC, structural_model = sm_IMC, missing = mean_replacement, missing_value = NA )

Could you help me with this problem?

With respect, Kate

soumyaray commented 1 year ago

Hi Kate,

Could you start with the simplest model possible (comment out all the constructs except for two of them – e.g., USBLT and SATIS) from both measurement and structural models and see if it estimates? If it works, keep adding constructs one-by-one until you find which one is causing the error?

caterinagf commented 1 year ago

I tried to run model for two factors. It doesn't work. The same error

Compile measurement model

mm_IMC = constructs( composite("USBLT", multi_items("USBLT", 1:3)), composite("SATIS", multi_items("SATIS", 13:15)) )

Build structural model

sm_IMC = relationships( paths(from = c("USBLT"), to = c("SATIS")) )

Estimate the model

IMCmod_est = estimate_pls( data = data_sem, measurement_model = mm_IMC, structural_model = sm_IMC, missing = mean_replacement, missing_value = NA )

pfrombris commented 1 year ago

I have found exactly the same error message with estimate_pls() and I have reduced my model to the absolute minimum and it still happens. seminr v2.3.1, r version 4.2.3. Can anyone help please?

RanaAvinash commented 8 months ago

Convert data to csv format before importing into R.

I encountered the same issue and resolved using this method