0
$\begingroup$

I am having trouble getting the mediation package in R to work with what I am trying to do.

My mediator is continuous and numeric ( range is between 92-430). My predictor is also continuous and ranges from ( 0.2834 to 1) My response/dependent variable which is disease status is binary (0 for control and 1 for disease).

Via the mediation package in R, my treatment would be gene expression levels (predictor). My mediator is diversity. The below doesn't work because either my mediator or predictor needs to be an integer where there are either 0 or 1 values.

   model.x <-lm(Diversity ~ Gene, data=df)

  model.y <-glm(Disease ~ Diversity + Gene, data=df, family=binomial)

  res <- mediate(model.x, model.y, treat="Gene", mediator="Diversity", robustSE=T, sims=100)

I have only seen examples whereby the response is binary and the predictor is also binary. Like in the example documented here https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5124624/. Where they wanted to assess the effect of c-reactive protein (mediator, continous, numeric) on the association between mortality ( response, logical, TRUE/FALSE) and medication (0=not consuming, 1=consuming, integer).

Please could anybody suggest an alternative method that may work? Or suggestions as to how I could change my predictor ( gene expression values) into a binary variable with either 0 or 1 values ( not exactly sure how to arbitrarily set a threshold, whereby values below which are 0 and values above which are 1 without losing the association between this predictor and the response).

$\endgroup$
1

1 Answer 1

0
$\begingroup$

I think with the example shown by Tingley et al,

 med.fit <- lm(emo ~ treat + age + educ + gender + income, data = framing) 

 out.fit <- glm(cong_mesg ~ emo + treat + age + educ + gender + income, data = framing, family = binomial("probit"))


 med.out <- mediate(med.fit, out.fit, treat = "treat", mediator = "emo", robustSE = TRUE, sims = 100)

summary(med.out)

class(framing$treat) ##numeric but takes either 0 or 1 (unlike the Gene variable you have)

class(framing$emo) ## numeric and continuous like your Diversity

class(framing$cong_mesg) ##integer but values are either 0 or 1 (probably factor with 0 control and 1 disease would be fine).

In this link, https://imai.fas.harvard.edu/research/files/mediationR.pdf on pg 17, they convert a continuous variable ( job) into job_disc, by dividing the job values by the median of this column, and then assign a 0 to all values belwo 0.96 and then a 1 to values above 0.96. Not sure how this might affect your results though or the relationship between the predictor and response etc.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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