<HTML dir=ltr><HEAD><TITLE>Re: [Mediation-information] (no subject)</TITLE>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.17280"></HEAD>
<BODY>
<DIV id=idOWAReplyText91081 dir=ltr>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Thank you, Kentaro. The treatment variable has two values only. With your command that warning disappears but, what about the error:</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial><FONT face="Times New Roman"></FONT></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial><FONT face="Times New Roman">Error in if (xhat == 0) out <- 1 else { :<BR> missing value where TRUE/FALSE needed</FONT></FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial><FONT face="Times New Roman"></FONT></FONT> </DIV>
<DIV dir=ltr><FONT size=2 face=Arial>?</FONT></DIV><FONT size=2></FONT></DIV>
<DIV dir=ltr><FONT size=2><FONT face=Arial>Angel</FONT>
<DIV dir=ltr><BR></DIV></FONT>
<DIV dir=ltr><FONT size=2 face=Arial></FONT> </DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>De:</B> mediation-information-bounces@lists.r-forge.r-project.org en nombre de Kentaro Hirose<BR><B>Enviado el:</B> vie 19/09/2014 14:17<BR><B>Para:</B> mediation-information@r-forge.wu-wien.ac.at<BR><B>Asunto:</B> Re: [Mediation-information] (no subject)<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Hi Angel,<BR><BR>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:<BR><BR>med.out <- mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic", robustSE = TRUE, sims = 100, control.value = "no", treat.value = "si")<BR><BR><BR>Best,<BR>Kentaro<BR><BR><BR><BR>________________________________________<BR>From: mediation-information-bounces@r-forge.wu-wien.ac.at [mediation-information-bounces@r-forge.wu-wien.ac.at] on behalf of Angel Rodriguez [angel.rodriguez@matiainstituto.net]<BR>Sent: Friday, September 19, 2014 7:15 AM<BR>To: mediation-information@r-forge.wu-wien.ac.at<BR>Subject: Re: [Mediation-information] (no subject)<BR><BR>Dear Subscribers,<BR><BR>I've encountered the following error message. Edad_c is numeric. Estudic, sexo, deprinf and benvii are dichotomic. Regalf has three categories.<BR><BR>Any help would be very valuable.<BR><BR>Best regards,<BR><BR>Angel Rodriguez-Laso<BR><BR><BR>> med.fit <- glm(estudic ~ edad_c + sexo + regalf + deprinf, family="binomial" ,data=child65)<BR>> out.fit <- glm(benvii ~ edad_c + sexo + regalf + deprinf + estudic, family="binomial" ,data=child65)<BR>> library("mediation")<BR>Loading required package: MASS<BR>Loading required package: Matrix<BR>Loading required package: lpSolve<BR>Loading required package: mvtnorm<BR>mediation: Causal Mediation Analysis<BR>Version: 4.4.2<BR><BR>> library("sandwich")<BR>> set.seed(2014)<BR>> med.out <- mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic", robustSE = TRUE, sims = 100)<BR>Error in if (xhat == 0) out <- 1 else { :<BR> missing value where TRUE/FALSE needed<BR>In addition: Warning message:<BR>In mediate(med.fit, out.fit, treat = "deprinf", mediator = "estudic", :<BR> treatment and control values do not match factor levels; using no and sí as control and treatment, respectively<BR><BR>________________________________<BR>_______________________________________________<BR>Mediation-information mailing list<BR>Mediation-information@lists.r-forge.r-project.org<BR><A href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/mediation-information">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/mediation-information</A><BR></FONT></P></DIV></BODY></HTML>