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

Identical conditioned networks using condition() function #34

Open
KaiyeeHe opened this issue Jan 1, 2025 · 1 comment
Open

Identical conditioned networks using condition() function #34

KaiyeeHe opened this issue Jan 1, 2025 · 1 comment

Comments

@KaiyeeHe
Copy link

KaiyeeHe commented Jan 1, 2025

Hi Jonas,

I've encountered an unexpected result when using the condition() function on a moderated MGM object. When comparing the pairwise weighted adjacency matrices of different conditioned networks, they appear to be identical, which is counterintuitive given that the networks are conditioned on different levels of the moderator.

I can replicate the behavior shown in the example code provided in your blog. However, the conditioned network remained identical, while subgroup analysis found some differences existed across the three subnetworks for each condition.

I am wondering about the possible reasons for these identical results.Is this issue related to the dataset, or could it be a bug in the condition() function? Besides, are there any additional steps or checks I should perform to ensure the moderation effects are being correctly applied in the conditioned networks?

Thank you for your time and assistance in addressing this issue! :)

Code and Output

mgm_obj <- mgm(
data = df_stressors_lca %>% as.matrix(),
type = c(rep("c", 19), "c"),
level = c(rep(2, 19), 3),
lambdaSel = "EBIC",
lambdaGam = 0.25,
ruleReg = "AND",
moderators = 20
)
l_mgm_cond <- list()
for(g in 1:3) l_mgm_cond[[g]] <- condition(object = mgm_obj,
values = list("20" = g))
identical(l_mgm_cond[]$pairwise$wadj, l_mgm_cond[]$pairwise$wadj)

Output: TRUE

Additional information

Description of system environment:

  • Operating System: macOS Sonoma 14.5
  • R version: 4.4.1 (2024-06-14)
  • mgm package version: 1.2.14

My dataset consists of:

  • more than 500+ samples in each moderation level
  • 19 binary nodes
  • 1 moderator variable (3 levels)
@jmbh
Copy link
Owner

jmbh commented Jan 2, 2025

Hi @KaiyeeHe,

You would expect identical networks after conditioning on different levels of the moderator if no moderation effect is included in the estimated model. It is important to realize that those are networks for different levels of the moderator, given the estimated model. If no moderation effects are in the model, conditioning on different levels of the moderator of course has no effect on the pairwise interactions in the network. You can check this by looking whether there are any 3-way interactions included in $interactions in the output object.

Best wishes,
Jonas

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

2 participants