I am using the contrast package to produce contrasts from a glm model that 
contains a quadratic term:
fit0 <- glm(y ~ x + I(x*x),data=mydata)
I would like to know how to specify the quadratic term, I(x*x), in the contrast 
function.
When I try to use 
contrast(fit0,list(x=4))
I receive an error message;
#Error in generateData(fit = list(coefficients = c(`(Intercept)` = 
0.5262645536229,  :not enough factors
When I try to use 
contrast(fit0,list(x=4,I(x*x)=16))
I receive an error message:
#Error: unexpected '=' in "contrast(fit0,list(x=4,I(x*x)="
Other variants of the call to contrast including
contrast(fit0,list(x=4,"x*x"=16)) and
contrast(fit0,list(x=4,"I(x*x}"=16))
produce similar error messsages.

Please see my code below.

if (!require(contrast)) install.packages("contrast")
library(contrast)
help(contrast)

x <- 1:100
y <- x + x^2 + rnorm(1)
mydata <- data.frame(x=x,y=y)

fit0 <- glm(y ~ x + I(x*x),data=mydata)
summary(fit0)

contrast(fit0,list(x=4))
#Error in generateData(fit = list(coefficients = c(`(Intercept)` = 
#0.5262645536229,  :  not enough factors

contrast(fit0,list(x=4,I(x*x)=16))
#Error: unexpected '=' in "contrast(fit0,list(x=4,I(x*x)="

Thank you,
John

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

Reply via email to