Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when plotting HOC and short HOC names. #305

Closed
NicholasDanks opened this issue Aug 22, 2022 · 0 comments
Closed

Error when plotting HOC and short HOC names. #305

NicholasDanks opened this issue Aug 22, 2022 · 0 comments

Comments

@NicholasDanks
Copy link
Collaborator

NicholasDanks commented Aug 22, 2022

From Facebook, Mohamed Ali, and Jota P Hidalgo

Mohamed Ali:

## I need a help.
## I am working on a model as below:
measurements <- constructs(
composite("A", multi_items("A", 1:12)),
composite("B", multi_items("B", 1:5)),
composite("C", multi_items("C", 1:6)),
higher_composite("M", dimensions = c("A", "B", "C"), method = two_stage, weights = mode_B),
composite ("D", multi_items("D", 1:8)),
composite ("E", multi_items("E", 1:7)),
composite ("F", multi_items("F", 1:4)),
composite ("G", multi_items("G", 1:4)),
higher_composite("N", dimensions = c("D", "E", "F", "G"), method = two_stage),
composite ("H", multi_items("H", 1:3)),
composite ("I", multi_items("I", 1:3)),
composite ("J", multi_items("J", 1:5)),
composite ("K", multi_items("K", 1:4)),
composite ("L", multi_items("L", 1:3)),
higher_composite("O", dimensions = c("H", "I", "J", "K", "L"), method = two_stage))
structure <- relationships(paths (from = "M", to = "N"),
(paths (from = "M", to = "O")),
(paths (from = "N", to = "O")))
pls_model <- estimate_pls(data = data, measurement_model = measurements, structural_model = structure, missing = mean_replacement, missing_value = "-99")
summary <- summary(pls_model)
## The Model runs fine
#>Generating the seminr model
#>Generating the seminr model
#>All 178 observations are valid.
#>All 178 observations are valid.
## But when I try to plot the model,
plot(pls_model)
## Error in get_construct_type(model, construct) :
object 'construct_type' not found
## Anyway, I was able to plot the first stage model using,
plot(pls_model_1$first_stage_model)
## But, it doesn't show the inner model in the plot.

and Jota P Hidalgo:

composite("DP", multi_items("ST", c(11:14,16)), weights = mode_A),
composite("CL", multi_items("ST", c(1,3:10)), weights = mode_A),
composite("ASGL", multi_items("ST", c(17:24)),weights = mode_A),
higher_composite("S", c("DP", "CL","ASGL"), weights = mode_A),
composite("CTF1", multi_items("BCT", c(1:8)), weights = mode_A),
composite("CTF2", multi_items("BCT", c(9:16)), weights = mode_A),
composite("CTF3", multi_items("BCT", c(17:23)), weights = mode_A),
composite("CTF4", multi_items("BCT", c(24:28)), weights = mode_A),
higher_composite("C", c("CTF1", "CTF2", "CTF3", "CTF4"), weights = mode_A),
composite("Ca",multi_items("CO", c(1,4,7,10,13,16,19)), weights = mode_A),
composite("Cn",multi_items("CO", c(2,5,8,11,14,17,20)), weights = mode_A),
composite("Cc",multi_items("CO", c(3,6,9,12,15,18,21)), weights = mode_A),
higher_composite("O", c("Ca", "Cn", "Cc"), weights = mode_A)
)
mobi_sm <- relationships(
paths(from = "C", to = c("S","O"))
)
mobi_pls <- estimate_pls(
data = PLS[,-c(1:6)],
measurement_model = mobi_mm,
structural_model = mobi_sm,
missing = mean_replacement
)
boot_mobi_pls <- bootstrap_model(seminr_model = mobi_pls, nboot = 1000, cores = 5)
plot(boot_mobi_pls, title = "Bootstrapped Model")

This problem arises because the authors used a single letter for the construct names, this aggravates a poor indexing line of code in extract_sm_nodes() in plot.dot.R
row_index <- grepl(construct, model$mmMatrix[,1])
has now been replcaed with:
row_index <- model$mmMatrix[,1] == construct

NicholasDanks pushed a commit that referenced this issue Aug 22, 2022
NicholasDanks added a commit that referenced this issue Oct 12, 2022
#308)

* changes to indexing in get_sm_nodes() to fix a bug that arises from using a single letter construct name. Issue #305

* Attend issue #309 regarding bug in total_effects() function

* Addresses issue #289 - bug when calculating fSquared on HOC models

* Addreswses issue #310

* refactor to use smMatrix helper function

* Remove browser() from code

* final changes to bugfixes

Co-authored-by: Nicholas Danks <nicholasdanks@Nicholass-MacBook-Pro-2.local>
Co-authored-by: Nicholas Danks <you@example.com>
Co-authored-by: Soumya Ray <soumya.ray@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant