[R] Plotting Factorial GLMs
Jarrett Byrnes
redbeard at arrr.net
Fri Nov 4 07:31:55 CET 2005
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!
More information about the R-help
mailing list