Since you have provided no executable data and not even a clear enough
description of the data to offer advice regarding approaches or
pitfalls, I will use the example in glm's help page:
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
glm.D93r <- glm(counts
Hi Jo,
Next time try prepare a reproducible code.
You have several ways of do that (see Dylan Beaudette) and give a look
below.
x<-1:100
y<-7+x*(sqrt(x*runif(100)))
plot(y~x)
mod1<-glm(y~x)
mod2<-glm(y~x+I(x*x))
curve(mod1$coef[1]+mod1$coef[2]*x, col="red", add=T, lwd=3)
curve(mod2$coef[1]+mod2
One approach to this is generating a representative sequence of your
x-variable(s) with seq() or expand.grid(). Next use the predict()
function to make predictions from your glm object along the sequence.
Finally, plot the predictions vs. the new sequence. Putting everything
into a dataframe helps.
Hi!
I have fitted two glms assuming a poisson distribution which are:
fit1 <- glm(Aids ~ Year, data=aids, family=poisson())
fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())
I am trying to work out how to represent the fitted regression curves of fit1
and fit2 on the one graph.
4 matches
Mail list logo