[R] How to produce glm graph

Sonja Klein sonja.klein.07 at aberdeen.ac.uk
Sat Nov 20 18:22:20 CET 2010


Thanks for the advise.
I tried predict but no matter what I do I always get an error message saying
that the 'x' and 'y' differ in length. Most of my variables are also not
categorical but continous of which I'm not sure how to deal with.

R procedure of a simplified model with categorical variable:

model2<-glm(total$Response~total$Distance*total$Topography,binomial)
xv<-seq(0,500,1)
lines(xv,predict(model2,data.frame(Distance=xv,Topography=factor(rep("flat",length(xv),levels=levels(total$Topography))),type="response")))

I also tried it the way Crawley suggests in his book:
tf<-rep("flat",501)
yv<-predict(model2,list(Topography=factor(tf),Distance=xv),type="response")
lines(xv,yv)

But I still get the same error message saying that 'x' and 'y' differ in
lengths.


Any suggestions where the mistake might be?

In the end I want to get a graph for a model like this:
glm(Response~NEdist+I(NEdist^2)+Distance*Horizon+I(Distance^2)*Visibility
-- 
View this message in context: http://r.789695.n4.nabble.com/How-to-produce-glm-graph-tp3051548p3051755.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list