[R] Design matrix labels

Thomas Lumley thomas at biostat.washington.edu
Tue Jan 26 00:11:25 CET 1999


On Mon, 25 Jan 1999, John Logsdon wrote:

> If I have two factors A and B with levels '1','2','3' and '1','4','6','8'
> recpectively (note the gaps in the second one).  As factors, the levels
> are named as above while of course the internal codes are (1,2,3) and
> (1,2,3,4) respectively.
> 
> I want to make a design matrix of these as one would in a linear model
> except I can't use lm or glm since the error distribution is not
> tractable. 

You can still use model.frame() and model.matrix() to create design
matrices from formulas.

	mf<-model.frame(~A+B)
	mmat<-model.matrix(~A+B,mf)

If your factors A and B are in a data frame you can use the data= argument
to model.frame().

This is what glm() and lm() do internally.

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list