[R] plot of Bernoulli data
Bill Simpson
wsi at gcal.ac.uk
Tue Oct 2 11:23:30 CEST 2001
I have some Bernoulli data something like this:
x<-sort(runif(100,1,20))
p<-pnorm(x,10,3)
y<-as.numeric(runif(x)<p)
plot(x,y)
lines(x,p)
This plot is not very satisfactory because the ogive does not visually
fit the (0,1) points very well, and also because the points tend to fall
on top of one another. The second problem can be eliminated by adding
vertical jitter. However I was thinking about the following plot. Instead
of plotting all the 0,1 points, instead divide the x axis into bins. In
each bin, find the average y value. Then plot (x=average of x values in
bin, y=average of 0,1 values in bin). So if I use 10 bins I have 10 points
in the plot and now the y-values are proportions instead of 0/1. Is this
a plot that other people have used (refs appreciated)? If so maybe someone
has code to do this. Otherwise, I am not sure of how to do this in R.
Could someone help me? Thanks very much.
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list