From: <Bill.Venables_at_csiro.au>

Date: Mon 11 Apr 2005 - 17:17:35 EST

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

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 Received on Mon Apr 11 17:21:31 2005

Date: Mon 11 Apr 2005 - 17:17:35 EST

Couple of points:

- If you provide relative frequencies for the binomial response, you need also to give weights so that the actual counts can be reconstructed. This is what the warning message is telling you: if you reconstruct the counts using the default (unity) weights, the counts are not integers... In this case the simplest work-around is to use a quasibinomial family, which at least shuts up the warning message.
- predict with glm objects, by default, predicts *linear predictors*. You need to predict responses.

Here's how I would (minimally) correct your script:

year <- c(2003+(6/12), 2004+(2/12), 2004+(10/12), 2005+(4/12))
percent <- c(0.31, 0.43, 0.47, 0.50)

plot(year, percent, xlim = c(2003, 2007), ylim = c(0, 1))
Lm <- lm(percent ~ year)

abline(Lm)

bm <- glm(percent ~ year, family = quasibinomial)
points(year, fitted(bm), pch = 3)

curve(predict(bm, data.frame(year = x), type = "resp"), add = TRUE)

Supplementary points:

- It is a good idea to work with data frames, despite the fact that you need not.
- Using "lm" as the name for a fitted linear model object can cause problems, not to say confusion.

-----Original Message-----

From: r-help-bounces@stat.math.ethz.ch

[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of James Salsman
Sent: Monday, 11 April 2005 4:51 PM

To: r-help@stat.math.ethz.ch

Subject: [R] glm family=binomial logistic sigmoid curve problem

* > year <- c(2003+(6/12), 2004+(2/12), 2004+(10/12), 2005+(4/12))
*

> percent <- c(0.31, 0.43, 0.47, 0.50)

* > plot(year, percent, xlim=c(2003, 2007), ylim=c(0, 1))
** > lm <- lm(percent ~ year)
** > abline(lm)
** > bm <- glm(percent ~ year, family=binomial)
*

Warning message:

non-integer #successes in a binomial glm! in: eval(expr, envir, enclos)

> points(year, fitted(bm), pch="+")

**NULL
**

> curve(predict(bm, data.frame(year=x)), add=TRUE)

All four of the binomial-fitted points fall exactly on the simple linear regression line, and the predict() curve is nowhere near any of the data points. What am I doing wrong?

What does the warning mean? Do I need more points?

I am using R on Windows, Version 2.0.1 (2004-11-15)

Thank you for your kind help.

Sincerely,

James Salsman

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

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 Received on Mon Apr 11 17:21:31 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:31:06 EST
*