Let's imagine I am interested in the association between happiness and pain.

I run a study where I ask participants to rate both feelings, daily, for several days. However, I couldn't get all participants to start at the same time so I will have to include calendar date in analysis, as I know it affects happiness.

I record whether my participants take any medication (pill) that affects pain. I also found some great literature that suggests that both apple juice and green tea affect happiness and pain.

In that scenario I have both confounding variables and variables competing for exposure. I created a DAG (following this great comment) to decide which one is which. Based on my data I have the following graph:

Original DAG

enter image description here


enter image description here


  • $time$ is confounding variable because $time \rightarrow happiness$ EDIT: $time \rightarrow happiness/pain$
  • $juice$ & $tea$ are confounding variables because $juice/tea \rightarrow happiness \rightarrow pain \leftarrow juice/tea $
  • $pill$ is competing exposure because $pill \rightarrow pain$

Based on that DAG interpretation I build a model

m1 <- lmer(pain ~ happiness + pill + time + (1 + time | participant) + (1 | juice) + (1 | tea)

With that model I hope to account for the effect of time, which is a continuous variable. I entered juice and tea as crossed random effects because they change with time and the level of both depends on participant. Lastly, I entered pill as a fixed effect since it is a categorical yes/no variable to denote presence/absence of medication.

  1. Is my interpretation of DAG correct?
  2. Does my model reflect my DAG?

Is my interpretation of DAG correct?

Not quite, but it is VERY nice to see that you are embracing the DAG methodology. You said:

time is confounding variable because time→happiness

That does not make time a confounder. You have correctly identified that juice and tea are confounder, but time is not a cause of pain, so according your DAG, time is not a confounder.

Pill is indeed a competing exposure and inclusion of it in the model will make the estimate of your causal effect of happiness on pain more precise.

So you should include tea, juice and pill as covariates, either fixed or random.

It is a bit unclear how to treat time here. I would rather of posted this as a comment but there was too much to say so I may update the answer once more information comes to light.

Does my model reflect my DAG?

A slightly better question to ask is "is my model consisent with my DAG, but I am being a little pedantic there. Just remember that DAGs are non parametric, but the model is parametric. According to your DAG we should not condition on time, but I think we need to understand how time is involved in the study design before taking it further.

  • $\begingroup$ Thank you as always, @Robert Long! And thank you for correcting the posed question, the devil is in the details! Regarding time, in this scenario I hypothesised that it would affect happiness exclusively, but now I understand that this is rather incorrect and likely affects both happiness and pain (see new DAG). Since participants did not complete the ratings on the same calendar dates, I suspect their answers will be affected by calendar date and I account for this in the model by including the variable time. $\endgroup$ Aug 3 '20 at 12:52
  • 1
    $\begingroup$ No worries, you're welcome. Indeed, time is now a coufounder in the new DAG. $\endgroup$ Aug 3 '20 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.