[Mediation-information] Independent dummy variable coding

dustin tingley dustin.tingley at gmail.com
Thu Jan 26 20:56:38 CET 2012


Hi-
You need to enter in treatment variable as a factor, then indicate the
contrast you want to estimate things for using the treat.value and
control.value arguments. In R you don't want to enter them in as dummy
variables. This seems to work fine on our side.
best,
Dustin

Dustin Tingley
Government Department
Harvard University
http://scholar.harvard.edu/dtingley


On Thu, Jan 26, 2012 at 10:18 AM, Heymans, M.W. <mw.heymans at vumc.nl> wrote:

>  Dear list,
>
>
>
> Is it possible to do a mediation analysis in combination with an
> independent categorical (dummy)variable, something like this? How to
> calculate the mediation effect with respect to both dummy variables? Just
> include dummy1 first andf than dummy2 in model c? I tried it with real data
> but the code below does not work? What is wrong? (define the variable as
> factor also does not solve it)
>
>
>
> # Model 1
> a <- glm(indep ~ dummy1 + dummy2, data=x, family=gaussian)
> b <- glm(mediator ~ dummy1 + dummy2, data=x, family=gaussian)
> c <- glm(indep outcome~ dummy1 + dummy2 + mediator, data=x,
> family=gaussian)
>
> a
> b
> c
>
> med1.boot <- mediate(b, c, boot=TRUE, sims=1000, treat=c("dummy1",
> "dummy2"), mediator="mediator")
> summary(med1.boot)
>
>
>
> Thanks for the response.
>
>
>
> kind regards,
>
>
>
> Martijn
>
>
>
> _______________________________________________
> 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/20120126/ef9005ac/attachment.htm>


More information about the Mediation-information mailing list