[R] logistic regression asymptote problem

2005-07-05 Thread Kevin J Emerson
R-helpers,

I have a question about logistic regressions.

Consider a case where you have binary data that reaches an asymptote
that is not 1, maybe its 0.5.  Can I still use a logistic regression to
fit a curve to this data?  If so, how can I do this in R.  As far as I
can figure out, using a logit link function assumes that the asymptote
is at y = 1.

An example.  Consider the following data:

tmp -
structure(list(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14), yes = c(0, 0, 0, 2, 1, 14, 24, 15, 23, 18, 22, 20, 14, 17
), no = c(94, 101, 95, 80, 81, 63, 51, 56, 30, 38, 31, 18, 21, 
20)), .Names = c(x, yes, no), row.names = c(1, 2, 3, 
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), class =
data.frame)

where x is the independent variable, and yes and no are counts of
events.  plotting the data you can see that the data seem to reach an
asymptote at around y=0.5.  using glm to fit a logistic regression it is
easily seen that it does not fit well.

tmp.glm - glm(cbind(yes,no) ~ x, data = tmp, family = binomial(link =
logit))
plot(tmp.glm$fitted, type = l, ylim = c(0,1))
par(new=T)
plot(tmp$yes / (tmp$yes + tmp$no), ylim = c(0,1))

Any suggestions would be greatly appreciated.

Cheers,
Kevin

-- 


Kevin J Emerson
Center for Ecology and Evolutionary Biology
1210 University of Oregon
University of Oregon
Eugene, OR 97403
[EMAIL PROTECTED]

__
R-help@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


Re: [R] logistic regression asymptote problem

2005-07-05 Thread Spencer Graves
  I saw a standard overdispersed binomial.  In particular, I saw NO 
evidence of saturation at 0.5 or anything below 1.  I did the following:


tmp$N - tmp$yes+tmp$no

with(tmp, plot(x, yes))
with(tmp, plot(x, yes/N))

tmp.glm - glm(cbind(yes,no) ~ x, data = tmp, family = binomial(link 
=logit))
tmp.glmq - glm(cbind(yes,no) ~ x, data = tmp, family = 
quasibinomial(link =logit))
summary(tmp.glm)
summary(tmp.glmq)

plot(tmp.glm)
plot(tmp.glmq)

# Test the statistical significance of the Dispersion parameter
pchisq(summary(tmp.glmq)$dispersion*12, 12, lower=FALSE)

  hope this helps.
  spencer graves


Kevin J Emerson wrote:

 R-helpers,
 
 I have a question about logistic regressions.
 
 Consider a case where you have binary data that reaches an asymptote
 that is not 1, maybe its 0.5.  Can I still use a logistic regression to
 fit a curve to this data?  If so, how can I do this in R.  As far as I
 can figure out, using a logit link function assumes that the asymptote
 is at y = 1.
 
 An example.  Consider the following data:
 
 tmp -
 structure(list(x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
 14), yes = c(0, 0, 0, 2, 1, 14, 24, 15, 23, 18, 22, 20, 14, 17
 ), no = c(94, 101, 95, 80, 81, 63, 51, 56, 30, 38, 31, 18, 21, 
 20)), .Names = c(x, yes, no), row.names = c(1, 2, 3, 
 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), class =
 data.frame)
 
 where x is the independent variable, and yes and no are counts of
 events.  plotting the data you can see that the data seem to reach an
 asymptote at around y=0.5.  using glm to fit a logistic regression it is
 easily seen that it does not fit well.
 
 tmp.glm - glm(cbind(yes,no) ~ x, data = tmp, family = binomial(link =
 logit))
 plot(tmp.glm$fitted, type = l, ylim = c(0,1))
 par(new=T)
 plot(tmp$yes / (tmp$yes + tmp$no), ylim = c(0,1))
 
 Any suggestions would be greatly appreciated.
 
 Cheers,
 Kevin
 

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
R-help@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