[R] creating bins for a plot

Ingmar Visser i.visser at uva.nl
Thu Oct 19 09:45:52 CEST 2006


Jeffrey,
not sure what you mean by showing the relationship between the prob and
purban2, but something like this could work:

library(gtools)
#inverse logit
fl <- function(x,beta){inv.logit(beta[1]+beta[2]*x)}
# for beta fill in your intercept and the coefficient of purban2
flb<-function(x,beta=c(-0.09,3.65)){fl(x,beta)}
# plot over the range of purban2 by:
plot(flb,0,1)

hth, Ingmar

On 10/19/06 12:24 AM, "Jeffrey Stratford" <stratja at auburn.edu> wrote:

> Hi.  I'm trying to plot the ratio of used versus unused bird houses
> (coded 1 or 0) versus a continuous environmental gradient (proportion of
>  urban cover [purban2]) that I would like to convert into bins (0 -
> 0.25, 0.26 - 0.5, 0.51 - 0.75, 0.76 - 1.0) and I'm not having much luck
> figuring this out.  I ran a logistic regression and purban2 ends up
> driving the probability of a box being occupied so it would be nice to
> show this relationship.  I'm also plotting the fitted values vs. purban2
> but that's done.  Any suggestions would be appreciated.
> 
> Many thanks,
> 
> Jeff
> 
> 
> Data sample:
> 
> box use purbank purban2
> 1 1 0.003813435 0.02684564
> 2 1 0.04429451 0.1610738
> 3 1 0.04458785 0.06040268
> 4 1 0.06072162 0.2080537
> 5 0 0.6080962 0.6979866
> 6 1 0.6060428 0.6107383
> 7 1 0.3807568 0.4362416
> 8 0 0.3649164 0.3154362
> 9 0 0.3505427 0.2483221
> 10 0 0.3476093 0.1409396
> 11 0 0.3719566 0.3020134
> 12 1 0.09238011 0.1342282
> 13 0 0.08616111 0.1073826
> 14 0 0.07388724 0.04026845
> 15 1 0.07046477 0.03355705
> .
> .
> .
> 
> 
> ****************************************
> Jeffrey A. Stratford, Ph.D.
> Postdoctoral Associate
> 331 Funchess Hall
> Department of Biological Sciences
> Auburn University
> Auburn, AL 36849
> 334-329-9198
> FAX 334-844-9234
> http://www.auburn.edu/~stratja
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

-- 
Ingmar Visser
Department of Psychology, University of Amsterdam
Roetersstraat 15, 1018 WB Amsterdam
The Netherlands
http://users.fmg.uva.nl/ivisser/
tel: +31-20-5256735



More information about the R-help mailing list