Thanks to all who replied (although next time, reply to the list!)
The simplest answer is to replace "A" in the curve statement with the
following:
rep("A", times=length(x))
Now if I could just figure out the workaround to plotting multiple sets
of points onto my graph in the first place (i.e. break up the x,y
values by block, then color them differently, and plot them on top of
each other as add=TRUE doesn't seem to work for the plot statement -
any pointers?)
On Nov 3, 2005, at 10:31 PM, Jarrett Byrnes wrote:
> Hello all,
> I'm attempting to plot the functions from a generalized linear model
> while iterating over multiple levels of a factor in the model. In
> other words, I have a data set
>
> Block, Treatment.Level, Response.Level
>
> So, the glm and code to plot should be
>
> logit.reg<-glm(formula = Response.Level ~ Treatment.Level + Block,
> family=quasibinomial(link="logit")))
>
> plot( Response.Level ~ Treatment.Level)
>
> logit.reg.function <- function (trt, blk) predict(logit.reg,
> data.frame(Treatment.Level=trt, Block=blk)
>
> curve(logit.reg.function(x, "A"), add=TRUE)
>
>
> But I get the error:
> Error in xy.coords(x, y) : 'x' and 'y' lengths differ
>
> Now, if I set Block="A" in the function, and take blk out, as
well as
> taking the "A" out of the curve statement, it plots just fine.
What am
> I doing wrong, as this would be a nice, quick, and easy way to whip up
> multiple curves from a factorial dataset!
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>