**Subject: **model.matrix() (PR#285)

*J.C.Rougier@durham.ac.uk*

**Date: **Wed 22 Sep 1999 - 20:32:12 EST

**Next message:**ripley@stats.ox.ac.uk: "Re: quasi-likelihood in glm (PR#284)"**Previous message:**plummer@iarc.fr: "quasi-likelihood in glm (PR#284)"**Next in thread:**Bill Venables: "Re: model.matrix() (PR#285)"

Message-Id: <199909221032.MAA17796@pubhealth.ku.dk>

I was alarmed to discover that model.matrix.default() can permute columns

with respect to the formula. This seems to happen with user-defined

components of the formula. Thus

X <- matrix(1:4, 1, 4, dimnames = list(NULL, LETTERS[1:4]))

Q <- function(x) x^2 # because model.matrix() does not like, eg, A:A

model.matrix(~ -1 + A + A:B + Q(C), data.frame(X))

has columns ordered A, Q(C), and A.B, not A, A.B, Q(C), as you might

expect (and I certainly expected!). This appears to happen .Internal-ly.

While on the subject, would it be reasonable to standardise the names of

interaction terms to be A:B not A.B, to match the terms in the formula.

Cheers, Jonathan.

Jonathan Rougier Science Laboratories

Department of Mathematical Sciences South Road

University of Durham Durham DH1 3LE

"[B]egin upon the precept ... that the things we see are to be

weighed in the scale with what we know" (Meredith, 1879, The Egoist)

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-

r-devel 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-devel-request@stat.math.ethz.ch

_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

**Next message:**ripley@stats.ox.ac.uk: "Re: quasi-likelihood in glm (PR#284)"**Previous message:**plummer@iarc.fr: "quasi-likelihood in glm (PR#284)"**Next in thread:**Bill Venables: "Re: model.matrix() (PR#285)"

*
This archive was generated by hypermail 2b25
: Tue 04 Jan 2000 - 14:16:08 EST
*