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

hello world #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
change dominant indicator
  • Loading branch information
tsamanh committed Sep 2, 2024
commit 7b3dd26380944c14bc5f9035c94f4d0670c25d8d
21 changes: 8 additions & 13 deletions R/boot_sign_change.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ boot_dominant_indicator <- function(boot_model, original_model) {

names(highest_loadings_list) <- construct_list

highest_loadings_list
# Create the dominant indicator sign change objects
di_outer_weights <- boot_model$outer_weights
di_outer_loadings <- boot_model$outer_loadings
Expand All @@ -95,30 +96,24 @@ boot_dominant_indicator <- function(boot_model, original_model) {
flag <- rep(FALSE, length(construct_list))
names(flag) <- construct_list

boot_model$outer_loadings[,construct] <- boot_model$outer_loadings[,construct] * (-1)

for (construct in construct_list) {
highest_loadings_var_index <- highest_loadings_list[construct]

# Compare the sign of the weights and flip if the sign is different from the original
original_weights <- original_model$outer_weights[,construct]
boot_weights <- boot_model$outer_weights[,construct]

if(sign(original_weights[highest_loadings_var_index]) != sign(boot_weights[highest_loadings_var_index])) {
di_outer_weights[,construct] <- di_outer_weights[,construct] * (-1)
di_construct_scores[,construct] <- di_construct_scores[,construct] * (-1)
flag[construct] <- TRUE
}

# Compare the sign of the loadings and flip if the sign is different from the original
original_loadings <- original_model$outer_loadings[,construct]
boot_loadings <- boot_model$outer_loadings[,construct]

if (sign(original_loadings[highest_loadings_var_index]) != sign(boot_loadings[highest_loadings_var_index])) {
di_outer_loadings[,construct] <- di_outer_loadings[,construct] * (-1)
di_outer_weights[,construct] <- di_outer_weights[,construct] * (-1)
di_construct_scores[,construct] <- di_construct_scores[,construct] * (-1)
flag[construct] <- TRUE
}
}


# Flip the path coef if one of the IV-DV flag is TRUE

# Flip the path coef if one of the IV-DV flag is TRUE
for (i in 1:nrow(boot_model$structural_model)) {
IV <- boot_model$structural_model[i,]["source"]
DV <- boot_model$structural_model[i,]["target"]
Expand Down