On Nov 20, 2010, at 12:22 PM, Sonja Klein wrote:


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")))

Did you look at predict? I am guessing you didn't satisfy its "needs", namely an exact match o the names of its terms. Those I() terms always mess me up and I avoid them religiously.


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?

The real mistake at this point is not including a workable example. See the Posting Guide. You are asking us to guess about mistakes in your data setup and aren't even including the exact error message. The fix for both issues you will see described in the Posting Guide.


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
--


David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to