I want to plot a logistic regression curve of my data, but whenever I try to my plot produces multiple curves. Here\'s a picture of my last attempt:
last attempt
fit = glm(vs ~ hp, data=mtcars, family=binomial) newdat <- data.frame(hp=seq(min(mtcars$hp), max(mtcars$hp),len=100)) newdat$vs = predict(fit, newdata=newdat, type="response") plot(vs~hp, data=mtcars, col="red4") lines(vs ~ hp, newdat, col="green4", lwd=2)