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

problems when trying to select particular elements of a factor, when the formative model argument (mode_B) is included #345

Open samirnemechaves opened 5 months ago

samirnemechaves commented 5 months ago

Hi, community, I trying to create the next measure model, however, I have noticed that when I include the "ATENCION" factor where I want to select particular items (1,3,4), and also after that I include the training model argument (mode_B). When I want to create the measurement model I get the following error when running code:

"Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame. Below the script"

PLS-PM

library(seminr) library(dplyr) DF <- dplyr::select(PNN, 8:33)

MM

ENG_mm <-constructs( composite("IDENT",multi_items("Idt,1:3), weights = mode_B), composite("ENTUS",multi_items("Ent",1:2), weights = mode_B), composite("ATENCION",multi_items("Ate", c(1,3,4), weights = mode_B)) )

Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame

To try to identify the errors I have been creating factor by factor and everything is fine before reaching the "ATENCION" factor, I have seen that if I remove the selection of specific items leaving all items from 1 to 4 "1:4" ( see example script 2) the measurement model is created without problem, or on the other hand, if I leave the specific selection of items "c(1,3,4)" but remove the reflective mode argument (mode_B) is also normally created (see example script 3) .

I appreciate your help to be able to carry out the creation of the first measurement model

Examples to scripts without problems

script2

ENG_mm <-constructs( composite("IDENT",multi_items("Idt,1:3), weights = mode_B), composite("ENTUS",multi_items("Ent",1:2), weights = mode_B), composite("ATENCION",multi_items("Ate", c(1,3,4))) )

Script3

ENG_mm <-constructs( composite("IDENT",multi_items("Idt,1:3), weights = mode_B), composite("ENTUS",multi_items("Ent",1:2), weights = mode_B), composite("ATENCION",multi_items("Ate", 1:4), weights = mode_B)) )