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

summary() error: Error in `[<-`(`*tmp*`, int_components, dv, value = NA) : subscript out of bounds #330

Open shu9911 opened 1 year ago

shu9911 commented 1 year ago

Hi,

I encountered error when I'm trying to apply summary() to the model. I can plot the model and see details using $, but when I try to use summary(), the error occurs.

> summary(all_intxn_pls) Error in[<-(tmp, int_components, dv, value = NA) : subscript out of bounds

In addition, I also failed to use bootstrap on this model.

> all__intxn_boot <- bootstrap_model(all_intxn_pls, nboot = 100) Bootstrapping model using seminr... Bootstrapping encountered this ERROR: 8 nodes produced errors; first error: system is computationally singular: reciprocal condition number = 1.60033e-16

I wonder how to fix this error.

My code of the model is as following. Thank you!

#interaction model
all_intxn_mm <- constructs(
  composite("NF", single_item("Cognitive_Style_NF")),
  composite("NT", single_item("Cognitive_Style_NT")),
  composite("SF", single_item("Cognitive_Style_SF")),
  composite("ST", single_item("Cognitive_Style_ST")),
  composite("ISS", single_item("ISS1")),
  composite("Value Co-creation", single_item("VCC_score")),
  interaction_term(iv = "NF", moderator = "ISS", method = orthogonal),
  interaction_term(iv = "NT", moderator = "ISS", method = orthogonal),
  interaction_term(iv = "SF", moderator = "ISS", method = orthogonal),
  interaction_term(iv = "ST", moderator = "ISS", method = orthogonal)
)

all_intxn_sm <- relationships(
  paths(from = c("NF", "NT", "SF", "ST", "NF*ISS", "NT*ISS", "SF*ISS", "ST*ISS"), 
        to = "Value Co-creation")
)

all_intxn_pls <- estimate_pls(data = all, 
                        measurement_model = all_intxn_mm,
                        structural_model = all_intxn_sm,
                        missing = mean_replacement,
                        missing_value = -99)
plot(all_intxn_pls, title = "MBTI*ISS to VCC model")
soumyaray commented 1 year ago

Hi! Before looking into it further, can I ask if this the final model you are interested in? If so, wouldn't it make more sense to just model this using linear regression? All the "constructs" (both IV and DV) seem to be single items, along with interactions.

shu9911 commented 1 year ago

Actually, I've run the regression too! But I try to take a look at the path coefficients of these variables using SEM.

soumyaray commented 1 year ago

Hi @shu9911 I'll still try to make time to see what is happening here, but apologies that it will not be a first priority as the use case (a regression path model) is a bit outside the intended usage. I do feel that it needs to be resolved at some point though.