<div><div class="gmail_quote"><br><br>Michael-<div><br></div><div>Thanks. This is because its plotting for acme(0) and acme(1) and you weren't using par() to put them together. You also need to update your syntax, like below, and stripping out the title prevented you from seeing this I think. </div>
<div><br></div><div>We do need to add an option to only plot one or the other for the sensitivity in the case of binary DV. We will do that.</div><div><br></div><div><div>pdf("GroSensRsq.pdf")</div><div> par(mfrow=c(1,2))</div>
<div class="im"><div> plot(sens1, sens.par = "R2", </div></div><div> r.type = "total", </div><div> sign.prod = "negative")</div><div> dev.off()</div><div class="im"><div><br>
</div>
<div><br></div>Dustin Tingley<br>Government Department<br>Harvard University<br><a href="http://scholar.harvard.edu/dtingley" target="_blank">http://scholar.harvard.edu/dtingley</a><br><br><br><br></div><div><div></div><div class="h5">
<div class="gmail_quote">On Fri, Sep 23, 2011 at 9:04 PM, Michael J. Donnelly <span dir="ltr"><<a href="mailto:mdonnell@princeton.edu" target="_blank">mdonnell@princeton.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<div bgcolor="#FFFFFF" text="#000000">Hi Dustin,<br>I hope all is well. I ran into a bug using plot.medsens this week and Kosuke suggested that you might know what's causing it. I figured out another approach that's just as easy, but if you plan to update it any time soon, you might want to look at it. <br>
<br>I'm using pdf() and the R2 option and getting a two page pdf with two identical graphs. If I use dev.copy(), I don't have the problem. Code below - run on both Linux and Mac using R-2.13.0 and 2.13.1, respectively.<br>
<br><br>Michael<br><br><br>rm(list = ls())<br># generating fake data<br>obs <- 1000<br>tr <- rnorm(obs)<br>med <- 2*tr + rnorm(obs)<br>ystar <- .5*tr - med + rnorm(obs)<br><br>dat <- as.data.frame(cbind(tr, med, ystar))<br>
dat$y <- 1- (dat$y < 0) <br><br># fitting models<br>firststage <- lm(med ~ tr, data = dat)<br>secondstage <- glm(y ~ tr + med, data = dat, family = binomial(link = "probit"))<br><br>library(mediation)<br>
<br># applying mediation<br> mod1 <- mediate(model.y = secondstage,<br> model.m = firststage,<br> boot = FALSE,<br> treat = "tr",<br> mediator = "med",<br>
sims = 100)<br> sens1 <- medsens(mod1, <a href="http://rho.by/" target="_blank">rho.by</a> = .05, sims = 100)<br><br> pdf("GroSensRsq.pdf")<br> plot(sens1, sens.par = "R2", <br> r.type = 1, <br>
sign.prod = -1,<br> levels = c(0),<br> main = "")<br> dev.off()<br></div></blockquote></div></div></div></div></div></div><div><br></div><div><br></div><div class="gmail_quote"><div><div>
<div class="h5">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#ffffff" text="#000000"><div><div><blockquote type="cite"><div><br>
<br></div></blockquote></div></div></div></blockquote></div></div></blockquote></div></blockquote></div></div></div></div></div><br>