[Mediation-information] (no subject)

Angel Rodriguez angel.rodriguez at matiainstituto.net
Fri Sep 19 14:22:43 CEST 2014


Thank you, Kentaro. The treatment variable has two values only. With your command that warning disappears but, what about the error:
 
Error in if (xhat == 0) out <- 1 else { :
  missing value where TRUE/FALSE needed
 
?
Angel 

 

________________________________

De: mediation-information-bounces at lists.r-forge.r-project.org en nombre de Kentaro Hirose
Enviado el: vie 19/09/2014 14:17
Para: mediation-information at r-forge.wu-wien.ac.at
Asunto: Re: [Mediation-information] (no subject)



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

________________________________
_______________________________________________
Mediation-information mailing list
Mediation-information at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/mediation-information


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/mediation-information/attachments/20140919/22d5ba3a/attachment.html>


More information about the Mediation-information mailing list