[R] logistic regression

David Winsemius dwinsemius at comcast.net
Wed Apr 4 03:57:52 CEST 2012


On Apr 3, 2012, at 9:25 PM, Melrose2012 wrote:

> I am trying to plot the logistic regression of a dataset (# of  
> living flies
> vs days the flies are alive) and then fit a best-fit line to this  
> data.
>
> Here is my code:
> plot(fflies$living~fflies$day,xlab="Number of Days",ylab="Number of  
> Fruit
> Flies",main="Number of Living Fruit Flies vs Day",pch=16)
> alive <- (fflies$living)
> dead <- (fflies$living[1]-alive)
> glm.fit <- glm(cbind(alive,dead)~fflies$day,family="binomial")
> summary(glm.fit)
> lines(sort(fflies$day),fitted(glm.fit) [order (fflies$day)],col =
> "red",lwd=2)
> lines(glm.fit,col = "red",lwd=2)

Is this homework?

>
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list