[Mediation-information] (no subject)

Kentaro Hirose hirose at Princeton.EDU
Fri Sep 19 14:17:07 CEST 2014


Hi Angel, 

The warning message "treatment and control values do not match factor levels" pops up when your treatment has more than two values but you don't specify the specific values of the treatment that you're interested when deriving the treatment effect. So, for example, if you're interested in the treatment effect when the value of the treatment changes from no to si, then you should use the following command: 
 
med.out <- mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic", robustSE = TRUE, sims = 100, control.value = "no", treat.value = "si")


Best,
Kentaro



________________________________________
From: mediation-information-bounces at r-forge.wu-wien.ac.at [mediation-information-bounces at r-forge.wu-wien.ac.at] on behalf of Angel Rodriguez [angel.rodriguez at matiainstituto.net]
Sent: Friday, September 19, 2014 7:15 AM
To: mediation-information at r-forge.wu-wien.ac.at
Subject: Re: [Mediation-information] (no subject)

Dear Subscribers,

I've encountered the following error message. Edad_c is numeric. Estudic, sexo, deprinf and benvii are dichotomic. Regalf has three categories.

Any help would be very valuable.

Best regards,

Angel Rodriguez-Laso


> med.fit <- glm(estudic ~ edad_c + sexo + regalf + deprinf, family="binomial" ,data=child65)
> out.fit <- glm(benvii ~ edad_c + sexo + regalf + deprinf + estudic, family="binomial" ,data=child65)
> library("mediation")
Loading required package: MASS
Loading required package: Matrix
Loading required package: lpSolve
Loading required package: mvtnorm
mediation: Causal Mediation Analysis
Version: 4.4.2

> library("sandwich")
> set.seed(2014)
> med.out <- mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic", robustSE = TRUE, sims = 100)
Error in if (xhat == 0) out <- 1 else { :
  missing value where TRUE/FALSE needed
In addition: Warning message:
In mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic",  :
  treatment and control values do not match factor levels; using no and sí as control and treatment, respectively

________________________________


More information about the Mediation-information mailing list