[R] how to get design matrix?
Gavin Simpson
gavin.simpson at ucl.ac.uk
Sun May 10 12:21:03 CEST 2009
On Sat, 2009-05-09 at 19:29 -0700, linakpl wrote:
> If I was doing an ANOVA analysis how can I get the design matrix R used?
You can do ANOVA several different ways in R, and that is just the few
functions to do this that I am aware of. Showing us what function/code
you used would be really helpful and is requested by the posting guide.
If you fitted the model using lm, then use the model.matrix method:
dat <- data.frame(Y = rnorm(100), X = gl(4,25))
mod <- lm(Y ~ X, data = dat)
mod
summary(mod)
model.matrix(mod)
This also works if you used aov()
If you used something else, then you'll have to say what...
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list