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 if ((mmMatrix[mmMatrix[, "construct"] == construct, "type"][1] == : missing value where TRUE/FALSE needed" #337

Closed hagemeis closed 1 year ago

hagemeis commented 1 year ago

Hi,

I am trying to follow the examples in the book "Partial Least Squares Structural Equation Modeling (PLS-SEM) Using R" by Hair et al., using their syntax and their data for the example.

I get the error "Generating the seminr model All 344 observations are valid. Error in if ((mmMatrix[mmMatrix[, "construct"] == construct, "type"][1] == : missing value where TRUE/FALSE needed"

My syntax is (sorry if there is too much of it, it is my first question here):

library(seminr)

corp_rep_data <- read.csv(file = "c:/carmen/dienst/statistik/r_sem_buch/data_raw/Corporate Reputation Data.csv", header = TRUE, sep = ";")

Create measurement model

simple_mm <- constructs( composite("COMP", multiitems("comp", 1:3)), composite("LIKE2", multiitems("like", 1:3)), composite("CUSA", single_item("cusa")), composite("CUSL", multiitems("cusl", 1:3)))

Create structural model

simple_sm <- relationships( paths(from = c("COMP", "LIKE"), to = c("CUSA", "CUSL")), paths(from = c("CUSA"), to = c("CUSL")))

Estimate the model with default settings

corp_rep_simple_model <- estimate_pls(data = corp_rep_data, measurement_model = simple_mm, structural_model = simple_sm, missing_value = "-99")

I had tried the more complex estimation and got exactly the same error code.

Thank you very much for your help! Carmen

soumyaray commented 1 year ago

Hi @hagemeis and thanks for your note. The issue is likely that your measurement model has a construct called LIKE2 but you are referring to LIKE in the structural model. The issue is most likely as simple as fixing the construct name to be consistent.

hagemeis commented 1 year ago

Hi soumyaray,

thank you very much! I am sorry. I added this typo when changing the quotation marks to a version which R can use.

Best, Carmen

soumyaray commented 1 year ago

Not at all -- typos happen! Closing this issue for now.