Thank you!  Your codes produced plots that was fairly close to what I wanted. I 
am not familiar with ggplot2, so I need to study what exactly each code is 
doing. Actually, I also want to plot the observed (raw) data points (not just 
confidence intervals shown by ggplot, assuming that colored portion is 
confidence intervals). I actually produced the one I wanted before, but my hard 
drive died and lost all R codes I wrote are lost. I have posted an example plot 
I created before using coplot function (downloadable in PowerPoint format from 
http://laurentian.academia.edu/KiyoshiSasaki/Miscellaneous ).

Could you please show me how to plot raw data points in those ggplots? 

And, can anyone help me reproduce that plot I made before using coplot? I just 
cannot figure out how I did to make that plot (I spent several days...).

Thank you for taking your time to help me out.

Sincerely,

Kiyoshi
 

________________________________
 From: Michael Friendly <frien...@yorku.ca>

Cc: "r-help@r-project.org" <r-help@r-project.org> 
Sent: Sunday, September 22, 2013 7:46:04 PM
Subject: Re: Conditioning plots (wth coplot function) with logistic regression 
curves


On 9/21/2013 11:12 PM, Kiyoshi Sasaki wrote:
> I have been trying to produce a conditional plot using coplot function 
> (http://stat.ethz.ch/R-manual/R-devel/library/graphics/html/coplot.html) for 
> a binary response ("Presence" in my case) variable and one continuous 
> variable ("Overstory") given a specific levels of the other continuous 
> variable ("Ivy"). But, my codes produces an overlapping graph. Also, I want 
> to use three equal intervals for "Ivy" (i.e.,33.3 each), but I could not 
> figure out how. Here is my data and codes I used:
> 

If you feel it hurts because you are banging your head into a wall trying 
t[[elided Yahoo spam]]

Instead, you might consider using ggplot2, which handles this case
nicely, as far as I can tell from your description.

But first a due diligence caveat:  Say you come to me for consulting
on this little plotting question. I look at your data frame, dat,
and I see there are a number of other variables that might explain
Presence, so maybe the marginal plot that ignores them could be
misleading, e.g., any of Moist, Leaf, Prey, ... could moderate
the relation between overstory and presence, but you won't see that
in a marginal plot.


Here are a couple of quick ggplot examples, plotting classes of Ivy in the
same plot frame, and on the probability scale.

library(ggplot2)
ggplot(dat, aes(Overstory, Presence), color=Ivy>50 ) +
  stat_smooth(method="glm", family=binomial, formula= y~x, alpha=0.3, 
aes(fill=Ivy>50))

dat$Ivy3 <- factor(cut(dat$Ivy,3))
plt <- ggplot(dat, aes(Overstory, Presence), color=Ivy3 ) +
  stat_smooth(method="glm", family=binomial, formula= y~x, alpha=0.3, 
aes(fill=Ivy3))
plt

If you want separate panels, try something like

plt + facet_grid(. ~ Ivy3)

For plots on the logit scale, try something like
logit <- function(p) log(p)/log(1-p), then

plt + coord_trans(y="logit")

-- Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:  http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to