Re: Efficient creation of regression design matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg82316] Re: Efficient creation of regression design matrix
- From: "Michael Weyrauch" <michael.weyrauch at gmx.de>
- Date: Wed, 17 Oct 2007 04:09:27 -0400 (EDT)
- References: <ff1ovf$8g5$1@smc.vnet.net>
Hello, the following simple one-liner does what you want (I believe) Outer[S, n, m] /. S[a_, b_] /; a == b -> 1 /. S[__]->0 where "m" is your vector of properties and "n" your data vector, e.g. m = {r, b, g, y} n = {r, b, b, y, y, g, g} For S you can take anything you like. If this code is particularly efficient I don't know... Michael