## Continuing with the same example, I now show the full set of
contrasts and their
## associated regression coefficients.  Remember that regression coefficients in
## models with factors are meaningful only when the dummy variables
are also displayed.

## construct full set of dummy variables to display all contrasts
sapply(threeway[,2:4], contrasts)  ## default is treatment contrasts
contrasts(threeway$A) <- cbind(Lin=c(-1,0,1), Quad=c(1,-2,1))
contrasts(threeway$B) <- cbind(Lin=c(-1,0,1), Quad=c(1,-2,1))
contrasts(threeway$C) <- cbind(Lin=c(-1,1))
sapply(threeway[,2:4], contrasts)  ## changed to orthogonal
                                   ## integer-valued polynomial contrasts

tw.aov <- aov(Y ~ A * B * C, data=threeway, x=TRUE)
x <- tw.aov$x    ## dummy variables x
t(x)

anova(tw.aov)
beta.hat <- coef(tw.aov)  ## regression coefficients beta.hat

## construct predicted values from beta.hat
y.hat <- x %*% beta.hat
y.hat
fitted(tw.aov)  ## compare to predicted values from fitted function

______________________________________________
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