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

Running a GAM interaction model as input for mediator and outcome model #62

Open
basilinb opened this issue Sep 6, 2023 · 0 comments
Open

Comments

@basilinb
Copy link

basilinb commented Sep 6, 2023

I am having some trouble using your mediate() function with a Generalized Additive Model(GAM) and see that your documentation specifies it can be done, but does not explain the appropriate syntax. Specifically, I am trying to run a causal mediation analysis with a GAM with an interaction between a continuous variable (time) and two factor categorical variable (illness group). The model aims to asses the relationship of how gene expression (continuous variable) differs over time (also a continuous variable) by a two factor categorical variable (Illness group) and whether this is mediated by viral load (a continuous variable), which differs overtime between the two illness groups. The model syntax for the GAMs is here:

model.mediate <- gam(viral_load~illnessgroup+ s(time) +s(time, by = illnessgroup), data=data, method = "REML")

model.outcome <- gam( gene_exp~illnessgroup + viral_load + s(time) +s(time, by = illnessgroup) ,data=data, method = "REML")
mediation_result <- mediate(model.m = model.mediate, model.y = model.outcome, mediator = "viral_load", treat = "illnessgroup", treat.value = "Severe", control.value = "Not_Severe", boot = TRUE, control = "Not_Severe")

This gives me an output with the average ACME, ADE, Prop. mediated and Total Effects but I was expecting to see separate statistics for the treatment (Severe) and control (Not Severe) conditions. This is what we would expect if using a linear model rather than a GAM. Any advice on how to appropriately run the mediate() function with a GAM model using an interaction for 2 comparison groups to get the output for both the treatment and control groups would be much appreciated.
Thank you,
Basilin Benson

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